mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Notify Bugsnag on Stripe payment errors
This commit is contained in:
@@ -19,6 +19,11 @@ Darkswarm.factory 'StripeElements', ($rootScope, Messages) ->
|
||||
secrets.cc_type = @mapTokenApiCardBrand(response.token.card.brand)
|
||||
secrets.card = response.token.card
|
||||
submit()
|
||||
.catch (response) =>
|
||||
# Stripe handles errors in the response above. This code may never be
|
||||
# reached. But if we get here, we want to know.
|
||||
@reportError(response, t("js.stripe_elements.unknown_error_from_stripe"))
|
||||
throw response
|
||||
|
||||
# Create Payment Method to be used with the Stripe Payment Intents API
|
||||
createPaymentMethod: (secrets, submit, loading_message = t("processing_payment")) ->
|
||||
@@ -35,11 +40,17 @@ Darkswarm.factory 'StripeElements', ($rootScope, Messages) ->
|
||||
secrets.cc_type = @mapPaymentMethodsApiCardBrand(response.paymentMethod.card.brand)
|
||||
secrets.card = response.paymentMethod.card
|
||||
submit()
|
||||
.catch (response) =>
|
||||
# Stripe handles errors in the response above. This code may never be
|
||||
# reached. But if we get here, we want to know.
|
||||
@reportError(response, t("js.stripe_elements.unknown_error_from_stripe"))
|
||||
throw response
|
||||
|
||||
reportError: (error, messageForUser) ->
|
||||
Messages.error(messageForUser)
|
||||
@triggerAngularDigest()
|
||||
console.error(JSON.stringify(error))
|
||||
console.error(error)
|
||||
Bugsnag.notify(new Error(JSON.stringify(error)))
|
||||
|
||||
triggerAngularDigest: ->
|
||||
# $evalAsync is improved way of triggering a digest without calling $apply
|
||||
|
||||
@@ -2767,6 +2767,11 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
signup_or_login: "Start By Signing Up (or logging in)"
|
||||
have_an_account: "Already have an account?"
|
||||
action_login: "Log in now."
|
||||
stripe_elements:
|
||||
unknown_error_from_stripe: |
|
||||
Uh oh, the Stripe integration failed. You can try again but there is
|
||||
a very small chance that the payment came through already. It's best to
|
||||
check your bank account first.
|
||||
|
||||
# Singular and plural forms of commonly used words.
|
||||
# We use these entries to pluralize unit names in every language.
|
||||
|
||||
@@ -46,10 +46,12 @@ describe 'StripeElements Service', ->
|
||||
it "doesn't submit the form, shows an error message instead", inject (Loading, RailsFlashLoader) ->
|
||||
spyOn(Loading, "clear")
|
||||
spyOn(RailsFlashLoader, "loadFlash")
|
||||
spyOn(Bugsnag, "notify")
|
||||
StripeElements.requestToken(secrets, submit).then (data) ->
|
||||
expect(submit).not.toHaveBeenCalled()
|
||||
expect(Loading.clear).toHaveBeenCalled()
|
||||
expect(RailsFlashLoader.loadFlash).toHaveBeenCalledWith({error: "Error: There was a problem"})
|
||||
expect(Bugsnag.notify).toHaveBeenCalled()
|
||||
|
||||
describe 'mapTokenApiCardBrand', ->
|
||||
it "maps the brand returned by Stripe's tokenAPI to that required by activemerchant", ->
|
||||
|
||||
Reference in New Issue
Block a user