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: 3 additions & 1 deletion checkout_sdk/oauth_access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

class OAuthAccessToken:
token: str
token_type: str
expiration_date: datetime

def __init__(self, token: str, expiration_date: datetime):
def __init__(self, token: str, token_type: str, expiration_date: datetime):
self.token = token
self.token_type = token_type
self.expiration_date = expiration_date

def is_valid(self):
Expand Down
3 changes: 3 additions & 0 deletions checkout_sdk/oauth_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def get_access_token(self):

data = {
'grant_type': 'client_credentials',
'client_id': self.__client_id,
'client_secret': self.__client_secret,
'scope': str.join(' ', self.__scopes)
}

Expand All @@ -84,6 +86,7 @@ def get_access_token(self):

response_json = response.json()
self.__access_token = OAuthAccessToken(token=response_json['access_token'],
token_type=response_json['token_type'],
expiration_date=datetime.now() + timedelta(
seconds=response_json['expires_in']))
return self.__access_token
2 changes: 1 addition & 1 deletion checkout_sdk/payments/contexts/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PaymentContextsProcessing:
locale: str
shipping_preference: ShippingPreference
user_action: UserAction
partner_customer_risk_data: PaymentContextsPartnerCustomerRiskData
partner_customer_risk_data: list # payment.contexts.PaymentContextsPartnerCustomerRiskData
airline_data: list # payment.contexts.PaymentContextsAirlineData


Expand Down
3 changes: 3 additions & 0 deletions checkout_sdk/transfers/transfers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from enum import Enum

from checkout_sdk.common.enums import Currency


class TransferType(str, Enum):
COMMISSION = 'commission'
Expand All @@ -10,6 +12,7 @@ class TransferType(str, Enum):
class TransferSource:
id: str
amount: int
currency: Currency


class TransferDestination:
Expand Down
2 changes: 1 addition & 1 deletion checkout_sdk/transfers/transfers_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, api_client: ApiClient,
configuration=configuration,
authorization_type=AuthorizationType.SECRET_KEY_OR_OAUTH)

def initiate_transfer_of_funds(self, create_transfer_request: CreateTransferRequest, idempotency_key: str = None):
def initiate_transfer_of_funds(self, create_transfer_request: CreateTransferRequest, idempotency_key: str):
return self._api_client.post(self.__TRANSFERS_PATH, self._sdk_authorization(), create_transfer_request,
idempotency_key)

Expand Down
1 change: 0 additions & 1 deletion tests/oauth_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def test_should_create_customer_with_oauth(oauth_api):

customer_response = oauth_api.customers.create(customer_request)
assert_response(customer_response, 'id')
return customer_response.id


def test_should_fail_init_authorization_invalid_credentials():
Expand Down
5 changes: 5 additions & 0 deletions tests/transfers/transfers_integration_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

from checkout_sdk.common.enums import Currency
from checkout_sdk.exception import CheckoutApiException
from checkout_sdk.transfers.transfers import CreateTransferRequest, TransferDestination, TransferSource, TransferType
from tests.checkout_test_utils import assert_response, new_idempotency_key
Expand All @@ -9,6 +10,7 @@ def test_should_initiate_transfer_of_funds_idempotently(oauth_api):
transfer_source = TransferSource()
transfer_source.id = 'ent_kidtcgc3ge5unf4a5i6enhnr5m'
transfer_source.amount = 100
transfer_source.currency = Currency.GBP

transfer_destination = TransferDestination()
transfer_destination.id = 'ent_w4jelhppmfiufdnatam37wrfc4'
Expand All @@ -23,6 +25,9 @@ def test_should_initiate_transfer_of_funds_idempotently(oauth_api):
response = oauth_api.transfers.initiate_transfer_of_funds(transfer_request, idempotency_key)
assert_response(response, 'id', 'status')

response2 = oauth_api.transfers.retrieve_a_transfer(response.id)
assert_response(response2, 'id', 'status', 'source', 'destination')

try:
oauth_api.transfers.initiate_transfer_of_funds(transfer_request, idempotency_key)
except CheckoutApiException as err:
Expand Down
Loading