#shahzaib3575
1 messages · Page 1 of 1 (latest)
Hi 👋 either approach seems viable.
Using pending updates is another option:
https://stripe.com/docs/billing/subscriptions/pending-updates
With that you update the Subscription, but the updates are rolled back if the payment for the update is not completed successfully.
here's what happens during organization registeration:
const customer = await stripe.customers.create({
email: body.user_email,
name: body.organization_name,
description: `User "${body.user_id}" is the member of the organization ${body.organization_name} ("${body.organization_id}")`,
metadata: {
organization_id: body.organization_id,
user_id: body.user_id,
},
})
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: price.id }],
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
})
payment_behavior: 'pending_if_incomplete',
proration_behavior: 'always_invoice',
should i add this?
To accomplish what?
in order to use the pending-update?
No Oh, are you talking about for updating the Subscription? (I was a bit confused because the code snippet was for creating a Subscription rather than updating it) If so, then yes, as shown in the linked guide, those are the settings you would use.
so, when the customer upgrades the subscription from free plan to the paid one, i'll update the subscription with new priceId and the following configs and check for the pending_update hash. but currently i dont know how to handle payment method. through latest_invoice?
Are you setting a Payment Method as the default for either the Subscription or the Customer before making the update? If not, then you will need a flow to collect payment method details from your customers.
payment_settings: { save_default_payment_method: 'on_subscription' } during initial free subscription
If not, then you will need a flow to collect payment method details from your customers.
currently i'm usingpending_setup_intentto collect payment for off-session
Okay, if you're using that to collect payment method details ahead of time, then the upgrade payment will likely succeed. However I believe you'll still want a flow to handle collecting new payment method details in case the payment fails.
so i'll check the latest_invoice.payment_intent for this, yeah?
can you point me to a specific doc page that covers payment method flow?
Depends on how you want to surface a payment interface to your customers. Are you hoping to do this on your own page using our Payment Element, or would you prefer to direct your customer to a prebuilt page that we offer?
i'll be using Payment Element
Gotcha, then yes, you will want to find the Payment Intent associated with the finalized Invoice that was created for the update, which should be in latest_invoice. Then you'll get the client secret from that Payment Intent and use it to initialize the Payment Element.
You can skip the Invoice creation steps, and use the last couple of steps shown here as a guide on how to use the Payment Element to pay for an Invoice:
https://stripe.com/docs/invoicing/integration?method=elements#accept-invoice-payment