mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
Show more helpful payment processing error in checkout
This commit is contained in:
@@ -293,6 +293,24 @@ Spree::Order.class_eval do
|
||||
complete? && distributor.andand.allow_order_changes? && order_cycle.andand.open?
|
||||
end
|
||||
|
||||
# Override of existing Spree method. Can remove when we reach 2-0-stable
|
||||
# See commit: https://github.com/spree/spree/commit/5fca58f658273451193d5711081d018c317814ed
|
||||
# Allows GatewayError to show useful error messages in checkout
|
||||
def process_payments!
|
||||
pending_payments.each do |payment|
|
||||
break if payment_total >= total
|
||||
|
||||
payment.process!
|
||||
|
||||
if payment.completed?
|
||||
self.payment_total += payment.amount
|
||||
end
|
||||
end
|
||||
rescue Spree::Core::GatewayError => e # This section changed
|
||||
result = !!Spree::Config[:allow_checkout_on_gateway_error]
|
||||
errors.add(:base, e.message) and return result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def shipping_address_from_distributor
|
||||
|
||||
@@ -68,7 +68,7 @@ describe "Submitting Stripe Connect charge requests", type: :request do
|
||||
put update_checkout_path, params
|
||||
expect(response.status).to be 400
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["flash"]["error"]).to eq I18n.t(:payment_processing_failed)
|
||||
expect(json_response["flash"]["error"]).to eq "Bup-bow..."
|
||||
expect(order.payments.completed.count).to be 0
|
||||
end
|
||||
end
|
||||
@@ -128,7 +128,7 @@ describe "Submitting Stripe Connect charge requests", type: :request do
|
||||
put update_checkout_path, params
|
||||
expect(response.status).to be 400
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["flash"]["error"]).to eq I18n.t(:payment_processing_failed)
|
||||
expect(json_response["flash"]["error"]).to eq "Bup-bow..."
|
||||
expect(order.payments.completed.count).to be 0
|
||||
end
|
||||
end
|
||||
@@ -147,7 +147,7 @@ describe "Submitting Stripe Connect charge requests", type: :request do
|
||||
put update_checkout_path, params
|
||||
expect(response.status).to be 400
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["flash"]["error"]).to eq I18n.t(:payment_processing_failed)
|
||||
expect(json_response["flash"]["error"]).to eq "Bup-bow..."
|
||||
expect(order.payments.completed.count).to be 0
|
||||
end
|
||||
end
|
||||
@@ -209,7 +209,7 @@ describe "Submitting Stripe Connect charge requests", type: :request do
|
||||
put update_checkout_path, params
|
||||
expect(response.status).to be 400
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["flash"]["error"]).to eq I18n.t(:payment_processing_failed)
|
||||
expect(json_response["flash"]["error"]).to eq "Bup-bow..."
|
||||
expect(order.payments.completed.count).to be 0
|
||||
end
|
||||
end
|
||||
@@ -228,7 +228,7 @@ describe "Submitting Stripe Connect charge requests", type: :request do
|
||||
put update_checkout_path, params
|
||||
expect(response.status).to be 400
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["flash"]["error"]).to eq I18n.t(:payment_processing_failed)
|
||||
expect(json_response["flash"]["error"]).to eq "Bup-bow..."
|
||||
expect(order.payments.completed.count).to be 0
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user