Search code examples
ruby-on-railsstripe-paymentspaymentcheckoutapplepay

Stripe payment intent with rails


I'm using stripe subscription payment in my rails application to charge my customers on my website. Does stripe subscription payment method uses the stripe paymentIntents or should I migrate to payment Intentets creations rather than payment subscriptions?

Stripe::Subscription.create(
  customer: user.stripe_id,
  items: [{ plan: plan.stripe_id }]
)

It already charges but I need to know should I migrate to payment intents or not.


Solution

  • I'd stick with the Subscriptions API. Subscription should create the necessary Payment Intent automatically.

    If you've used Subscriptions in the past, it's worth reading up on how the flow has changed. Historically, your Stripe::Subscription.create call would either result in a charge and start the subscription, or it would fail and throw an exception.

    That has changed with newer API versions. Now a Subscription will be created regardless of whether the initial charge succeeds or fails, but it can end up in an incomplete state, and you will need to take appropriate action to add a new payment method or have the user to authenticate their card.