Reputation: 118
I'm using stripe-react-native to handle payment, and I'm able to handle one-time payment via payment-sheet using PaymentIntent
flow.
Now I'm stuck with creating subscription using the same payment sheet flow, has anyone tried this before? Or an advise how to use PaymentIntent
in subscription?
Upvotes: 2
Views: 2895
Reputation: 373
You need to expand the subscription object with payment intent.
const subscription = await stripe.subscriptions.create({
...subscriptionSettings
expand: ['latest_invoice.payment_intent']
});
You can then access it using:
const paymentIntent = subscription.latest_invoice.payment_intent
const clientSecret = subscription.latest_invoice.payment_intent.client_secret
Upvotes: 4