mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
only complete the payment if it is in a completable state
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user