Skip to content

Commit

Permalink
Added captured amount to DummyProvider (#382)
Browse files Browse the repository at this point in the history
Fixes: #374
See: #382
  • Loading branch information
juanpsenn authored Oct 19, 2023
1 parent 93dc588 commit 2c28dd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions payments/dummy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def process_data(self, payment, request):
if verification_result:
payment.change_status(verification_result)
if payment.status in [PaymentStatus.CONFIRMED, PaymentStatus.PREAUTH]:
payment.captured_amount = payment.total
return HttpResponseRedirect(payment.get_success_url())
return HttpResponseRedirect(payment.get_failure_url())

def capture(self, payment, amount=None):
payment.change_status(PaymentStatus.CONFIRMED)
payment.captured_amount = amount or payment.total
return amount

def release(self, payment):
Expand Down
2 changes: 2 additions & 0 deletions payments/dummy/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Payment:
total = 100
status = PaymentStatus.WAITING
fraud_status = ""
captured_amount = 0

def get_process_url(self):
return "http://example.com"
Expand Down Expand Up @@ -50,6 +51,7 @@ def test_process_data_supports_verification_result(self):
request.GET = {"verification_result": verification_status}
response = provider.process_data(self.payment, request)
self.assertEqual(self.payment.status, verification_status)
self.assertEqual(self.payment.captured_amount, 100)
self.assertEqual(response.status_code, 302)
self.assertEqual(response["location"], self.payment.get_success_url())

Expand Down

0 comments on commit 2c28dd4

Please sign in to comment.