Skip to content
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
48 changes: 46 additions & 2 deletions checkout_sdk/payments/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Exemption(str, Enum):
LOW_VALUE = 'low_value'
SECURE_CORPORATE_PAYMENT = 'secure_corporate_payment'
TRUSTED_LISTING = 'trusted_listing'
TRUSTED_LISTING_PROMPT = 'trusted_listing_prompt'
TRANSACTION_RISK_ASSESSMENT = 'transaction_risk_assessment'
THREE_DS_OUTAGE = '3ds_outage'
SCA_DELEGATION = 'sca_delegation'
Expand Down Expand Up @@ -124,10 +125,14 @@ class BillingPlanType(str, Enum):
PRE_APPROVED_PAYMENTS = 'PRE_APPROVED_PAYMENTS'


class PanPreference(str, Enum):
FPAN = 'fpan'
DPAN = 'dpan'


class BillingDescriptor:
name: str
city: str
# Not available on previous
reference: str


Expand Down Expand Up @@ -324,7 +329,6 @@ class ThreeDsRequest:
exemption: Exemption
challenge_indicator: ChallengeIndicator
allow_upgrade: bool
# Not available on Previous
status: str
authentication_date: datetime
authentication_amount: int
Expand Down Expand Up @@ -380,6 +384,41 @@ class SenderInformation:
sourceOfFunds: str


class PartnerCustomerRiskData:
key: str
value: str


class AccommodationAddress:
address_line1: str
zip: str


class AccommodationGuest:
first_name: str
last_name: str
date_of_birth: str


class AccommodationRoom:
rate: str
number_of_nights_at_room_rate: str


class AccommodationData:
name: str
booking_reference: str
check_in_date: str
check_out_date: str
address: AccommodationAddress
state: str
country: str
city: str
number_of_rooms: int
guests: list # AccommodationGuest
room: list # AccommodationRoom


class ProcessingSettings:
order_id: str
tax_amount: int
Expand Down Expand Up @@ -414,6 +453,11 @@ class ProcessingSettings:
dlocal: DLocalProcessingSettings
senderInformation: SenderInformation
purpose: str
partner_customer_risk_data: list # PartnerCustomerRiskData
accommodation_data: list # AccommodationData
surcharge_amount: int
pan_preference: PanPreference
provision_network_token: bool


class Product:
Expand Down
234 changes: 215 additions & 19 deletions checkout_sdk/payments/sessions/sessions.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,270 @@
from datetime import datetime
from enum import Enum

from checkout_sdk.common.common import Address, CustomerRequest
from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments import PaymentType, BillingDescriptor, PaymentCustomerRequest, ShippingDetails, \
PaymentRecipient, ProcessingSettings, RiskRequest, PaymentRetryRequest, ThreeDsRequest, PaymentSender
from checkout_sdk.payments.payments_previous import BillingInformation
PaymentRecipient, ProcessingSettings, RiskRequest, ThreeDsRequest, PaymentSender


class PaymentMethodsType(str, Enum):
ALIPAY_CN = 'alipay_cn'
ALIPAY_HK = 'alipay_hk'
ALMA = 'alma'
APPLEPAY = 'applepay'
BANCONTACT = 'bancontact'
BENEFIT = 'benefit'
BIZUM = 'bizum'
CARD = 'card'
DANA = 'dana'
EPS = 'eps'
GIROPAY = 'giropay'
GCASH = 'gcash'
GOOGLEPAY = 'googlepay'
IDEAL = 'ideal'
KAKAOPAY = 'kakaopay'
KLARNA = 'klarna'
KNET = 'knet'
MBWAY = 'mbway'
MOBILEPAY = 'mobilepay'
MULTIBANCO = 'multibanco'
PRZELEWY24 = 'p24'
P24 = 'p24'
PAYPAL = 'paypal'
SOFORT = 'sofort'
PLAID = 'plaid'
QPAY = 'qpay'
REMEMBER_ME = 'remember_me'
SEPA = 'sepa'
STCPAY = 'stcpay'
STORED_CARD = 'stored_card'
TABBY = 'tabby'
TAMARA = 'tamara'
TNG = 'tng'
TRUEMONEY = 'truemoney'
TWINT = 'twint'
VIPPS = 'vipps'


class Locale(str, Enum):
AR = 'ar'
DA_DK = 'da-DK'
DE_DE = 'de-DE'
EL = 'el'
EN_GB = 'en-GB'
ES_ES = 'es-ES'
FI_FI = 'fi-FI'
FIL_PH = 'fil-PH'
FR_FR = 'fr-FR'
HI_IN = 'hi-IN'
ID_ID = 'id-ID'
IT_IT = 'it-IT'
JA_JP = 'ja-JP'
KO_KR = 'ko-KR'
MS_MY = 'ms-MY'
NB_NO = 'nb-NO'
NL_NL = 'nl-NL'
PT_PT = 'pt-PT'
SV_SE = 'sv-SE'
TH_TH = 'th-TH'
VI_VN = 'vi-VN'
ZH_CN = 'zh-CN'
ZH_HK = 'zh-HK'
ZH_TW = 'zh-TW'


