mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-17 19:12:33 -05:00
Stripe API version update fixes
Using customer sources instead of cards so we can update our API version: https://stripe.com/docs/upgrades?since=2014-11-05#api-changelog
This commit is contained in:
parent
a4f50c4dd1
commit
7e46b819c4
2 changed files with 17 additions and 18 deletions
|
@ -36,7 +36,7 @@ module.exports = class SubscriptionView extends RootView
|
||||||
else
|
else
|
||||||
c.nextPaymentDate = periodEnd
|
c.nextPaymentDate = periodEnd
|
||||||
c.cost = "$#{(subscription.plan.amount/100).toFixed(2)}"
|
c.cost = "$#{(subscription.plan.amount/100).toFixed(2)}"
|
||||||
if card = @stripeInfo.cards?.data?[0]
|
if card = @stripeInfo.sources?.data?[0]
|
||||||
c.card = "#{card.brand}: x#{card.last4}"
|
c.card = "#{card.brand}: x#{card.last4}"
|
||||||
if @payments?.loaded
|
if @payments?.loaded
|
||||||
c.monthsSubscribed = (x for x in @payments.models when not x.get('productID')).length # productID is for gem purchases
|
c.monthsSubscribed = (x for x in @payments.models when not x.get('productID')).length # productID is for gem purchases
|
||||||
|
|
|
@ -148,7 +148,7 @@ describe '/db/payment', ->
|
||||||
it "updates the customer's card when you submit a new token", (done) ->
|
it "updates the customer's card when you submit a new token", (done) ->
|
||||||
stripe.customers.retrieve joeData.stripe.customerID, (err, customer) ->
|
stripe.customers.retrieve joeData.stripe.customerID, (err, customer) ->
|
||||||
originalCustomerID = customer.id
|
originalCustomerID = customer.id
|
||||||
originalCardID = customer.cards.data[0].id
|
originalCardID = customer.sources.data[0].id
|
||||||
stripe.tokens.create {
|
stripe.tokens.create {
|
||||||
card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' }
|
card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' }
|
||||||
}, (err, token) ->
|
}, (err, token) ->
|
||||||
|
@ -159,7 +159,7 @@ describe '/db/payment', ->
|
||||||
joeData = user.toObject()
|
joeData = user.toObject()
|
||||||
expect(joeData.stripe.customerID).toBe(originalCustomerID)
|
expect(joeData.stripe.customerID).toBe(originalCustomerID)
|
||||||
stripe.customers.retrieve joeData.stripe.customerID, (err, customer) ->
|
stripe.customers.retrieve joeData.stripe.customerID, (err, customer) ->
|
||||||
expect(customer.cards.data[0].id).not.toBe(originalCardID)
|
expect(customer.sources.data[0].id).not.toBe(originalCardID)
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it 'clears the db', (done) ->
|
it 'clears the db', (done) ->
|
||||||
|
@ -295,4 +295,3 @@ describe '/db/payment', ->
|
||||||
done()
|
done()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue