Skip to content

Commit

Permalink
Merge pull request #6965 from andrewpbrett/fix-sca-snail
Browse files Browse the repository at this point in the history
Fix #6964: don't try to complete a failed payment
  • Loading branch information
sauloperez authored Mar 4, 2021
2 parents ff23980 + 3b15e0e commit 982c3d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/process_payment_intent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call!

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
Expand Down
14 changes: 14 additions & 0 deletions spec/services/process_payment_intent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,19 @@
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

0 comments on commit 982c3d2

Please sign in to comment.