Skip to content

Commit

Permalink
Added amount allocations and marked marketplace as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ibarra committed Sep 16, 2022
1 parent 228ef8e commit 5c24f3a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
12 changes: 12 additions & 0 deletions checkout_sdk/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ class Product:
name: str
quantity: int
price: int


class Commission:
amount: int
percentage: float


class AmountAllocations:
id: str
amount: int
reference: str
commission: Commission
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,9 +3,9 @@
from checkout_sdk.common.common import CustomerRequest
from checkout_sdk.common.common import MarketplaceData
from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments_previous import BillingInformation
from checkout_sdk.payments.payments import BillingDescriptor, PaymentType, ShippingDetails, ThreeDsRequest, \
RiskRequest, PaymentRecipient, ProcessingSettings
from checkout_sdk.payments.payments_previous import BillingInformation


class HostedPaymentsSessionRequest:
Expand Down Expand Up @@ -34,4 +34,6 @@ class HostedPaymentsSessionRequest:
capture_on: datetime
# Not available on Previous
processing_channel_id: str
# @deprecated marketplace property will be removed in the future, and should be used amount_allocations instead
marketplace: MarketplaceData
amount_allocations: list # values of AmountAllocations
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,9 +3,9 @@
from checkout_sdk.common.common import CustomerRequest
from checkout_sdk.common.common import MarketplaceData
from checkout_sdk.common.enums import Currency
from checkout_sdk.payments.payments_previous import BillingInformation
from checkout_sdk.payments.payments import BillingDescriptor, PaymentType, ShippingDetails, ThreeDsRequest, \
RiskRequest, PaymentRecipient, ProcessingSettings
from checkout_sdk.payments.payments_previous import BillingInformation


class PaymentLinkRequest:
Expand All @@ -32,4 +32,6 @@ class PaymentLinkRequest:
capture: bool
capture_on: datetime
processing_channel_id: str
# @deprecated marketplace property will be removed in the future, and should be used amount_allocations instead
marketplace: MarketplaceData
amount_allocations: list # values of AmountAllocations
4 changes: 4 additions & 0 deletions checkout_sdk/payments/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ class PaymentRequest:
payment_ip: str
sender: PaymentSender
recipient: PaymentRecipient
# @deprecated marketplace property will be removed in the future, and should be used amount_allocations instead
marketplace: MarketplaceData
amount_allocations: list # values of AmountAllocations
processing: ProcessingSettings
metadata: dict
items: list # payments.Product
Expand Down Expand Up @@ -450,7 +452,9 @@ class CaptureRequest:
billing_descriptor: BillingDescriptor
shipping: ShippingDetails
items: list # payments.Product
# @deprecated marketplace property will be removed in the future, and should be used amount_allocations instead
marketplace: MarketplaceData
amount_allocations: list # values of AmountAllocations
processing: ProcessingSettings
metadata: dict

Expand Down
27 changes: 15 additions & 12 deletions tests/payments/links/payments_links_integration_test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
from __future__ import absolute_import

import pytest

from checkout_sdk.common.common import CustomerRequest, Product
from checkout_sdk.common.common import CustomerRequest, Product, Commission, AmountAllocations
from checkout_sdk.common.enums import Currency, PaymentSourceType
from checkout_sdk.payments.links.payments_links import PaymentLinkRequest
from checkout_sdk.payments.payments_previous import BillingInformation
from checkout_sdk.payments.payments import ShippingDetails, ThreeDsRequest, RiskRequest, PaymentRecipient, \
ProcessingSettings
from tests.checkout_test_utils import assert_response, phone, address, random_email
from checkout_sdk.payments.payments_previous import BillingInformation
from tests.checkout_test_utils import assert_response, phone, address, random_email, new_uuid


@pytest.mark.skip(reason='not available')
def test_should_create_and_get_payment_link(default_api):
commission = Commission()
commission.amount = 1
commission.percentage = 0.1

amount_allocations = AmountAllocations()
amount_allocations.id = 'ent_sdioy6bajpzxyl3utftdp7legq'
amount_allocations.reference = new_uuid()
amount_allocations.commission = commission
amount_allocations.amount = 100

request = create_payment_link_request()
request.amount_allocations = [amount_allocations]

response = default_api.payments_links.create_payment_link(request)

Expand All @@ -22,22 +30,17 @@ def test_should_create_and_get_payment_link(default_api):
'id',
'reference',
'expires_on',
'_links',
'_links.self',
'_links.redirect',
'warnings')

for warning in response.warnings:
assert_response(warning,
'http_metadata',
'code',
'value',
'description')

hosted_details = default_api.payments_links.get_payment_link(response.id)

assert_response(hosted_details,
'http_metadata',
'id',
'reference',
'status',
Expand All @@ -52,7 +55,7 @@ def test_should_create_and_get_payment_link(default_api):
'products',
'_links',
'_links.self',
'_links.redirect', )
'_links.redirect')


def create_payment_link_request():
Expand Down

0 comments on commit 5c24f3a

Please sign in to comment.