Ensured latest subscription data is always stored (#240)

no-issue

If we receive webhooks out of order, e.g. a
`customer.subscription.updated` with a status of 'active', followed by a
`customer.subscription.created` with a status of 'incomplete'. We would
overwrite the correct value with data from the "older" webhook. This
ensures that we always fetch the latest data from the Stripe API before
storing in the database.
This commit is contained in:
Fabien 'egg' O'Carroll 2021-02-11 17:43:36 +00:00 committed by GitHub
parent 8b3cd5499c
commit 991b6e92a3

View File

@ -169,7 +169,7 @@ module.exports = class MemberRepository {
throw new Error('Subscription is not associated with a customer for the member');
}
const subscription = data.subscription;
const subscription = await this._stripeAPIService.getSubscription(data.subscription.id);
let paymentMethodId;
if (!subscription.default_payment_method) {
paymentMethodId = null;