From 2179cc7fafd686d02a55a63b995878ee66bd6a04 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sun, 17 May 2020 11:35:22 +0100 Subject: [PATCH] Make StripeSCA void action make a refund instead StripeSCA does not support voiding confirmed payment intents so we need to make a refund instead --- app/models/spree/gateway/stripe_sca.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index 21fa698c3b..02681ae210 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -57,8 +57,11 @@ module Spree # NOTE: the name of this method is determined by Spree::Payment::Processing def void(response_code, _creditcard, gateway_options) + payment_intent_id = response_code + payment_intent_response = Stripe::PaymentIntent.retrieve(payment_intent_id, + stripe_account: stripe_account_id) gateway_options[:stripe_account] = stripe_account_id - provider.void(response_code, gateway_options) + provider.refund(payment_intent_response.amount_received, response_code, gateway_options) end # NOTE: the name of this method is determined by Spree::Payment::Processing