Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix bug where refunded amount is not take into account in the actual amount

Unknown4313ba0d8c2c
diff --git a/saleor/payment/gateways/stripe/__init__.py b/saleor/payment/gateways/stripe/__init__.py
index ea39e00060..85045d92ef 100644
--- a/saleor/payment/gateways/stripe/__init__.py
+++ b/saleor/payment/gateways/stripe/__init__.py
@@ -209,7 +209,12 @@ def _create_transaction(payment, amount, kind, response):
# Get amount from response or payment
if 'amount' in response:
- amount = get_amount_from_stripe(response.get('amount'), currency)
+ stripe_amount = response.get('amount')
+ if 'amount_refunded' in response:
+ # This happens for partial catpure which will refund the left
+ # Then the actual amount should minus refunded amount
+ stripe_amount -= response.get('amount_refunded')
+ amount = get_amount_from_stripe(stripe_amount, currency)
# Get token, which is an empty string for error responses
token = response.get('id', '')