2

I'm stuck on this issue: When I try to submit this subscription, I got an error of "subscription_payment_intent_requires_action", should I handle it on client-side or there is another way to do it?

For information: I already created setupIntent (verify 3D Secure) and return payment_method

Steps: 1 - create setupIntent 2 - generate payment_method ( verify 3D Secure) 3 - create Customer and attach payment_method to it 4 - create Subscription (on back_end) => error: "subscription_payment_intent_requires_action" shows up!

Thank you all!

// Create Subscription With Payment Method + Customer ID
router.post('/createSubscription', function (req, res){
  const {payment_method, customerId} = req.body;
  var stripe = require("stripe")(stripe_sk);
  try{
  stripe.subscriptions
  .create({
    customer: customerId,
    items: [{
      plan: 'plan_HTGCI8ljPYFTHQ'
    }],
    default_payment_method: payment_method,
    expand: ["latest_invoice.payment_intent"],
    // enable_incomplete_payments: true
  }).then(subscription => {
    res.send({
      subscription : subscription
    })
  }).catch(err => {
    res.send({
      err
    })
  })
} catch (error) {
  res.send("Error : ", error);
}
});```
  • If you choose to create the setup intent before creating the subscription you need to ensure that you set the `off_session` flag to `true` when calling the subscription-create method: https://stripe.com/docs/api/subscriptions/create#create_subscription-off_session. Doing so will account for the previous setup intent. To clarify though, if an off session payment ever requires authentication you will need to bring the user back on-session in order to authenticate the payment - you can only do this client-side. Also, out of curiosity, how are you managing Step 1? Are you using a WebView? – ttmarek Jun 22 '20 at 14:12
  • No, I want the customer to pay the subscription even if he is disconnected so that's why I keep it off_session flag to true. However, I did it by return the payment intent on the subscription object to the client side to re-confirm it in order to validate the subscription, thanks! – Hamza Sabir Jun 27 '20 at 09:44

0 Answers0