Skip to content
Open
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
4 changes: 3 additions & 1 deletion checkout_sdk/payments/hosted/hosted_payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from checkout_sdk.common.common import CustomerRequest, CustomerRetry
from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments import BillingDescriptor, PaymentInstruction, PaymentType, ShippingDetails, \
ThreeDsRequest, RiskRequest, PaymentRecipient, ProcessingSettings, PaymentSender
ThreeDsRequest, RiskRequest, PaymentRecipient, ProcessingSettings, PaymentSender, AuthorizationType, PaymentPlan
from checkout_sdk.payments.payments_previous import BillingInformation
from checkout_sdk.payments.sessions.sessions import SessionPaymentMethodConfiguration

Expand Down Expand Up @@ -40,3 +40,5 @@ class HostedPaymentsSessionRequest:
capture_on: datetime
instruction: PaymentInstruction
payment_method_configuration: SessionPaymentMethodConfiguration
authorization_type: AuthorizationType
payment_plan: PaymentPlan
4 changes: 3 additions & 1 deletion checkout_sdk/payments/links/payments_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from checkout_sdk.common.common import CustomerRequest, CustomerRetry
from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments import BillingDescriptor, PaymentInstruction, PaymentType, ShippingDetails, \
ThreeDsRequest, RiskRequest, PaymentRecipient, ProcessingSettings, PaymentSender
ThreeDsRequest, RiskRequest, PaymentRecipient, ProcessingSettings, PaymentSender, AuthorizationType, PaymentPlan
from checkout_sdk.payments.payments_previous import BillingInformation
from checkout_sdk.payments.sessions.sessions import SessionPaymentMethodConfiguration

Expand Down Expand Up @@ -39,3 +39,5 @@ class PaymentLinkRequest:
capture_on: datetime
instruction: PaymentInstruction
payment_method_configuration: SessionPaymentMethodConfiguration
authorization_type: AuthorizationType
payment_plan: PaymentPlan
4 changes: 3 additions & 1 deletion checkout_sdk/payments/sessions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments import PaymentType, BillingDescriptor, ShippingDetails, \
PaymentRecipient, ProcessingSettings, RiskRequest, ThreeDsRequest, PaymentSender
PaymentRecipient, ProcessingSettings, RiskRequest, ThreeDsRequest, PaymentSender, AuthorizationType, PaymentPlan
from checkout_sdk.sessions.sessions import SessionsBillingDescriptor


Expand Down Expand Up @@ -252,6 +252,8 @@ class PaymentSessionsRequest:
disabled_payment_methods: list # PaymentMethodsType
customer_retry: CustomerRetry
ip_address: str
authorization_type: AuthorizationType
payment_plan: PaymentPlan


class PaymentSessionWithPaymentRequest:
Expand Down
51 changes: 51 additions & 0 deletions tests/payments/payment_request_fields_serialization_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import json

from checkout_sdk.json_serializer import JsonSerializer
from checkout_sdk.payments.payments import AuthorizationType, PaymentPlan
from checkout_sdk.payments.hosted.hosted_payments import HostedPaymentsSessionRequest
from checkout_sdk.payments.links.payments_links import PaymentLinkRequest
from checkout_sdk.payments.sessions.sessions import PaymentSessionsRequest


def _serialize(obj):
return json.loads(json.dumps(obj, cls=JsonSerializer))


def _payment_plan():
plan = PaymentPlan()
plan.days_between_payments = 30
plan.total_number_of_payments = 12
return plan


class TestPaymentRequestFieldsSerialization:

def test_hosted_payments_request_serializes_authorization_type_and_payment_plan(self):
request = HostedPaymentsSessionRequest()
request.authorization_type = AuthorizationType.ESTIMATED
request.payment_plan = _payment_plan()

assert _serialize(request) == {
'authorization_type': 'Estimated',
'payment_plan': {'days_between_payments': 30, 'total_number_of_payments': 12},
}

def test_payment_link_request_serializes_authorization_type_and_payment_plan(self):
request = PaymentLinkRequest()
request.authorization_type = AuthorizationType.INCREMENTAL
request.payment_plan = _payment_plan()

assert _serialize(request) == {
'authorization_type': 'Incremental',
'payment_plan': {'days_between_payments': 30, 'total_number_of_payments': 12},
}

def test_payment_sessions_request_serializes_authorization_type_and_payment_plan(self):
request = PaymentSessionsRequest()
request.authorization_type = AuthorizationType.FINAL
request.payment_plan = _payment_plan()

assert _serialize(request) == {
'authorization_type': 'Final',
'payment_plan': {'days_between_payments': 30, 'total_number_of_payments': 12},
}
Loading