Skip to content

Commit 90775b8

Browse files
YounesOMKWhyNotHugo
authored andcommitted
Fix premature status change in Stripe provider refund
1 parent 6e635ba commit 90775b8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

payments/stripe/providers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def refund(self, payment, amount=None) -> int:
164164
else:
165165
payment.attrs.refund = json.dumps(refund)
166166
payment.save()
167-
payment.change_status(PaymentStatus.REFUNDED)
168167
return self.convert_amount(payment.currency, to_refund)
169168

170169
raise PaymentError("Only Confirmed payments can be refunded")

payments/stripe/test_stripev3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def test_provider_refund_failure_stripe_error():
157157
provider.refund(payment)
158158

159159

160+
## Provider.refund() should not change the payment status.
161+
## Status management is handled by BasePayment.refund().
162+
## Refunds should be performed via payment.refund() (see docs/refund.rst).
160163
def test_provider_refund_success():
161164
payment = Payment()
162165
payment.status = PaymentStatus.CONFIRMED
@@ -171,4 +174,4 @@ def test_provider_refund_success():
171174
with patch("stripe.Refund.create", return_value=return_value):
172175
provider.refund(payment)
173176

174-
assert payment.status == PaymentStatus.REFUNDED
177+
assert payment.status == PaymentStatus.CONFIRMED

0 commit comments

Comments
 (0)