class StorePaymentDetails(str, Enum):
DISABLED = 'disabled'
ENABLED = 'enabled'
COLLECT_CONSENT = 'collect_consent'


class InstructionPurpose(str, Enum):
DONATIONS = 'donations'
EDUCATION = 'education'
EMERGENCY_NEED = 'emergency_need'
EXPATRIATION = 'expatriation'
FAMILY_SUPPORT = 'family_support'
FINANCIAL_SERVICES = 'financial_services'
GIFTS = 'gifts'
INCOME = 'income'
INSURANCE = 'insurance'
INVESTMENT = 'investment'
IT_SERVICES = 'it_services'
LEISURE = 'leisure'
LOAN_PAYMENT = 'loan_payment'
MEDICAL_TREATMENT = 'medical_treatment'
OTHER = 'other'
PENSION = 'pension'
ROYALTIES = 'royalties'
SAVINGS = 'savings'
TRAVEL_AND_TOURISM = 'travel_and_tourism'


class Instruction:
purpose: InstructionPurpose


class CustomerRetry:
max_attempts: int


class AccountHolderType(str, Enum):
INDIVIDUAL = 'individual'
CORPORATE = 'corporate'
GOVERNMENT = 'government'


class BillingAddress:
country: str
address_line1: str
address_line2: str
city: str
state: str
zip: str


class BillingPhone:
country_code: str
number: str


class SessionBilling:
address: BillingAddress
phone: BillingPhone


class AccountHolder:
type: AccountHolderType

class Billing:
address: Address
def __init__(self, type_p: AccountHolderType):
self.type = type_p


class Card:
class IndividualAccountHolder(AccountHolder):
first_name: str
last_name: str
middle_name: str
account_name_inquiry: bool

def __init__(self):
super().__init__(AccountHolderType.INDIVIDUAL)


class CorporateAccountHolder(AccountHolder):
company_name: str
account_name_inquiry: bool

def __init__(self):
super().__init__(AccountHolderType.CORPORATE)


class ApplePayConfiguration:
store_payment_details: StorePaymentDetails
account_holder: AccountHolder


class CardConfiguration:
store_payment_details: StorePaymentDetails
account_holder: AccountHolder


class PaymentMethodConfiguration:
card: Card
class GooglePayConfiguration:
store_payment_details: StorePaymentDetails
account_holder: AccountHolder


class StoredCardConfiguration:
customer_id: str
instrument_ids: list # list of strings
default_instrument_id: str


class SessionPaymentMethodConfiguration:
applepay: ApplePayConfiguration
card: CardConfiguration
googlepay: GooglePayConfiguration
stored_card: StoredCardConfiguration


class Item:
name: str
quantity: int
unit_price: int
reference: str
commodity_code: str
unit_of_measure: str
total_amount: int
tax_amount: int
discount_amount: int
url: str
image_url: str


class PaymentSessionsRequest:
amount: int
currency: Currency
billing: SessionBilling
success_url: str
failure_url: str
payment_type: PaymentType
billing: BillingInformation
billing_descriptor: BillingDescriptor
reference: str
description: str
customer: PaymentCustomerRequest
customer: CustomerRequest
shipping: ShippingDetails
recipient: PaymentRecipient
processing: ProcessingSettings
instruction: Instruction
processing_channel_id: str
payment_method_configuration: SessionPaymentMethodConfiguration
items: list # Item
amount_allocations: list # AmountAllocations
risk: RiskRequest
display_name: str
metadata: dict
locale: str
three_ds: ThreeDsRequest
sender: PaymentSender
capture: bool
capture_on: datetime
expires_on: datetime
payment_method_configuration: PaymentMethodConfiguration
enabled_payment_methods: list # PaymentMethodsType
disabled_payment_methods: list # PaymentMethodsType
items: list # payments.Product
amount_allocations: list # values of AmountAllocations
risk: RiskRequest
customer_retry: PaymentRetryRequest
display_name: str
customer_retry: CustomerRetry
ip_address: str


class PaymentSessionWithPaymentRequest:
session_data: str
amount: int
currency: Currency
billing: SessionBilling
success_url: str
failure_url: str
payment_type: PaymentType
billing_descriptor: BillingDescriptor
reference: str
description: str
customer: PaymentCustomerRequest
shipping: ShippingDetails
recipient: PaymentRecipient
processing: ProcessingSettings
instruction: Instruction
processing_channel_id: str
payment_method_configuration: SessionPaymentMethodConfiguration
items: list # Item
amount_allocations: list # AmountAllocations
risk: RiskRequest
display_name: str
metadata: dict
locale: str
three_ds: ThreeDsRequest
sender: PaymentSender
capture: bool
capture_on: datetime


class SubmitPaymentSessionRequest:
session_data: str
amount: int
reference: str
items: list # Item
three_ds: ThreeDsRequest
ip_address: str
Loading