diff --git a/ghost/members-api/index.js b/ghost/members-api/index.js index d7ca525727..7ec086e479 100644 --- a/ghost/members-api/index.js +++ b/ghost/members-api/index.js @@ -162,7 +162,10 @@ module.exports = function MembersApi({ return res.end('No permission'); } - const sessionInfo = await stripe.createCheckoutSession(member, plan); + const sessionInfo = await stripe.createCheckoutSession(member, plan, { + successUrl: req.body.successUrl, + cancelUrl: req.body.cancelUrl + }); res.writeHead(200, { 'Content-Type': 'application/json' diff --git a/ghost/members-api/lib/stripe/index.js b/ghost/members-api/lib/stripe/index.js index 145e80d0c9..e05905d7d3 100644 --- a/ghost/members-api/lib/stripe/index.js +++ b/ghost/members-api/lib/stripe/index.js @@ -77,7 +77,7 @@ module.exports = class StripePaymentProcessor { return this._stripe.webhooks.constructEvent(body, signature, this._webhookSecret); } - async createCheckoutSession(member, planName) { + async createCheckoutSession(member, planName, options) { let customer; if (member) { try { @@ -92,8 +92,8 @@ module.exports = class StripePaymentProcessor { const plan = this._plans.find(plan => plan.nickname === planName); const session = await this._stripe.checkout.sessions.create({ payment_method_types: ['card'], - success_url: this._checkoutSuccessUrl, - cancel_url: this._checkoutCancelUrl, + success_url: options.successUrl || this._checkoutSuccessUrl, + cancel_url: options.cancelUrl || this._checkoutCancelUrl, customer: customer ? customer.id : undefined, subscription_data: { items: [{