#Shahriyar

1 messages · Page 1 of 1 (latest)

near peakBOT
true gyro
#

You want to send your customer to a Stripe-hosted page for paying the first invoice?

old oxide
#

yeah

true gyro
#

React is most irrelevant here, and these are both back end operations

#

Have you considered using Stripe Checkout to create subscriptions?

#

You can create your own subscriptions and direct customers to the hosted invoice payment page, but Checkout might be a better overall experience that supprots more payment methods

#

You can optionally create the customer first and provide the customer ID

old oxide
#

So I can create customer without the fields

payment_method: ?,
invoice_settings: {
  default_payment_method: ?,
}
#

Then I get the customer id and create a subscription

true gyro
#

If you want to manage the subscription creation yourself, then you can create it with payment_behavior=default_incomplete
then redirect the customer to the Invoice URL:
1/ Create subscription like this: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription
2/ From the latest_invoice get the invoice hosted_invoice_url to redirect your customer:
https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url

Create and manage subscriptions to accept recurring payments.

old oxide
#

Then after the subscription has been created how do I return the link where I will redirect the user to pay

true gyro
old oxide
#

Okay, let me try it real quick and I will get back to you if I succeed or fail

true gyro
#

However, this requires manually handling the default payment method setup, so I'd recommend evaluating Checkout if you're already looking for a redirect-based flow.

old oxide
#

I have a webhook and I will store the metadata on the subscription creation and let the webhook handle the other things that needs to be done after payment is done

#

So which will be best in this scenario

true gyro
#

I would still suggest Checkout, which can automatically set up the payment method for you for the renewal invoices

old oxide
true gyro
#

You don't create the subscription, you create a checkout session and redirect your customer to that

#

Checkout creates the subscription once your customer has filled in the payment form