mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Deleted webhooks when disconnecting from Stripe
refs https://github.com/TryGhost/Team/issues/1006 When disconnecting from Stripe, we currently do not remove the webhooks, this will result in the webhooks from Stripe failing, and tending toward a 100% error rate, which will ultimately result in emails from Stripe about the failing webhook. In order to stop all of that from happening, we should make sure that we actively remove the webhook from Stripe when disconnecting.
This commit is contained in:
parent
2d394b3a2e
commit
67d2104190
@ -169,6 +169,10 @@ module.exports = function MembersAPI({
|
||||
});
|
||||
|
||||
async function disconnectStripe() {
|
||||
if (stripeConfig && stripeConfig.webhook && stripeConfig.webhook.id) {
|
||||
await stripeWebhookService.removeWebhook(stripeConfig.webhook.id);
|
||||
}
|
||||
|
||||
await Product.forge().query().update({
|
||||
monthly_price_id: null,
|
||||
yearly_price_id: null
|
||||
|
@ -100,6 +100,20 @@ module.exports = class StripeWebhookService {
|
||||
this._webhookSecret = webhook.secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id - WebhookEndpoint Stripe ID
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async removeWebhook(id) {
|
||||
try {
|
||||
await this._stripeAPIService.deleteWebhookEndpoint(id);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} body
|
||||
* @param {string} signature
|
||||
|
Loading…
Reference in New Issue
Block a user