#Naveed | Web3Auth
1 messages · Page 1 of 1 (latest)
hello! you can probably use https://stripe.com/docs/billing/subscriptions/pending-updates and use the corresponding invoice to collect the payment details
so the corresponding invoice will contain an intent which i can use to init the payment element?
yep
OK ill give that a try!
On a similar note though, what about after doing that user wishes to upgrade further from growth -> scale?
Case 1 was:
- no credit card, has subscription
Now Case 2: - has credit card, has subscription
In case 2, user has a choice. Either
a) use pre-existing card or
b) add new card
I assume that for a, I can use pending updates again, but this time add payment method as part of subscription item params.
params := &stripe.SubscriptionParams{
Items: []*stripe.SubscriptionItemsParams{
{
ID: stripe.String(subscription.Items.Data[0].ID),
Price: stripe.String("price_CBb6IXqvTLXp3f"),
},
},
PaymentBehavior: stripe.String(string(stripe.SubscriptionPaymentBehaviorPendingIfIncomplete)),
ProrationBehavior: stripe.String(string(stripe.SubscriptionProrationBehaviorAlwaysInvoice)),
}
As for b, I will just have to do exactly what you'd mentioned above.
for b, it's going to be slightly different. You should collect the new card details up front and attach it to the customer first.
then depending on where you set the default_payment_method - you would update it either on the Subscription or on the Customer
Hmm why is that? isn't b similar to Case 1: no card, has sub
I will probably set subscriptions to charge default payment method, and any cards that get attached will be set to default
maybe it will make things easier
doesn't b already have an existing card set as the default payment method on the customer [0] or subscription?
if the default payment method is already set, then when you attempt to update the Subscription, the Subscription will charge that card
[0] https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
ahhh right
hmm seems like it'll be a bit complex to make it into one atomic flow
hrm, i guess another way about it is to identify the card to use upfront, and/or collect the new payment details first : https://stripe.com/docs/payments/save-and-reuse
Then perform the update on your backend by setting default_payment_method
so using set up intents u mean?
yep
so it would be like :
- identify the existing PaymentMethod to use, or create new PaymentMethod to use
- create the update to the subscription and make sure to also update the default payment method on the subscription or on the customer with the PaymentMethod (if required)
I see, from user's perspective probably they wouldn't know the difference. So it may be like
- set up card (if no payment method found on customer)
- Either update sub's payment method or update customer invoice settings.default payment method (whichever one I've chosen)
- Update subscription price items
yup, that's right!
ok ill try it out and see if it can handle this matrix of scenarios.
Is there a way to continue the same thread later on as this might take time to evaluate?
the thread will be closed after a while. If you come back later and have more questions, you can ask again in the main channel. You can also link to this thread if you need to reference it : https://discord.com/channels/841573134531821608/1077433543715721246