mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
🐛Fix unpaid charges yield payments
Unpaid charges should not be recorded as successful payments in our database. Was happening when opening the buy gems modal again.
This commit is contained in:
parent
6e8ff798a1
commit
a8a55021b9
2 changed files with 4 additions and 1 deletions
|
@ -337,6 +337,7 @@ PaymentHandler = class PaymentHandler extends Handler
|
|||
[payments, charges] = results
|
||||
recordedChargeIDs = (p.get('stripe').chargeID for p in payments)
|
||||
for charge in charges
|
||||
continue unless charge.paid
|
||||
continue if charge.invoice # filter out subscription charges
|
||||
if charge.id not in recordedChargeIDs
|
||||
return @recordStripeCharge(req, res, charge)
|
||||
|
|
|
@ -284,7 +284,7 @@ describe 'Subscriptions', ->
|
|||
expect(user).not.toBeNull()
|
||||
sponsorStripe = user.get('stripe')
|
||||
sponsorCustomerID = sponsorStripe.customerID
|
||||
numSponsored = sponsorStripe.recipients.length
|
||||
numSponsored = sponsorStripe.recipients?.length
|
||||
expect(sponsorCustomerID).toBeDefined()
|
||||
expect(sponsorStripe.sponsorSubscriptionID).toBeDefined()
|
||||
expect(sponsorStripe.token).toBeUndefined()
|
||||
|
@ -368,6 +368,7 @@ describe 'Subscriptions', ->
|
|||
requestBody.stripe.prepaidCode = prepaidCode if prepaidCode?
|
||||
request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) ->
|
||||
expect(err).toBeNull()
|
||||
return done() if err
|
||||
expect(res.statusCode).toBe(200)
|
||||
expect(body.stripe.customerID).toBeDefined()
|
||||
expect(body.stripe.planID).toBe('basic')
|
||||
|
@ -412,6 +413,7 @@ describe 'Subscriptions', ->
|
|||
requestBody.stripe.token = token.id if token?
|
||||
request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) ->
|
||||
expect(err).toBeNull()
|
||||
return done() if err
|
||||
expect(res.statusCode).toBe(200)
|
||||
expect(body.stripe.customerID).toBeDefined()
|
||||
updatedUser = body
|
||||
|
|
Loading…
Reference in a new issue