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:
parent
6806505a4c
commit
68d65c905a
1 changed files with 22 additions and 0 deletions
|
@ -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({
|
||||
|
|
Loading…
Add table
Reference in a new issue