#Shahriyar
1 messages · Page 1 of 1 (latest)
You want to send your customer to a Stripe-hosted page for paying the first invoice?
yeah
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
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
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
Then after the subscription has been created how do I return the link where I will redirect the user to pay
Yes, correct
That's what i explained in the message above
Okay, let me try it real quick and I will get back to you if I succeed or fail
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.
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
I would still suggest Checkout, which can automatically set up the payment method for you for the renewal invoices
ok so how do get the checkout page link from a created subscription
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
Following this guide