diff --git a/checkout_sdk/accounts/accounts.py b/checkout_sdk/accounts/accounts.py index e2d1ae77..5225b14d 100644 --- a/checkout_sdk/accounts/accounts.py +++ b/checkout_sdk/accounts/accounts.py @@ -520,11 +520,15 @@ def __init__(self, frequency_p: ScheduleFrequency): class ScheduleFrequencyDailyRequest(ScheduleRequest): + # For ISV (SaaS seller) sub-entities, a daily schedule runs on working days only + # (Monday to Friday); payouts do not take place on weekends. def __init__(self): super().__init__(ScheduleFrequency.DAILY) class ScheduleFrequencyMonthlyRequest(ScheduleRequest): + # For ISV (SaaS seller) sub-entities, by_month_day accepts only the combinations + # [1], [15], [1, 15] or [1, 16], in any order. by_month_day: list # int def __init__(self): @@ -532,6 +536,8 @@ def __init__(self): class ScheduleFrequencyWeeklyRequest(ScheduleRequest): + # For ISV (SaaS seller) sub-entities, by_day accepts working days only + # (Monday to Friday); payouts set to take place on weekends are rejected. by_day: list # DaySchedule def __init__(self): @@ -541,6 +547,14 @@ def __init__(self): class UpdateScheduleRequest: enabled: bool threshold: int + # The amount, in the minor units of the schedule's currency, to retain in the + # sub-entity's available balance. ISV (SaaS seller) sub-entities only. Min 0. + balance_minimum: int + # Indicates whether to carry forward any balance below the configured minimum + # to the next payout. ISV (SaaS seller) sub-entities only. + carry_forward_enabled: bool + # The ID of the platforms payment instrument used as the payout destination. + payment_instrument_id: str recurrence: ScheduleRequest diff --git a/tests/accounts/update_schedule_request_serialization_test.py b/tests/accounts/update_schedule_request_serialization_test.py new file mode 100644 index 00000000..d9fd05cf --- /dev/null +++ b/tests/accounts/update_schedule_request_serialization_test.py @@ -0,0 +1,47 @@ +import json + +from checkout_sdk.json_serializer import JsonSerializer +from checkout_sdk.accounts.accounts import ( + DaySchedule, ScheduleFrequencyWeeklyRequest, UpdateScheduleRequest, +) + + +def _serialize(obj): + return json.loads(json.dumps(obj, cls=JsonSerializer)) + + +class TestUpdateScheduleRequestSerialization: + + def test_serializes_isv_fields_when_set(self): + recurrence = ScheduleFrequencyWeeklyRequest() + recurrence.by_day = [DaySchedule.MONDAY] + + request = UpdateScheduleRequest() + request.enabled = True + request.threshold = 100 + request.balance_minimum = 500 + request.carry_forward_enabled = True + request.payment_instrument_id = 'ppi_w4jelhppmfiufdnatam37wrfc4' + request.recurrence = recurrence + + assert _serialize(request) == { + 'enabled': True, + 'threshold': 100, + 'balance_minimum': 500, + 'carry_forward_enabled': True, + 'payment_instrument_id': 'ppi_w4jelhppmfiufdnatam37wrfc4', + 'recurrence': { + 'frequency': 'weekly', + 'by_day': ['monday'], + }, + } + + def test_omits_isv_fields_when_unset(self): + request = UpdateScheduleRequest() + request.enabled = False + + serialized = _serialize(request) + assert serialized == {'enabled': False} + assert 'balance_minimum' not in serialized + assert 'carry_forward_enabled' not in serialized + assert 'payment_instrument_id' not in serialized