Skip to content

Commit

Permalink
Update Payment Context And Properties
Browse files Browse the repository at this point in the history
- Update payment request for payment contexts
- Update giropay source
- Update properties and tests
  • Loading branch information
armando-rodriguez-cko committed Feb 8, 2024
1 parent 31bef0f commit 1342ae9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 2 additions & 0 deletions checkout_sdk/payments/payment_apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self):


class RequestGiropaySource(PaymentRequestSource):
account_holder: AccountHolder

def __init__(self):
super().__init__(PaymentSourceType.GIROPAY)

Expand Down
15 changes: 15 additions & 0 deletions checkout_sdk/payments/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,21 @@ class PaymentCustomerRequest(CustomerRequest):
tax_number: str


class PaymentSegment:
brand: str
business_category: str
market: str


class PaymentRetryRequest:
enabled: bool
max_attempts: int
end_after_days: int


# Request Payment
class PaymentRequest:
payment_context_id: str
source: PaymentRequestSource
amount: int
currency: Currency
Expand All @@ -441,6 +454,7 @@ class PaymentRequest:
customer: PaymentCustomerRequest
billing_descriptor: BillingDescriptor
shipping: ShippingDetails
segment: PaymentSegment
three_ds: ThreeDsRequest
processing_channel_id: str
previous_payment_id: str
Expand All @@ -456,6 +470,7 @@ class PaymentRequest:
processing: ProcessingSettings
metadata: dict
items: list # payments.Product
retry: PaymentRetryRequest


# Payout Request Source
Expand Down
2 changes: 2 additions & 0 deletions tests/checkout_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
NAME = 'Integration Test'
FIRST_NAME = 'Integration'
LAST_NAME = 'Test'
REFERENCE = 'Reference'
DESCRIPTION = 'Description'
SUCCESS_URL = 'https://testing.checkout.com/sucess'
FAILURE_URL = 'https://testing.checkout.com/failure'
PAYEE_NOT_ONBOARDED = 'payee_not_onboarded'
Expand Down
34 changes: 31 additions & 3 deletions tests/payments/request_apm_payments_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
PaymentRequestWeChatPaySource, RequestAlipayPlusSource, RequestP24Source, RequestKnetSource, \
RequestBancontactSource, RequestMultiBancoSource, RequestPostFinanceSource, RequestStcPaySource, RequestAlmaSource, \
RequestKlarnaSource, RequestFawrySource, RequestTrustlySource, RequestCvConnectSource, RequestIllicadoSource, \
RequestSepaSource
from checkout_sdk.payments.payments import PaymentRequest, ProcessingSettings, FawryProduct, PaymentCustomerRequest
RequestSepaSource, RequestGiropaySource
from checkout_sdk.payments.payments import PaymentRequest, ProcessingSettings, FawryProduct, PaymentCustomerRequest, \
ShippingDetails
from checkout_sdk.payments.payments_apm_previous import RequestSofortSource
from tests.checkout_test_utils import assert_response, SUCCESS_URL, FAILURE_URL, retriable, address, FIRST_NAME, \
LAST_NAME, phone, check_error_item, PAYEE_NOT_ONBOARDED, APM_SERVICE_UNAVAILABLE, random_email, new_uuid, \
account_holder
account_holder, REFERENCE, DESCRIPTION


def test_should_request_ideal_payment(default_api):
Expand Down Expand Up @@ -175,6 +176,33 @@ def test_should_request_we_chat_pay_payment(default_api):
payment_request=payment_request)


def test_should_request_giropay_payment(default_api):
aholder = AccountHolder()
aholder.first_name = FIRST_NAME
aholder.last_name = LAST_NAME

source = RequestGiropaySource()
source.account_holder = aholder

shipping = ShippingDetails()
shipping.address = address()
shipping.phone = phone()

payment_request = PaymentRequest()
payment_request.source = source
payment_request.amount = 100
payment_request.currency = Currency.EUR
payment_request.reference = REFERENCE
payment_request.description = DESCRIPTION
payment_request.shipping = shipping
payment_request.success_url = SUCCESS_URL
payment_request.failure_url = FAILURE_URL

check_error_item(callback=default_api.payments.request_payment,
error_item=PAYEE_NOT_ONBOARDED,
payment_request=payment_request)


def test_should_request_alipay_plus_payment(default_api):
source = RequestAlipayPlusSource.request_alipay_plus_cn_source()

Expand Down

0 comments on commit 1342ae9

Please sign in to comment.