Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added captured amount to DummyProvider #382

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 71 in payments/dummy/__init__.py

View check run for this annotation

Codecov / codecov/patch

payments/dummy/__init__.py#L71

Added line #L71 was not covered by tests
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
Loading