Merge pull request #6965 from andrewpbrett/fix-sca-snail

Fix #6964: don't try to complete a failed payment
This commit is contained in:
Pau Pérez Fabregat
2021-03-04 17:26:24 +01:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ class ProcessPaymentIntent
last_payment.update_attribute(:cvv_response_message, nil)
OrderWorkflow.new(@order).next
last_payment.complete! if !last_payment.completed?
last_payment.complete! if last_payment.can_complete?
end
private

View File

@@ -47,5 +47,19 @@ describe ProcessPaymentIntent do
expect(order).to have_received(:deliver_order_confirmation_email)
end
end
context "payment is in a failed state" do
let(:invalid_intent) { "invalid" }
let(:service) { ProcessPaymentIntent.new(invalid_intent, order) }
before do
payment.update_attribute(:state, "failed")
end
it "does not complete the payment" do
service.call!
expect(payment.reload.state).to eq("failed")
end
end
end
end