This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again
It looks like there is an issue with the Stripe documentation.
On https://stripe.com/docs/payments/save-after-payment#web-collect-card-details they have:
setup_future_usage: 'off_session'
But on https://stripe.com/docs/payments/save-and-reuse#web-collect-card-details they are missing this critical line.
But in your case, does the user select if they want to save their card on the frontend? Then you don't need to save the card on the backend and can save it in the confirmCardPayment
call: https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-save_payment_method :
save_payment_method
booleanIf the
PaymentIntent
is associated with a customer and this parameter is set totrue
, the provided payment method will be attached to the customer. Default isfalse
.