#shahzaib3575

1 messages · Page 1 of 1 (latest)

dull jayBOT
fathom ingot
visual shoal
#

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?

fathom ingot
#

To accomplish what?

visual shoal
#

in order to use the pending-update?

fathom ingot
#

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.

visual shoal
#

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?

fathom ingot
#

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.

visual shoal
#

If not, then you will need a flow to collect payment method details from your customers.
currently i'm using pending_setup_intent to collect payment for off-session

fathom ingot
#

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.

visual shoal
#

can you point me to a specific doc page that covers payment method flow?

fathom ingot
#

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?

visual shoal
#

i'll be using Payment Element

fathom ingot
#

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

Learn how to create and send an invoice with code.