#alex-subscription-paymentmethod
1 messages · Page 1 of 1 (latest)
alex-subscription-paymentmethod
Hey @scarlet ivy ! You're likely missing https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method which is a few weeks old
the problem you had is basically you accepted a payment but never "saved" that PaymentMethod as the default payment method on the Customer or Subscription so on the next Invoice there's nothing to pay it
Thanks @craggy horizon!
That means this should fix the problem, right:
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [
{
price: req.body.price_id,
},
],
payment_behavior: "default_incomplete",
payment_settings: {save_default_payment_method: "on_subscription"},
expand: ["latest_invoice.payment_intent"],
coupon: req.body.coupon,
});
yes, with that, future subscriptions will have that pm_123 as the default after you confirm it successfully
for existing Subscriptions you need to basically make the Customer's existing PaymentMethod pm_ABC the default via https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
Ok, thx. So I need to execute this, right?
const subscription = await stripe.subscriptions.update(
'sub_1M9tg42Tb35ankTnQxxxxxxx',
{default_payment_method :"pm_1LxgzhD2E0GHKjbdvgCJxxxxx"},
);
yes!