Created
September 8, 2013 20:45
-
-
Save gerep/6488265 to your computer and use it in GitHub Desktop.
[Blogger] Making spree 2.0.3 show your gateway error messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
CheckoutController.class_eval do | |
def update | |
if @order.update_attributes(object_params) | |
fire_event('spree.checkout.update') | |
return if after_update_attributes | |
unless @order.next | |
flash[:error] = @order.errors[:base].join("\n") | |
redirect_to checkout_state_path(@order.state) and return | |
end | |
if @order.completed? | |
session[:order_id] = nil | |
flash.notice = Spree.t(:order_processed_successfully) | |
flash[:commerce_tracking] = "nothing special" | |
redirect_to completion_route | |
else | |
redirect_to checkout_state_path(@order.state) | |
end | |
else | |
render :edit | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
Order.class_eval do | |
def process_payments! | |
if pending_payments.empty? | |
raise Core::GatewayError.new Spree.t(:no_pending_payments) | |
else | |
pending_payments.each do |payment| | |
break if payment_total >= total | |
payment.process! | |
if payment.completed? | |
self.payment_total += payment.amount | |
end | |
end | |
end | |
rescue Core::GatewayError => e | |
result = !!Spree::Config[:allow_checkout_on_gateway_error] | |
errors.add(:base, e.message) and return result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment