Gateway error messages (Stripe in particular)

89 views
Skip to first unread message

Niklas Oppermann

unread,
May 27, 2013, 10:30:21 AM5/27/13
to spree...@googlegroups.com
Hi there,

Was trying to implement Stripe's error messages in Spree's text for :gateway_error. After some fiddling and googling I found the issue has been raised and closed on github (https://github.com/spree/spree/issues/2478). I guess that issue was regarding a general solution for all Gateways. 

My question is, does anyone know (or can give pointers to) how I could implement this for a single case (Stripe Gateway)?

Many thanks in advance!

Best,
Niklas

Ryan Bigg

unread,
May 30, 2013, 10:25:26 AM5/30/13
to spree...@googlegroups.com
Hey Niklas,

Is there some steps that we can follow which would reproduce the problem that you're seeing? 
--

Ryan Bigg
Community Manager
Spree Commerce, Inc.

Niklas Oppermann

unread,
May 30, 2013, 12:09:10 PM5/30/13
to spree...@googlegroups.com
Hi Ryan,

Thanks for the message!

I configured the Stripe gateway (on spree 1.3.2) and tested with some of Stripe's card numbers that should give a specific error message (card declined, wrong address etc). As far as I could see, stripe_gateway.rb is set up to handle these error response mesages. The method :rescue_from_spree_gateway_error in checkout_controller.rb, however does not seem to be using these messages, but instead falls back to a standard error message (:spree_gateway_error_flash_for_checkout in the locale file).

As it is not implemented, and the issue seems to have been closed in the github issue I referenced, I'm not sure you could call it an error :) I would be thankful however, if anyone could point me in a direction for implementing this for just Stripe. A general solution for all gateways might be a harder nut to crack!

Thanks a lot!
Niklas

Niklas Oppermann

unread,
Jun 7, 2013, 1:32:31 PM6/7/13
to spree...@googlegroups.com
Hi Eric,

Thanks for the help, simple and effective! 

Best
Niklas

On Wed, Jun 5, 2013 at 2:42 AM, Eric Hochberger <erichoc...@gmail.com> wrote:
Hey Niklas,

We had this exact problem and some confused users! I solved it with a simple decorator:

module Spree
 
CheckoutController.class_eval do
   
def rescue_from_spree_gateway_error(error)
      flash
[:error] = error.message
      render
:edit
   
end
 
end
end


Ryan, would you be interested in a PR of this nature for 1-3-stable? Anything you'd like to see it do differently?
Reply all
Reply to author
Forward
0 new messages