{"id":25676409,"url":"https://github.com/checkout/checkout-sdk-python","last_synced_at":"2025-04-22T23:48:11.536Z","repository":{"id":32717467,"uuid":"138142178","full_name":"checkout/checkout-sdk-python","owner":"checkout","description":"Checkout.com SDK for Python","archived":false,"fork":false,"pushed_at":"2025-04-16T09:34:09.000Z","size":570,"stargazers_count":18,"open_issues_count":4,"forks_count":25,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-16T09:49:11.909Z","etag":null,"topics":["api-client","payment","payment-gateway","payment-processing","python","sdk"],"latest_commit_sha":null,"homepage":"https://checkout.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/checkout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-21T08:30:08.000Z","updated_at":"2025-04-16T09:03:47.000Z","dependencies_parsed_at":"2024-04-29T10:46:01.219Z","dependency_job_id":"cfdcd714-8429-4cf4-b18f-55f48b81cbde","html_url":"https://github.com/checkout/checkout-sdk-python","commit_stats":{"total_commits":229,"total_committers":12,"mean_commits":"19.083333333333332","dds":0.5021834061135371,"last_synced_commit":"d273ada0f6f7d5d88567b4f144773756cad6d39d"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/checkout","download_url":"https://codeload.github.com/checkout/checkout-sdk-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343907,"owners_count":21415036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","payment","payment-gateway","payment-processing","python","sdk"],"created_at":"2025-02-24T14:26:30.105Z","updated_at":"2025-04-22T23:48:11.508Z","avatar_url":"https://github.com/checkout.png","language":"Python","readme":"# Checkout.com Python SDK\n\n[![build-status](https://github.com/checkout/checkout-sdk-python/workflows/build-main/badge.svg)](https://github.com/checkout/checkout-sdk-python/actions/workflows/build-main.yml)\n![CodeQL](https://github.com/checkout/checkout-sdk-python/workflows/CodeQL/badge.svg)\n\n[![build-status](https://github.com/checkout/checkout-sdk-python/workflows/build-release/badge.svg)](https://github.com/checkout/checkout-sdk-python/actions/workflows/build-release.yml)\n[![GitHub release](https://img.shields.io/github/release/checkout/checkout-sdk-python.svg)](https://GitHub.com/checkout/checkout-sdk-php/releases/)\n[![PyPI - latest](https://img.shields.io/pypi/v/checkout-sdk?label=latest\u0026logo=pypi)](https://pypi.org/project/checkout-sdk)\n\n[![GitHub license](https://img.shields.io/github/license/checkout/checkout-sdk-python.svg)](https://github.com/checkout/checkout-sdk-python/blob/main/LICENSE.md)\n\n## Getting started\n\n```\n# Requires Python \u003e 3.6\npip install checkout-sdk==\u003cversion\u003e\n```\n\n\u003e **Version 3.0.0 is here!**\n\u003e  \u003cbr/\u003e\u003cbr/\u003e\n\u003e We improved the initialization of SDK making it easier to understand the available options. \u003cbr/\u003e\n\u003e Now `NAS` accounts are the default instance for the SDK and `ABC` structure was moved to a `previous` prefixes. \u003cbr/\u003e\n\u003e If you have been using this SDK before, you may find the following important changes:\n\u003e * Imports: if you used to import `checkout_sdk.payments.payments` now use `checkout_sdk.payments.payments_previous`\n\u003e * Marketplace module was moved to Accounts module, same for classes and references.\n\u003e * In most cases, IDE can help you determine from where to import, but if you’re still having issues don't hesitate to open a [ticket](https://github.com/checkout/checkout-sdk-python/issues/new/choose).\n\n\n### :rocket: Please check in [GitHub releases](https://github.com/checkout/checkout-sdk-python/releases) for all the versions available.\n\n### :book: Checkout our official documentation.\n\n* [Official Docs (Default)](https://docs.checkout.com/)\n* [Official Docs (Previous)](https://docs.checkout.com/previous)\n\n### :books: Check out our official API documentation guide, where you can also find more usage examples.\n\n* [API Reference (Default)](https://api-reference.checkout.com/)\n* [API Reference (Previous)](https://api-reference.checkout.com/previous)\n\n## How to use the SDK\n\nThis SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply\nusing specific API features. Please find in the table below the types of keys that can be used within this SDK.\n\n| Account System | Public Key (example)                    | Secret Key (example)                    |\n|----------------|-----------------------------------------|-----------------------------------------|\n| Default        | pk_nruiensgius784thg489hio3481          | sk_nguierhg984hg4nig489gh48931          |\n| Previous       | pk_gdf78gdg-rf56-3fgr-34rf-5435g456gg6y | sk_hg5643g6-4r5t-gt67-ht6t-5467567g6f56 |\n\nNote: sandbox keys have a `sbox_` or `test_` identifier, for Default and Previous accounts respectively.\n\nIf you don't have your own API keys, you can sign up for a test\naccount [here](https://www.checkout.com/get-test-account).\n\n**PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.**\n\n### Default\n\nDefault keys client instantiation can be done as follows:\n\n```python\nfrom checkout_sdk.checkout_sdk import CheckoutSdk\nfrom checkout_sdk.environment import Environment\n\n\ndef default():\n    # public key is optional, only required for operations related with tokens\n    checkout_api = CheckoutSdk\n        .builder()\n        .secret_key('secret_key')\n        .public_key('public_key') # optional, only required for operations related with tokens\n        .environment(Environment.sandbox()) # or production()\n        .environment_subdomain(\"subdomain\") # optional, Merchant-specific DNS name\n        .build()\n\n    payments_client = checkout_api.payments\n    payments_client.refund_payment('payment_id')\n```\n\n### Default OAuth\n\nThe SDK supports client credentials OAuth, when initialized as follows:\n\n```python\nfrom checkout_sdk.checkout_sdk import CheckoutSdk\nfrom checkout_sdk.environment import Environment\nfrom checkout_sdk.oauth_scopes import OAuthScopes\n\n\ndef oauth():\n    checkout_api = CheckoutSdk\n        .builder()\n        .oauth()\n        .client_credentials(client_id='client_id', client_secret='client_secret')\n        .environment(Environment.sandbox()) # or production()\n        .environment_subdomain(\"subdomain\") # optional, Merchant-specific DNS name\n        .scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes\n        .build()\n\n    payments_client = checkout_api.payments\n    payments_client.refund_payment('payment_id')\n```\n\n### Previous\n\nIf your pair of keys matches the Previous type, this is how the SDK should be used:\n\n```python\nfrom checkout_sdk.checkout_sdk import CheckoutSdk\nfrom checkout_sdk.environment import Environment\n\ndef previous():\n    # public key is optional, only required for operations related with tokens\n    checkout_api = CheckoutSdk\n        .builder()\n        .previous()\n        .secret_key('secret_key')\n        .public_key('public_key') # optional, only required for operations related with tokens\n        .environment(Environment.sandbox()) # or production()\n        .environment_subdomain(\"subdomain\") # optional, Merchant-specific DNS name\n        .build()\n\n    payments_client = checkout_api.payments\n    payments_client.refund_payment('payment_id')\n```\n\n## Logging\n\nCheckout SDK custom logger can be enabled and configured through Python's logging module:\n\n```python\nimport logging\nlogging.basicConfig()\nlogging.getLogger('checkout').setLevel(logging.INFO)\n```\n\n## HttpClient\n\nCheckout SDK uses `requests` library to perform http operations, and you can provide your own custom http client implementing `HttpClientBuilderInterface`\n\n```python\nimport requests\nfrom requests import Session\n\nimport checkout_sdk\nfrom checkout_sdk.checkout_sdk import CheckoutSdk\nfrom checkout_sdk.environment import Environment\nfrom checkout_sdk.oauth_scopes import OAuthScopes\nfrom checkout_sdk.http_client_interface import HttpClientBuilderInterface\n\n\nclass CustomHttpClientBuilder(HttpClientBuilderInterface):\n\n    def get_client(self) -\u003e Session:\n        session = requests.Session()\n        session.max_redirects = 5\n        return session\n\n\ndef oauth():\n    checkout_api = CheckoutSdk\n        .builder()\n        .oauth()\n        .client_credentials(client_id='client_id', client_secret='client_secret')\n        .environment(Environment.sandbox()) # or production()\n        .environment_subdomain(\"subdomain\") # optional, Merchant-specific DNS name\n        .http_client_builder(CustomHttpClientBuilder()) # optional\n        .scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes\n        .build()\n\n    payments_client = checkout_api.payments\n    payments_client.refund_payment('payment_id')\n```\n\n## Exception handling\n\nAll the API responses that do not fall in the 2** status codes will cause a `CheckoutApiException`. The exception encapsulates\nthe `http_metadata` and a dictionary of `error_details`, if available.\n\n```python\ntry:\n    checkout_api.customers.get(\"customer_id\")\nexcept CheckoutApiException as err:\n    http_status_code = err.http_metadata.status_code\n    error_details = err.error_details\n```\n\n## Building from source\n\nOnce you checkout the code from GitHub, the project can be built using `pip`:\n\n```\n# install the latest version pip\npython -m pip install --upgrade pip\n\n# install project dependencies\npip install -r requirements-dev.txt\n\n# run unit and integration tests\npython -m pytest\n```\n\nThe execution of integration tests require the following environment variables set in your system:\n\n* For Default account systems: `CHECKOUT_DEFAULT_PUBLIC_KEY` \u0026 `CHECKOUT_DEFAULT_SECRET_KEY`\n* For OAuth account systems: `CHECKOUT_DEFAULT_OAUTH_CLIENT_ID` \u0026 `CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET`\n* For Previous account systems: `CHECKOUT_PREVIOUS_PUBLIC_KEY` \u0026 `CHECKOUT_PREVIOUS_SECRET_KEY`\n\n## Code of Conduct\n\nPlease refer to [Code of Conduct](CODE_OF_CONDUCT.md)\n\n## Licensing\n\n[MIT](LICENSE.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheckout%2Fcheckout-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-sdk-python/lists"}