#Tiana-portal
1 messages · Page 1 of 1 (latest)
And if not, how can I allow the customer to select a product while automatically cancelling the previous one as soon as the new one is paid ?
@heady lava it depends on the other parameters you pass. It lets the customer change the subscription. The options they have are dictated by https://stripe.com/docs/api/customer_portal/configurations/create#create_portal_configuration-features-subscription_update-products
, the idea being that looks like
[{
product : prod_1,
prices:[price_1, price_2]
},
{
product : prod_2,
prices:[price_3 ]
}]
i..e they can choose between those two products and the specific prices for them
Alright, will this automatically cancel the previous product ?
so if you don't want them to change products you'd only allow updates to be to other prices in the existing product by having a single entry in that array
not sure what 'cancel' means, but it switches the subscription to the new product yes
That's what I meant, yes. Thanks
Okay, turns out my boss don't want that in terms of UX in the end.
So here's another question : is it possible to create a checkout session which, once paid, will switch an existing subscription to a new product ?
no it's not
you can switch the product by just using the API as normal (https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing (and also potentially combine it with https://stripe.com/docs/billing/subscriptions/pending-updates )) and then if there's a payment required for the update, you can redirect to the hosted invoice page of the invoice created for the customer to pay there, that's pretty much the same thing as what you're asking for I think.
Yes.
How do I do that ?
do what exactly? I kind of explained it above
I mean what API endpoints can I use ?
the ones the docs I linked describe.
Can a customer create a subscription with a different currency from previous subscriptions ?
Why not ?
it's just a limitation that's always existed unfortunately! it's basically because of things like how a customer's debit/credit balance and amount_off coupons at a customer level could work
it's a really common pain point over the years and something we're actively looking at redesigning, but for now it is what it is.
Ok
So, if I need to create a new Stripe customer because our app user want to switch currency, can it be created with the same email ?
yep! they don't have to be unique across all customers, we don't enforce that.
Alright, does the dashboard allow my boss to retrieve all the data of an app user that has mutliple Stripe accounts with the same email in a single place ?
If not, how difficult is this to manage ?
you could create a few test customers in test mode with the same email and play around with it yourself to see
you can filter customers by email in the dashboard yes, for example.
Okay, thanks.
It doesn't say how to get the hosted invoice page after updating the subscription ?
yep but if you test this out it should naturally flow a little.
After you update the subscription, there might be an invoice generated(depends on the type of the update and what value you pass to payment_behavior ), it would be the latest_invoice field on the Subscription object. Invoices have a hosted_invoice_url https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url and you can redirect the user to that to pay that invoice which was generated for the update. https://stripe.com/docs/invoicing/hosted-invoice-page
I don't know about payment_behavior but I pass proration_behavior to always_invoice. What should I do about payment_behavior ?
oh yeah it's proration_behavior true, my bad. Just a typo.
Alright !
though you can use payment_behavior too, it's for pending updates
How do I redirect the user back to my app when using hosted_invoice_url ?
you can't unfortunately
What do I do then ?
well you just don't redirect. It depends how important this is to you. There are alternatives.
What alternatives are there ?
Also how do I set the locale of hosted_invoice_url ?
for example instead of using the hosted invoice page, once you have this update invoice, you can take the invoice.payment_intent.client_secret and use it on a custom payment page on your site. Confirming that PaymentIntent (https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-attached) does the same thing, pays the invoice and because it's on your own site you control the flow completely. It's just more work
Not an option 😅
ok!
as far as I know the locale comes from the customer's preferred_locales but I'd have to test it, it might also just be based on the browser you view the page in.
What's the type and format of preferred_locales ?
it's an array of strings of ISO 639 language codes like ["en","fr"]
Okay.