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
4 changes: 4 additions & 0 deletions checkout_sdk/accounts/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ class EntityFileRequest:
purpose: FilePurpose


class EntityRequirementUpdateRequest:
value: object


class EtagHeader:
etag: str

Expand Down
21 changes: 20 additions & 1 deletion checkout_sdk/accounts/accounts_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from checkout_sdk.accounts.accounts import (
EtagHeader, OnboardEntityRequest, UpdateScheduleRequest, AccountsPaymentInstrument,
PaymentInstrumentRequest, PaymentInstrumentsQuery, UpdatePaymentInstrumentRequest,
ReserveRuleRequest, EntityFileRequest
ReserveRuleRequest, EntityFileRequest, EntityRequirementUpdateRequest
)
from checkout_sdk.api_client import ApiClient
from checkout_sdk.authorization_type import AuthorizationType
Expand All @@ -24,6 +24,7 @@ class AccountsClient(Client):
__PAYMENT_INSTRUMENTS_PATH = 'payment-instruments'
__MEMBERS_PATH = 'members'
__RESERVE_RULES_PATH = 'reserve-rules'
__REQUIREMENTS_PATH = 'requirements'

def __init__(self, api_client: ApiClient,
files_client: ApiClient,
Expand Down Expand Up @@ -148,6 +149,24 @@ def update_reserve_rule(self, entity_id: str, reserve_rule_id: str, etag: str, u
entity_id, self.__RESERVE_RULES_PATH, reserve_rule_id)
return self._api_client.put(path, self._sdk_authorization(), update_request, headers=headers)

def get_entity_requirements(self, entity_id: str):
return self._api_client.get(
self.build_path(self.__ACCOUNTS_PATH, self.__ENTITIES_PATH, entity_id, self.__REQUIREMENTS_PATH),
self._sdk_authorization())

def get_entity_requirement_details(self, entity_id: str, requirement_id: str):
return self._api_client.get(
self.build_path(self.__ACCOUNTS_PATH, self.__ENTITIES_PATH, entity_id,
self.__REQUIREMENTS_PATH, requirement_id),
self._sdk_authorization())

def resolve_entity_requirement(self, entity_id: str, requirement_id: str,
request: EntityRequirementUpdateRequest):
return self._api_client.put(
self.build_path(self.__ACCOUNTS_PATH, self.__ENTITIES_PATH, entity_id,
self.__REQUIREMENTS_PATH, requirement_id),
self._sdk_authorization(), request)

def upload_entity_file(self, entity_id: str, entity_file_request: EntityFileRequest):
return self.__files_client.post(
self.build_path(self.__ENTITIES_PATH, entity_id, self.__FILES_PATH),
Expand Down
3 changes: 3 additions & 0 deletions checkout_sdk/checkout_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from checkout_sdk.identities.applicants.applicants_client import ApplicantsClient
from checkout_sdk.identities.identityverification.identityverification_client import IdentityVerificationClient
from checkout_sdk.networktokens.network_tokens_client import NetworkTokensClient
from checkout_sdk.onboardingsimulator.onboarding_simulator_client import OnboardingSimulatorClient
from checkout_sdk.paymentmethods.payment_methods_client import PaymentMethodsClient


Expand Down Expand Up @@ -115,3 +116,5 @@ def __init__(self, configuration: CheckoutConfiguration):
configuration=configuration)
self.network_tokens = NetworkTokensClient(api_client=base_api_client, configuration=configuration)
self.payment_methods = PaymentMethodsClient(api_client=base_api_client, configuration=configuration)
self.onboarding_simulator = OnboardingSimulatorClient(api_client=base_api_client,
configuration=configuration)
11 changes: 8 additions & 3 deletions checkout_sdk/instruments/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,19 @@ def __init__(self):
super().__init__(InstrumentType.BANK_ACCOUNT)


class ProvisionNetworkToken:
provision: bool


class CreateCardInstrumentRequest(CreateInstrumentRequest):
number: str
expiry_month: int
expiry_year: int
network_token: str
processing_channel_id: str
entity_id: str
account_holder: AccountHolder
customer: CreateCustomerInstrumentRequest
entity_id: str
processing_channel_id: str
network_token: ProvisionNetworkToken

def __init__(self):
super().__init__(InstrumentType.CARD)
Expand Down
5 changes: 5 additions & 0 deletions checkout_sdk/instruments/instruments_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def update(self, instrument_id: str, update_instrument_request: UpdateInstrument
def delete(self, instrument_id: str):
return self._api_client.delete(self.build_path(self.__INSTRUMENTS, instrument_id), self._sdk_authorization())

def revoke(self, instrument_id: str):
return self._api_client.patch(
self.build_path(self.__INSTRUMENTS, instrument_id, 'revoke'),
self._sdk_authorization())

def get_bank_account_field_formatting(self, country: Country, currency: Currency,
bank_account_field_query: BankAccountFieldQuery):
return self._api_client.get(self.build_path(self.__BANK_VALIDATION_PATH, country, currency),
Expand Down
8 changes: 6 additions & 2 deletions checkout_sdk/oauth_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def get_access_token(self):
auth=(self.__client_id, self.__client_secret))
response.raise_for_status()
except HTTPError as err:
errors = json.loads(err.response.text)
message = 'OAuth client_credentials authentication failed with error: ({})'.format(errors['error'])
try:
errors = json.loads(err.response.text)
message = 'OAuth client_credentials authentication failed with error: ({})'.format(errors['error'])
except (json.JSONDecodeError, KeyError):
message = 'OAuth client_credentials authentication failed with status: ({})'.format(
err.response.status_code)
raise CheckoutAuthorizationException(message) from err
except ConnectionError as err:
raise CheckoutAuthorizationException(
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions checkout_sdk/onboardingsimulator/onboarding_simulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import absolute_import

from enum import Enum


class SimulatorEntityStatus(str, Enum):
DRAFT = 'draft'
REQUIREMENTS_DUE = 'requirements_due'
PENDING = 'pending'
ACTIVE = 'active'
RESTRICTED = 'restricted'
REJECTED = 'rejected'
INACTIVE = 'inactive'


class SimulatorSetRequirementsDueRequest:
fields: list # list of str


class SimulatorSetStatusRequest:
status: SimulatorEntityStatus
51 changes: 51 additions & 0 deletions checkout_sdk/onboardingsimulator/onboarding_simulator_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from __future__ import absolute_import

from checkout_sdk.api_client import ApiClient
from checkout_sdk.authorization_type import AuthorizationType
from checkout_sdk.checkout_configuration import CheckoutConfiguration
from checkout_sdk.client import Client
from checkout_sdk.onboardingsimulator.onboarding_simulator import (
SimulatorSetRequirementsDueRequest,
SimulatorSetStatusRequest
)


class OnboardingSimulatorClient(Client):
__SIMULATE_PATH = 'simulate'
__ENTITIES_PATH = 'entities'
__REQUIREMENTS_DUE_PATH = 'requirements-due'
__SCENARIOS_PATH = 'scenarios'
__STATUS_PATH = 'status'

def __init__(self, api_client: ApiClient, configuration: CheckoutConfiguration):
super().__init__(api_client=api_client,
configuration=configuration,
authorization_type=AuthorizationType.OAUTH)

def set_requirements_due(self, entity_id: str, request: SimulatorSetRequirementsDueRequest):
return self._api_client.post(
self.build_path(self.__SIMULATE_PATH, self.__ENTITIES_PATH, entity_id,
self.__REQUIREMENTS_DUE_PATH),
self._sdk_authorization(), request)

def run_scenario(self, entity_id: str, scenario_id: str):
return self._api_client.post(
self.build_path(self.__SIMULATE_PATH, self.__ENTITIES_PATH, entity_id,
self.__SCENARIOS_PATH, scenario_id),
self._sdk_authorization())

def set_entity_status(self, entity_id: str, request: SimulatorSetStatusRequest):
return self._api_client.post(
self.build_path(self.__SIMULATE_PATH, self.__ENTITIES_PATH, entity_id,
self.__STATUS_PATH),
self._sdk_authorization(), request)

def list_available_requirements(self):
return self._api_client.get(
self.build_path(self.__SIMULATE_PATH, self.__REQUIREMENTS_DUE_PATH),
self._sdk_authorization())

def list_scenarios(self):
return self._api_client.get(
self.build_path(self.__SIMULATE_PATH, self.__SCENARIOS_PATH),
self._sdk_authorization())
7 changes: 6 additions & 1 deletion checkout_sdk/payments/sessions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,16 @@ class PaymentSessionWithPaymentRequest:
capture_on: datetime


class PaymentInterfacesProcessingBase:
pan_preference: str
provision_network_token: bool


class SubmitPaymentSessionRequest:
session_data: str
amount: int
currency: Currency
reference: str
description: str
items: list # Item
three_ds: ThreeDsRequest
ip_address: str
Expand All @@ -308,3 +312,4 @@ class SubmitPaymentSessionRequest:
sender: PaymentSender
shipping: ShippingDetails
success_url: str
processing: PaymentInterfacesProcessingBase
Loading
Loading