diff --git a/app/assets/javascripts/darkswarm/services/checkout.js.coffee b/app/assets/javascripts/darkswarm/services/checkout.js.coffee index d974004d92..3b7c2756d7 100644 --- a/app/assets/javascripts/darkswarm/services/checkout.js.coffee +++ b/app/assets/javascripts/darkswarm/services/checkout.js.coffee @@ -19,19 +19,24 @@ Darkswarm.factory 'Checkout', ($injector, CurrentOrder, ShippingMethods, StripeE Navigation.go response.data.path .catch (response) => try - if response.data.path - Navigation.go response.data.path - else - throw response unless response.data.errors || response.data.flash - - Loading.clear() - @errors = response.data.errors - RailsFlashLoader.loadFlash(response.data.flash) + @handle_checkout_error_response(response) catch error - Loading.clear() - RailsFlashLoader.loadFlash(error: t("checkout.failed")) # inform the user about the unexpected error + @loadFlash(error: t("checkout.failed")) # inform the user about the unexpected error throw error # generate a BugsnagJS alert + handle_checkout_error_response: (response) => + if response.data.path + Navigation.go response.data.path + else + throw response unless response.data.errors || response.data.flash + + @errors = response.data.errors + @loadFlash(response.data.flash) + + loadFlash: (flash) => + Loading.clear() + RailsFlashLoader.loadFlash(flash) + # Rails wants our Spree::Address data to be provided with _attributes preprocess: -> munged_order =