Skip to content

Commit

Permalink
Merge pull request #6 from radekholy24/renewal_trigger
Browse files Browse the repository at this point in the history
add renewal_triggered_by parameter to payment.set_renew_token
  • Loading branch information
PetrDlouhy authored Apr 12, 2024
2 parents 9c7454c + d989f4e commit 7008268
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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

0 comments on commit 7008268

Please sign in to comment.