{"id":21302333,"url":"https://github.com/pfpayments/python-sdk","last_synced_at":"2025-07-11T20:31:42.347Z","repository":{"id":37977821,"uuid":"251532627","full_name":"pfpayments/python-sdk","owner":"pfpayments","description":"The python SDK allows an easy integration of PostFinance Checkout into python applications.","archived":false,"fork":false,"pushed_at":"2024-04-08T10:10:30.000Z","size":802,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T08:41:57.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfpayments.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-03-31T07:38:00.000Z","updated_at":"2024-07-04T12:53:36.000Z","dependencies_parsed_at":"2024-01-11T11:04:22.153Z","dependency_job_id":null,"html_url":"https://github.com/pfpayments/python-sdk","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/pfpayments/python-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fpython-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fpython-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fpython-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fpython-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfpayments","download_url":"https://codeload.github.com/pfpayments/python-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fpython-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892320,"owners_count":23679270,"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":[],"created_at":"2024-11-21T15:55:48.471Z","updated_at":"2025-07-11T20:31:40.601Z","avatar_url":"https://github.com/pfpayments.png","language":"Python","readme":"[![Build Status](https://travis-ci.org/pfpayments/python-sdk.svg?branch=master)](https://travis-ci.org/pfpayments/python-sdk)\n\n# PostFinance Checkout Python SDK\n\nPython SDK to access PostFinance Checkout web services API.\n\nLibrary facilitates your interaction with various services such as transactions, accounts, and subscriptions.\n\n## API documentation\n\n[PostFinance Checkout Web Service API](https://checkout.postfinance.ch/doc/api/web-service)\n\n## Requirements\n\n- Python 3.7+\n\n## Installation\n\n### pip3 install (recommended)\n```sh\npip3 install --upgrade postfinancecheckout\n```\n\n### pip3 install from source via GitHub\n\n```sh\npip3 install git+http://github.com/pfpayments/python-sdk.git\n```\n(you may need to run `pip3` with root permission: `sudo pip3 install git+http://github.com/pfpayments/python-sdk.git` )\n\n### install from source via Setuptools\n\nInstall via [Setuptools](http://pypi.python.org/pypi/setuptools).\n\n```sh\npip3 install setuptools\n\npython setup.py install\n```\n(or `sudo python setup.py install` to install the package for all users)\n\n## Usage\nThe library needs to be configured with your account's space id, user id, and secret key which are available in your [PostFinance Checkout\naccount dashboard](https://checkout.postfinance.ch/account/select). Set `space_id`, `user_id`, and `api_secret` to their values.\nYou can also optionally set `default_headers` to set some headers that will be sent to all requests\n\n### Configuring a Service\n\n```python\nfrom postfinancecheckout import Configuration\nfrom postfinancecheckout.api import TransactionServiceApi, TransactionPaymentPageServiceApi\n\nspace_id = 405\n\n# default_headers is an optional param, that represents headers sent to all requests\nconfig = Configuration(\n    user_id=512,\n    api_secret='FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=',\n    default_headers={'x-meta-custom-header': 'value-1', 'x-meta-custom-header-2': 'value-2'},\n    # set a custom request timeout if needed. (If not set, then the default value is: 25 seconds)\n    request_timeout = 30\n)\n\ntransaction_service = TransactionServiceApi(configuration=config)\ntransaction_payment_page_service = TransactionPaymentPageServiceApi(configuration=config)\n\n```\n\nTo get started with sending transactions, please review the example below:\n\n```python\nfrom postfinancecheckout import Configuration\nfrom postfinancecheckout.api import TransactionServiceApi, TransactionPaymentPageServiceApi\nfrom postfinancecheckout.models import LineItem, LineItemType, TransactionCreate\n\nspace_id = 405\n\nconfig = Configuration(\n    user_id=512,\n    api_secret='FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=',\n    # set a custom request timeout if needed. (If not set, then the default value is: 25 seconds)\n    request_timeout = 30\n)\n\ntransaction_service = TransactionServiceApi(configuration=config)\ntransaction_payment_page_service = TransactionPaymentPageServiceApi(configuration=config)\n\n# create line item\nline_item = LineItem(\n    name='Red T-Shirt',\n    unique_id='5412',\n    sku='red-t-shirt-123',\n    quantity=1,\n    amount_including_tax=29.95,\n    type=LineItemType.PRODUCT\n)\n\n# create transaction model\ntransaction = TransactionCreate(\n    line_items=[line_item],\n    auto_confirmation_enabled=True,\n    currency='EUR',\n)\n\ntransaction_create = transaction_service.create(space_id=space_id, transaction=transaction)\npayment_page_url = transaction_payment_page_service.payment_page_url(space_id=space_id, id=transaction_create.id)\n# redirect your customer to this payment_page_url\n```\n\n### Integrating Webhook Payload Signing Mechanism into webhook callback handler\n\nThe HTTP request which is sent for a state change of an entity now includes an additional field `state`, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.\n\nPayload field `state` provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.\n\n#### ⚠️ Warning: Generic Pseudocode\n\n\u003e **The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.**\n\u003e\n\u003e Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling.\nFor a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive\n[Webhook Payload Signing Documentation](https://checkout.postfinance.ch/doc/webhooks#_webhook_payload_signing_mechanism).\n\n```python\n@app.route('/webhook/callback', methods=['POST'])\ndef handle_webhook():\n    request_payload = request.data.decode('utf-8')\n    signature = request.headers.get('x-signature')\n\n    if not signature:\n        # Make additional API call to retrieve the entity state\n        # ...\n    else:\n        if webhook_encryption_service().is_content_valid(signature_header=signature, content_to_verify=request_payload):\n            # Parse request_payload to extract 'state' value\n            # Process entity's state change\n            # ...\n\n    # Process the received webhook data\n    # ...\n\n```\n\n## License\n\nPlease see the [license file](https://github.com/pfpayments/python-sdk/blob/master/LICENSE) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfpayments%2Fpython-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfpayments%2Fpython-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfpayments%2Fpython-sdk/lists"}