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

add renewal_triggered_by parameter to payment.set_renew_token #6

Merged
merged 1 commit into from
Apr 12, 2024
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
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ History
Unreleased
**********
* fix backward compatibility by making PayuProvider's get_refund_description argument optional
* add `renewal_triggered_by` parameter to `payment.set_renew_token`
* make PayuProvider.refund fail if get_refund_description is not provided
* make PayuProvider.refund raise PayuApiError if an unexpected response is received
* deprecate the default value of get_refund_description; set it to a callable instead
* deprecate `automatic_renewal` parameter of `payment.set_renew_token`; use `renewal_triggered_by` parameter instead
* deprecate `None` value of `renewal_triggered_by` parameter of `payment.set_renew_token`; set `"user"`/`"task"`/`"other"` instead

1.3.1 (2024-03-19)
******************
Expand Down
2 changes: 1 addition & 1 deletion payments_payu/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def create_order(self, payment, payment_processor, auto_renew=False):
card_masked_number=response_dict["payMethods"]["payMethod"]["card"][
"number"
],
automatic_renewal=self.recurring_payments,
renewal_triggered_by="task" if self.recurring_payments else "user",
)
add_extra_data(payment, {"card_response": response_dict})

Expand Down
9 changes: 7 additions & 2 deletions tests/test_payu.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __eq__(self, other):


class Payment(Mock):
UNSET = object()

id = 1
description = "payment"
currency = "USD"
Expand Down Expand Up @@ -98,13 +100,15 @@ def set_renew_token(
card_expire_year=None,
card_expire_month=None,
card_masked_number=None,
automatic_renewal=None,
automatic_renewal=UNSET,
renewal_triggered_by=UNSET,
):
self.token = token
self.card_expire_year = card_expire_year
self.card_expire_month = card_expire_month
self.card_masked_number = card_masked_number
self.automatic_renewal = automatic_renewal
self.renewal_triggered_by = renewal_triggered_by


class TestPayuProvider(TestCase):
Expand Down Expand Up @@ -188,7 +192,8 @@ def test_redirect_payu_store_token(self):
self.assertEqual(self.payment.card_expire_year, 2021)
self.assertEqual(self.payment.card_expire_month, 1)
self.assertEqual(self.payment.card_masked_number, "1234xxx")
self.assertEqual(self.payment.automatic_renewal, True)
self.assertEqual(self.payment.automatic_renewal, Payment.UNSET)
self.assertEqual(self.payment.renewal_triggered_by, "task")

def test_redirect_payu_unknown_status(self):
self.set_up_provider(
Expand Down
Loading