Don't let the server die when a sponsored subscription's sponsor can't be found.

This commit is contained in:
Nick Winter 2015-05-25 14:03:07 -07:00
parent bebe2dde21
commit bb17621b47

View file

@ -161,7 +161,10 @@ module.exports.setup = (app) ->
_.remove(stripeInfo.recipients, (s) -> s.userID is recipient.id) _.remove(stripeInfo.recipients, (s) -> s.userID is recipient.id)
options = options =
quantity: utils.getSponsoredSubsAmount(subscription.plan.amount, stripeInfo.recipients.length, stripeInfo.subscriptionID?) quantity: utils.getSponsoredSubsAmount(subscription.plan.amount, stripeInfo.recipients.length, stripeInfo.subscriptionID?)
console.log 'Updating sponsored subscription', stripeInfo.customerID, stripeInfo.sponsorSubscriptionID, options, 'from stripeInfo', stripeInfo, 'and subscription', subscription, 'for user', recipient.id, 'with sponsor', sponsor.id unless stripeInfo.sponsorSubscriptionID
# TODO: fix #2786 error for a particular customer which doesn't have this
console.error "Couldn't find sponsorSubscriptionID from stripeInfo", stripeInfo, 'for customer', stripeInfo.customerID, 'with options', options, 'and subscription', subscription, 'for user', recipient.id, 'with sponsor', sponsor.id
return res.send(500, '')
stripe.customers.updateSubscription stripeInfo.customerID, stripeInfo.sponsorSubscriptionID, options, (err, subscription) => stripe.customers.updateSubscription stripeInfo.customerID, stripeInfo.sponsorSubscriptionID, options, (err, subscription) =>
if err if err
logStripeWebhookError(err) logStripeWebhookError(err)