Thursday 25 July 2019

migrating stripe subscription to be SCA compliant (bad error)

I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.I have followed the documentation to create a subscription.Testing the flow with a fake card 4000002500003155 which requires setup, I encountered an issue.My setup is as follows.​Frontend does: stripe.createToken()Server does stripe.updatePaymentDetails({source}) (with token):Server creates the subscription:stripe.subscriptions.create({ customer: self.stripe_customer_id,tax_percent: 20,expand: ['latest_invoice.payment_intent', 'pending_setup_intent'], ...plan}​As expected the subscription response: subscription.pending_setup_intentis not null and has { client_secret: 'seti__', status: 'requires_action', payment_method: 'card___', ... }.On the frontend I attempt to handle the pending setup intent on the frontend with stripe.handleCardSetup(client_secret, {}); but I got the following error.The payment method supplied (pm____) does not belong to a Customer, but you supplied Customer cus____. Please attach the payment method to this Customer before using it with a SetupIntent.​I tried to remedy this by attaching the paymentMethod to the user before step 5.stripe.paymentMethods.attach('card____', { customer: customer_id });But I got the following error:The payment method you provided has already been attached to a customer.​Any help really appreciated :)

Submitted July 25, 2019 at 12:15PM by harrydry

No comments:

Post a Comment