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:
Matt Lott 2015-02-22 07:53:44 -08:00
parent a4f50c4dd1
commit 7e46b819c4
2 changed files with 17 additions and 18 deletions

View file

@ -36,7 +36,7 @@ module.exports = class SubscriptionView extends RootView
else
c.nextPaymentDate = periodEnd
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}"
if @payments?.loaded
c.monthsSubscribed = (x for x in @payments.models when not x.get('productID')).length # productID is for gem purchases

View file

@ -148,7 +148,7 @@ describe '/db/payment', ->
it "updates the customer's card when you submit a new token", (done) ->
stripe.customers.retrieve joeData.stripe.customerID, (err, customer) ->
originalCustomerID = customer.id
originalCardID = customer.cards.data[0].id
originalCardID = customer.sources.data[0].id
stripe.tokens.create {
card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' }
}, (err, token) ->
@ -159,7 +159,7 @@ describe '/db/payment', ->
joeData = user.toObject()
expect(joeData.stripe.customerID).toBe(originalCustomerID)
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()
it 'clears the db', (done) ->
@ -295,4 +295,3 @@ describe '/db/payment', ->
done()
)
)