mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Cleaned up fix for 500 errors on invalid Stripe subscription webhooks
no refs - moves up check for invalid subscription before making any DB requests to fail fast
This commit is contained in:
parent
e83c9e38a7
commit
43642216c8
1 changed files with 5 additions and 3 deletions
|
@ -138,15 +138,17 @@ module.exports = class StripeWebhookService {
|
|||
}
|
||||
|
||||
async subscriptionEvent(subscription) {
|
||||
const member = await this._memberRepository.get({
|
||||
customer_id: subscription.customer
|
||||
});
|
||||
const subscriptionPriceData = _.get(subscription, 'items.data');
|
||||
if (!subscriptionPriceData || subscriptionPriceData.length !== 1) {
|
||||
throw new errors.BadRequestError({
|
||||
message: 'Subscription should have exactly 1 price item'
|
||||
});
|
||||
}
|
||||
|
||||
const member = await this._memberRepository.get({
|
||||
customer_id: subscription.customer
|
||||
});
|
||||
|
||||
if (member) {
|
||||
await this._memberRepository.linkSubscription({
|
||||
id: member.id,
|
||||
|
|
Loading…
Add table
Reference in a new issue