mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Revert "Used mode to determine flow for checkout session (#184)"
no-issue
Reverting so that changesets can be released independently
This reverts commit d41e5f3b55
.
This commit is contained in:
parent
d41e5f3b55
commit
c30ffba75a
@ -331,7 +331,6 @@ module.exports = function MembersApi({
|
|||||||
res.writeHead(401);
|
res.writeHead(401);
|
||||||
return res.end();
|
return res.end();
|
||||||
}
|
}
|
||||||
common.logging.info(`Handling webhook ${event.type}`);
|
|
||||||
try {
|
try {
|
||||||
if (event.type === 'customer.subscription.deleted') {
|
if (event.type === 'customer.subscription.deleted') {
|
||||||
await stripe.handleCustomerSubscriptionDeletedWebhook(event.data.object);
|
await stripe.handleCustomerSubscriptionDeletedWebhook(event.data.object);
|
||||||
@ -350,15 +349,13 @@ module.exports = function MembersApi({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === 'checkout.session.completed') {
|
if (event.type === 'checkout.session.completed') {
|
||||||
if (event.data.object.mode === 'setup') {
|
if (event.data.object.setup_intent) {
|
||||||
common.logging.info('Handling "setup" mode Checkout Session');
|
|
||||||
const setupIntent = await stripe.getSetupIntent(event.data.object.setup_intent);
|
const setupIntent = await stripe.getSetupIntent(event.data.object.setup_intent);
|
||||||
const customer = await stripe.getCustomer(setupIntent.metadata.customer_id);
|
const customer = await stripe.getCustomer(setupIntent.metadata.customer_id);
|
||||||
const member = await users.get({email: customer.email});
|
const member = await users.get({email: customer.email});
|
||||||
|
|
||||||
await stripe.handleCheckoutSetupSessionCompletedWebhook(setupIntent, member);
|
await stripe.handleCheckoutSetupSessionCompletedWebhook(setupIntent, member);
|
||||||
} else if (event.data.object.mode === 'subscription') {
|
} else {
|
||||||
common.logging.info('Handling "subscription" mode Checkout Session');
|
|
||||||
const customer = await stripe.getCustomer(event.data.object.customer, {
|
const customer = await stripe.getCustomer(event.data.object.customer, {
|
||||||
expand: ['subscriptions.data.default_payment_method']
|
expand: ['subscriptions.data.default_payment_method']
|
||||||
});
|
});
|
||||||
@ -378,8 +375,6 @@ module.exports = function MembersApi({
|
|||||||
|
|
||||||
const emailType = 'signup';
|
const emailType = 'signup';
|
||||||
await sendEmailWithMagicLink({email: customer.email, requestedType: emailType, options: {forceEmailType: true}});
|
await sendEmailWithMagicLink({email: customer.email, requestedType: emailType, options: {forceEmailType: true}});
|
||||||
} else if (event.data.object.mode === 'payment') {
|
|
||||||
common.logging.info('Ignoring "payment" mode Checkout Session');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user