Pages - Menu

Sunday, September 8, 2013

Making spree 2.0.3 show your gateway error messages

Hi there, happy?

I have developed an active merchant gateway, called 2Pay and I configured my Spree to use it.

It was working great until I got warned that when something goes wrong with the client's credit card, spree is always showing a default error message.

Well, that is terrible because the client will have no idea of what is going on among all possibilities.

PAUSE: I have this on StackOverflow if you feel more comfortable there :)

I had to do one thing, check the spree_core source code using

bundle open spree_core
So I noticed how the checkout_controller was calling a default message when something goes wrong with the Gateway object so I had to update it but it didn't work 100%.

Searching a bit more I found that the order.rb model rescue block wasn't adding the error to the errors hash.

Anyway, these are the two files you need to override and to do that you need to create checkout_controller.rb as checkout_controller_decorator.rb on /controller and the order.rb as order_decorator.rb on /model.

I know the paths are obvious but some user on #spree channel told me to save them on different folder and that was making me more confused.



I really hope it helps you my friend.

Now, be a nice person and say something nice to who's with you :)

No comments:

Post a Comment