Skip to content

Commit 377984c

Browse files
feat: add ISV payout schedule fields and payment_instrument_id (INT-1684)
1 parent ce427c8 commit 377984c

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎checkout_sdk/accounts/accounts.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,18 +520,24 @@ def __init__(self, frequency_p: ScheduleFrequency):
520520

521521

522522
class ScheduleFrequencyDailyRequest(ScheduleRequest):
523+
# For ISV (SaaS seller) sub-entities, a daily schedule runs on working days only
524+
# (Monday to Friday); payouts do not take place on weekends.
523525
def __init__(self):
524526
super().__init__(ScheduleFrequency.DAILY)
525527

526528

527529
class ScheduleFrequencyMonthlyRequest(ScheduleRequest):
530+
# For ISV (SaaS seller) sub-entities, by_month_day accepts only the combinations
531+
# [1], [15], [1, 15] or [1, 16], in any order.
528532
by_month_day: list # int
529533

530534
def __init__(self):
531535
super().__init__(ScheduleFrequency.MONTHLY)
532536

533537

534538
class ScheduleFrequencyWeeklyRequest(ScheduleRequest):
539+
# For ISV (SaaS seller) sub-entities, by_day accepts working days only
540+
# (Monday to Friday); payouts set to take place on weekends are rejected.
535541
by_day: list # DaySchedule
536542

537543
def __init__(self):
@@ -541,6 +547,14 @@ def __init__(self):
541547
class UpdateScheduleRequest:
542548
enabled: bool
543549
threshold: int
550+
# The amount, in the minor units of the schedule's currency, to retain in the
551+
# sub-entity's available balance. ISV (SaaS seller) sub-entities only. Min 0.
552+
balance_minimum: int
553+
# Indicates whether to carry forward any balance below the configured minimum
554+
# to the next payout. ISV (SaaS seller) sub-entities only.
555+
carry_forward_enabled: bool
556+
# The ID of the platforms payment instrument used as the payout destination.
557+
payment_instrument_id: str
544558
recurrence: ScheduleRequest
545559

546560

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import json
2+
3+
from checkout_sdk.json_serializer import JsonSerializer
4+
from checkout_sdk.accounts.accounts import (
5+
DaySchedule, ScheduleFrequencyWeeklyRequest, UpdateScheduleRequest,
6+
)
7+
8+
9+
def _serialize(obj):
10+
return json.loads(json.dumps(obj, cls=JsonSerializer))
11+
12+
13+
class TestUpdateScheduleRequestSerialization:
14+
15+
def test_serializes_isv_fields_when_set(self):
16+
recurrence = ScheduleFrequencyWeeklyRequest()
17+
recurrence.by_day = [DaySchedule.MONDAY]
18+
19+
request = UpdateScheduleRequest()
20+
request.enabled = True
21+
request.threshold = 100
22+
request.balance_minimum = 500
23+
request.carry_forward_enabled = True
24+
request.payment_instrument_id = 'ppi_w4jelhppmfiufdnatam37wrfc4'
25+
request.recurrence = recurrence
26+
27+
assert _serialize(request) == {
28+
'enabled': True,
29+
'threshold': 100,
30+
'balance_minimum': 500,
31+
'carry_forward_enabled': True,
32+
'payment_instrument_id': 'ppi_w4jelhppmfiufdnatam37wrfc4',
33+
'recurrence': {
34+
'frequency': 'weekly',
35+
'by_day': ['monday'],
36+
},
37+
}
38+
39+
def test_omits_isv_fields_when_unset(self):
40+
request = UpdateScheduleRequest()
41+
request.enabled = False
42+
43+
serialized = _serialize(request)
44+
assert serialized == {'enabled': False}
45+
assert 'balance_minimum' not in serialized
46+
assert 'carry_forward_enabled' not in serialized
47+
assert 'payment_instrument_id' not in serialized

0 commit comments

Comments
 (0)