Switch to console.error so we get a bugsnag alert everytime a user has a problem with their card

Add paymentMethodsAPI specific mapping function, we had some errors in production with mastercards probably caused by ActiveMerchant not handling the card type correctly
This commit is contained in:
Luis Ramos
2020-04-01 17:22:17 +01:00
parent 73c4eedd06
commit 0e268a171f
3 changed files with 45 additions and 22 deletions

View File

@@ -51,11 +51,18 @@ describe 'StripeElements Service', ->
expect(Loading.clear).toHaveBeenCalled()
expect(RailsFlashLoader.loadFlash).toHaveBeenCalledWith({error: "Error: There was a problem"})
describe 'mapCC', ->
it "maps the brand returned by Stripe to that required by activemerchant", ->
expect(StripeElements.mapCC('MasterCard')).toEqual "master"
expect(StripeElements.mapCC('Visa')).toEqual "visa"
expect(StripeElements.mapCC('American Express')).toEqual "american_express"
expect(StripeElements.mapCC('Discover')).toEqual "discover"
expect(StripeElements.mapCC('JCB')).toEqual "jcb"
expect(StripeElements.mapCC('Diners Club')).toEqual "diners_club"
describe 'mapTokenApiCardBrand', ->
it "maps the brand returned by Stripe's tokenAPI to that required by activemerchant", ->
expect(StripeElements.mapTokenApiCardBrand('MasterCard')).toEqual "master"
expect(StripeElements.mapTokenApiCardBrand('Visa')).toEqual "visa"
expect(StripeElements.mapTokenApiCardBrand('American Express')).toEqual "american_express"
expect(StripeElements.mapTokenApiCardBrand('Discover')).toEqual "discover"
expect(StripeElements.mapTokenApiCardBrand('JCB')).toEqual "jcb"
expect(StripeElements.mapTokenApiCardBrand('Diners Club')).toEqual "diners_club"
describe 'mapPaymentMethodsApiCardBrand', ->
it "maps the brand returned by Stripe's paymentMethodsAPI to that required by activemerchant", ->
expect(StripeElements.mapPaymentMethodsApiCardBrand('mastercard')).toEqual "master"
expect(StripeElements.mapPaymentMethodsApiCardBrand('amex')).toEqual "american_express"
expect(StripeElements.mapPaymentMethodsApiCardBrand('diners')).toEqual "diners_club"
expect(StripeElements.mapPaymentMethodsApiCardBrand('visa')).toEqual "visa"