mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Added Stripe webhook listener for subscription created event (#208)
no-issue Subscription created events are required for migrating Stripe subscriptions from alternative platforms, which involves creating a new subscription for a customer (outside of Ghost) before cancelling the original subscription.
This commit is contained in:
parent
2544212ff7
commit
4359517e75
@ -346,6 +346,10 @@ module.exports = function MembersApi({
|
||||
await stripe.handleCustomerSubscriptionUpdatedWebhook(event.data.object);
|
||||
}
|
||||
|
||||
if (event.type === 'customer.subscription.created') {
|
||||
await stripe.handleCustomerSubscriptionCreatedWebhook(event.data.object);
|
||||
}
|
||||
|
||||
if (event.type === 'invoice.payment_succeeded') {
|
||||
await stripe.handleInvoicePaymentSucceededWebhook(event.data.object);
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ module.exports = class StripePaymentProcessor {
|
||||
'checkout.session.completed',
|
||||
'customer.subscription.deleted',
|
||||
'customer.subscription.updated',
|
||||
'customer.subscription.created',
|
||||
'invoice.payment_succeeded',
|
||||
'invoice.payment_failed'
|
||||
]
|
||||
@ -386,6 +387,10 @@ module.exports = class StripePaymentProcessor {
|
||||
await this._updateSubscription(subscription);
|
||||
}
|
||||
|
||||
async handleCustomerSubscriptionCreatedWebhook(subscription) {
|
||||
await this._updateSubscription(subscription);
|
||||
}
|
||||
|
||||
async handleInvoicePaymentSucceededWebhook(invoice) {
|
||||
const subscription = await retrieve(this._stripe, 'subscriptions', invoice.subscription, {
|
||||
expand: ['default_payment_method']
|
||||
|
Loading…
Reference in New Issue
Block a user