Hani Ghazi
Hani Ghazi

Reputation: 118

React-native Stripe Payment Sheet with Subscription

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

Answers (1)

Ethan Crabb
Ethan Crabb

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

Related Questions