mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 21:12:04 +03:00
Added support for custome success/cancel urls
no-issue This will allow clients to customise where they are redirecting to after the stripe checkout session is exited.
This commit is contained in:
parent
88832fa923
commit
dd566b3d29
@ -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'
|
||||
|
@ -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: [{
|
||||
|
Loading…
Reference in New Issue
Block a user