mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
move payment to requires_authorization if cvv_result is present
This commit is contained in:
@@ -175,7 +175,9 @@ module Spree
|
||||
|
||||
@payment.authorize!(full_order_path(@payment.order))
|
||||
|
||||
raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending?
|
||||
unless @payment.pending? || @payment.requires_authorization?
|
||||
raise Spree::Core::GatewayError, I18n.t('authorization_failure')
|
||||
end
|
||||
|
||||
return unless @payment.requires_authorization?
|
||||
|
||||
|
||||
@@ -236,7 +236,9 @@ module Spree
|
||||
if response.cvv_result
|
||||
self.cvv_response_code = response.cvv_result['code']
|
||||
self.cvv_response_message = response.cvv_result['message']
|
||||
self.require_authorization if self.cvv_response_message.present?
|
||||
if self.cvv_response_message.present?
|
||||
return self.require_authorization!
|
||||
end
|
||||
end
|
||||
end
|
||||
__send__("#{success_state}!")
|
||||
|
||||
@@ -15,7 +15,9 @@ module OrderManagement
|
||||
|
||||
@payment.authorize!(redirect_url)
|
||||
|
||||
@order.errors.add(:base, I18n.t('authorization_failure')) unless @payment.pending?
|
||||
unless @payment.pending? || @payment.requires_authorization?
|
||||
@order.errors.add(:base, I18n.t('authorization_failure'))
|
||||
end
|
||||
|
||||
@payment
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ module OrderManagement
|
||||
allow(PaymentMailer).to receive(:authorize_payment) { mail_mock }
|
||||
allow(PaymentMailer).to receive(:authorization_required) { mail_mock }
|
||||
allow(payment).to receive(:authorize!) {
|
||||
payment.state = "pending"
|
||||
payment.state = "requires_authorization"
|
||||
payment.cvv_response_message = "https://stripe.com/redirect"
|
||||
}
|
||||
end
|
||||
|
||||
@@ -82,7 +82,7 @@ feature '
|
||||
|
||||
expect(page).to have_link "StripeSCA"
|
||||
expect(page).to have_content "PENDING"
|
||||
expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "pending"
|
||||
expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "requires_authorization"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,11 @@ describe PaymentsRequiringAction do
|
||||
describe '#query' do
|
||||
context "payment has a cvv_response_message" do
|
||||
let(:payment) do
|
||||
create(:payment, order: order, cvv_response_message: "https://stripe.com/redirect")
|
||||
create(:payment,
|
||||
order: order,
|
||||
cvv_response_message: "https://stripe.com/redirect",
|
||||
state: "requires_authorization"
|
||||
)
|
||||
end
|
||||
|
||||
it "finds the payment" do
|
||||
|
||||
Reference in New Issue
Block a user