Skip to content

Instantly share code, notes, and snippets.

@gerep
Created September 8, 2013 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerep/6488265 to your computer and use it in GitHub Desktop.
Save gerep/6488265 to your computer and use it in GitHub Desktop.
[Blogger] Making spree 2.0.3 show your gateway error messages
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
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