This commit is contained in:
Andy Brett
2020-12-03 15:07:58 -08:00
parent dfabc5fa06
commit 96462325d2
2 changed files with 9 additions and 2 deletions

View File

@@ -61,7 +61,7 @@ module Spree
payment_intent_response = Stripe::PaymentIntent.retrieve(payment_intent_id,
stripe_account: stripe_account_id)
gateway_options[:stripe_account] = stripe_account_id
provider.refund(payment_intent_response.amount_received, response_code, gateway_options)
provider.refund(refundable_amount(payment_intent_response), response_code, gateway_options)
end
# NOTE: the name of this method is determined by Spree::Payment::Processing
@@ -79,6 +79,11 @@ module Spree
private
def refundable_amount(payment_intent_response)
payment_intent_response.amount_received -
payment_intent_response.charges.data.map(&:amount_refunded).sum
end
# In this gateway, what we call 'secret_key' is the 'login'
def options
options = super

View File

@@ -75,7 +75,9 @@ module StripeStubs
amount_received: 2000,
status: options[:intent_status] || "requires_capture",
last_payment_error: nil,
charges: { data: [{ id: "ch_1234", amount: 2000 }] }) }
charges: {
data: [{ id: "ch_1234", amount: 2000, amount_refunded: 0 }] })
}
end
def payment_intent_redirect_response_mock(redirect_url)