From ef0763394a66d6e7f8e8a0e7de5ed59fc26fb23c Mon Sep 17 00:00:00 2001 From: Philip Peterson Date: Mon, 11 Aug 2025 00:45:58 -0700 Subject: [PATCH 1/2] Subscription cancel should cancel, not delete --- fixed-price-subscriptions/server/node/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fixed-price-subscriptions/server/node/server.js b/fixed-price-subscriptions/server/node/server.js index 968b160f..cd5ab3c8 100644 --- a/fixed-price-subscriptions/server/node/server.js +++ b/fixed-price-subscriptions/server/node/server.js @@ -136,11 +136,11 @@ app.get('/invoice-preview', async (req, res) => { app.post('/cancel-subscription', async (req, res) => { // Cancel the subscription try { - const deletedSubscription = await stripe.subscriptions.del( + const canceledSubscription = await stripe.subscriptions.cancel( req.body.subscriptionId ); - res.send({ subscription: deletedSubscription }); + res.send({ subscription: canceledSubscription }); } catch (error) { return res.status(400).send({ error: { message: error.message } }); } From 493545703e4e8e5c22f233511674484635705745 Mon Sep 17 00:00:00 2001 From: Philip Peterson Date: Mon, 11 Aug 2025 00:46:10 -0700 Subject: [PATCH 2/2] Payment intent plumbing fix --- fixed-price-subscriptions/server/node/server.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fixed-price-subscriptions/server/node/server.js b/fixed-price-subscriptions/server/node/server.js index cd5ab3c8..200aeb14 100644 --- a/fixed-price-subscriptions/server/node/server.js +++ b/fixed-price-subscriptions/server/node/server.js @@ -215,11 +215,14 @@ app.post( // The subscription automatically activates after successful payment // Set the payment method used to pay the first invoice // as the default payment method for that subscription - const subscription_id = dataObject['subscription'] - const payment_intent_id = dataObject['payment_intent'] + const subscription_id = dataObject.parent.subscription_details.subscription; + + const subscription = await stripe.subscriptions.retrieve(subscription_id, { + expand: ['latest_invoice.payment_intent'] + }); // Retrieve the payment intent used to pay the subscription - const payment_intent = await stripe.paymentIntents.retrieve(payment_intent_id); + const payment_intent = subscription.latest_invoice.payment_intent; try { const subscription = await stripe.subscriptions.update(