Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Error Type to Checkout API Exception #123

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
2 changes: 2 additions & 0 deletions checkout_sdk/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ def invalid_key(key_type: AuthorizationType):
class CheckoutApiException(CheckoutException):
http_metadata: dict
error_details: dict
error_type: str

def __init__(self, response):
self.http_metadata = map_to_http_metadata(response)
if response.text:
payload = response.json()
self.error_details = payload['error_codes'] if 'error_codes' in payload else None
self.error_type = payload['error_type'] if 'error_type' in payload else None
super().__init__('The API response status code ({}) does not indicate success.'
.format(response.status_code))
27 changes: 0 additions & 27 deletions tests/transfers/transfers_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,6 @@
from tests.checkout_test_utils import assert_response, new_idempotency_key


def test_should_initiate_and_get_transfer_of_funds(oauth_api):
transfer_source = TransferSource()
transfer_source.id = 'ent_kidtcgc3ge5unf4a5i6enhnr5m'
transfer_source.amount = 100

transfer_destination = TransferDestination()
transfer_destination.id = 'ent_w4jelhppmfiufdnatam37wrfc4'

transfer_request = CreateTransferRequest()
transfer_request.transfer_type = TransferType.COMMISSION
transfer_request.source = transfer_source
transfer_request.destination = transfer_destination

response = oauth_api.transfers.initiate_transfer_of_funds(transfer_request)
assert_response(response, 'id', 'status')
assert 'pending' == response.status

transfer_response = oauth_api.transfers.retrieve_a_transfer(response.id)

assert_response(transfer_response, "id",
'source',
'destination',
'status',
'requested_on',
'transfer_type')


def test_should_initiate_transfer_of_funds_idempotently(oauth_api):
transfer_source = TransferSource()
transfer_source.id = 'ent_kidtcgc3ge5unf4a5i6enhnr5m'
Expand Down