mark payment failed after failed authorization

This commit is contained in:
Andy Brett
2021-06-18 11:41:52 -07:00
parent f61fbee52a
commit 9b1da14380
3 changed files with 5 additions and 3 deletions

View File

@@ -46,6 +46,8 @@ class ProcessPaymentIntent
Result.new(ok: false, error: I18n.t("payment_could_not_complete"))
end
rescue Stripe::StripeError => e
payment.failed_authorization
payment.clear_authorization_url
Result.new(ok: false, error: e.message)
end

View File

@@ -171,8 +171,8 @@ describe Spree::OrdersController, type: :controller do
expect(response.status).to eq 200
expect(flash[:error]).to eq("#{I18n.t('payment_could_not_process')}. error message")
payment.reload
expect(payment.cvv_response_message).to eq("https://stripe.com/redirect")
expect(payment.state).to eq("requires_authorization")
expect(payment.cvv_response_message).to be nil
expect(payment.state).to eq("failed")
end
end

View File

@@ -65,7 +65,7 @@ describe ProcessPaymentIntent do
it "does not complete the payment" do
service.call!
expect(payment.reload.state).to eq("requires_authorization")
expect(payment.reload.state).to eq("failed")
end
end
end