#_api
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1276159077977821277
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
hello!
no, a Checkout Session can only create brand new Subscriptions.
but why whould you need this? to exit an existing Subscription?
no, we want to give users a payment page when they want to go pay for a trial
then why not use a Checkout Session to create a new Subscription?
I'm not sure I understand your use case.
so a trial creates a subscription object in the backend, and we want to add payment details to that trial so that it becomes a paid subscription rather than a whole new subscription
so your goal is to add a payment method to a Subscription that is active with a trial?
you could use the Customer Portal for this: https://docs.stripe.com/customer-management
Yea that's our current solution
but what we want is a link to the payment page you get when you do a subscription - is that possible?
I don't undertsand your question. if you use the customer portal, users will be able to add a payment method to their subscription.
I know that it works, but we want to reduce the friction since customer portal has a lot showing there
we want them to land directly on the payment page for subscriptions
I think that's possible with deep links: https://docs.stripe.com/customer-management/portal-deep-links
Hi, stepping in and catching up
Hello
Let me know if you need me to clarify anything
also in a work call, don't clsoe the thread
We document how you can create a deep link here: https://docs.stripe.com/customer-management/portal-deep-links#what-is-a-flow. You would need to handle that on your code.
Here is the examples code: https://docs.stripe.com/customer-management/portal-deep-links#create-a-flow
const session = await stripe.billingPortal.sessions.create({
customer: '{{CUSTOMER_ID}}',
return_url: 'https://example.com/account/overview',
flow_data: {
type: 'payment_method_update',
},
});
by doing this, the customer will only be shown the payment page and nothing else?
can you answer this question as well?
Yes, that is correct. I highly recommend that you test this using your test api key and play around a bit.
what about the other question i asked?
I am sorry, can you clarify which question? I might have missed it
Yes, that is correct.
I tried it out and see what you mean
this works, thanks!
wait
how is this attached to a current subscription?
i need it to be for a specific customer for a specific subscription - this doesn't have that
Are you saying that if a customer has 2 subscriptions, you would want them to update the payment method on only one of the subscriptions? Why?
yes
because if customer has two subscriptions, and they want to purchase only one of them for the next month, I don't want them to put their payment details for both of them
just the one they want to purchase
the same idea with trials as well
That is not possible. The above method updates this customer.invoice_settings.default_payment_method on the customer object.
I created this link using the stripe dashboard (per customer per subscription) - how can I create this programatically?
https://billing.stripe.com/p/subscription/update_payment_method_link/CBcaFwoVYWNjdF8xT2JVRlNId0RhMDVnekVjKIHonLYGMgZ90C7d42U6OtYrE-tmke6C_R4Dg0CORfnIvOTAxU7ExUjJJskGThwd76HOSZ7yykjezjOd3VKK4IBVNnXIGoyyLSI
you can pass the customer: https://docs.stripe.com/api/customer_portal/sessions/create#create_portal_session-customer when you create the Session
this creates a customer portal session
the link i shared is not a csutomer portal
please look at the link
The link you shared is using the CustomerPortal but you would use it with the deep link I shared with you above.
Can you try passing the customer id to the previous code you tested?
I did pass in a customer id
I want to pass in a subscription id as well
i need it to be for a specific customer for a specific subscription - this doesn't have that
That is not possible
It is!
I made the link through the stripe portal earlier
how can I make it programtically?
its not a customer portal link
I mean, you would create a Portal Configuration and the pass that when you create the link to limit what they can update on the products: https://docs.stripe.com/api/customer_portal/configurations/object#portal_configuration_object-features-subscription_update-products via the API. Also, please note that the functionalities on the API and the Dashboard do not mirror each other all the time. Some things supported via the Dashboard are not supported via the API.
the earlier snippet of code you shared is a billing portal and this is to create a customer portal
I don't it's possible from our conversation
thanks for the help
Sure!