0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Added webhook handlers for subscription lifecycle events

no-issue

We will need these to keep our metadata in sync with stripe
This commit is contained in:
Fabien O'Carroll 2019-10-08 14:10:34 +07:00
parent 6806505a4c
commit 68d65c905a

View file

@ -172,6 +172,28 @@ module.exports = class StripePaymentProcessor {
}
}
async handleCustomerSubscriptionDeletedWebhook(subscription) {
await this._updateSubscription(subscription);
}
async handleCustomerSubscriptionUpdatedWebhook(subscription) {
await this._updateSubscription(subscription);
}
async handleInvoicePaymentSucceededWebhook(invoice) {
const subscription = await retrieve(this._stripe, 'subscriptions', invoice.subscription, {
expand: ['default_payment_method']
});
await this._updateSubscription(subscription);
}
async handleInvoicePaymentFailedWebhook(invoice) {
const subscription = await retrieve(this._stripe, 'subscriptions', invoice.subscription, {
expand: ['default_payment_method']
});
await this._updateSubscription(subscription);
}
async _addCustomerToMember(member, customer) {
debug(`Attaching customer to member ${member.email} ${customer.id}`);
await this.storage.set({