Fixed errors for non-subscription invoices

refs https://github.com/TryGhost/Team/issues/887

Our invoice webhook handling code assumed that every invoice would be
for a subscription, but that is not the case. There are valid use-cases
of using the same Stripe account in order to sell items with a one-off
purchase. Here we update the handling to ignore all invoices which are
not for subscriptions.
This commit is contained in:
Fabien O'Carroll 2021-11-02 15:34:02 +02:00
parent d0b349828a
commit 635c2614a3

View File

@ -155,6 +155,9 @@ module.exports = class StripeWebhookService {
* @returns {Promise<void>}
*/
async invoiceEvent(invoice) {
if (!invoice.subscription) {
return;
}
const subscription = await this._stripeAPIService.getSubscription(invoice.subscription, {
expand: ['default_payment_method']
});