{"id":17521725,"url":"https://github.com/pfpayments/php-sdk","last_synced_at":"2025-10-06T19:28:01.016Z","repository":{"id":32689627,"uuid":"139705131","full_name":"pfpayments/php-sdk","owner":"pfpayments","description":"PHP SDK for PostFinance Checkout","archived":false,"fork":false,"pushed_at":"2025-03-24T13:22:34.000Z","size":2644,"stargazers_count":22,"open_issues_count":6,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-03T00:51:24.641Z","etag":null,"topics":["composer","payment","payment-integration","php","php-sdk","postfinance","postfinance-checkout","postfinance-checkout-sdk"],"latest_commit_sha":null,"homepage":"https://www.postfinance-checkout.ch","language":"PHP","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-04T10:10:49.000Z","updated_at":"2025-03-24T13:22:38.000Z","dependencies_parsed_at":"2024-01-25T16:46:39.032Z","dependency_job_id":"80be72a8-d40d-42bb-bf52-4e7857589702","html_url":"https://github.com/pfpayments/php-sdk","commit_stats":{"total_commits":44,"total_committers":10,"mean_commits":4.4,"dds":0.75,"last_synced_commit":"278ee4dbb9765a7946e58bf89dc8125b8dd8113b"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/pfpayments/php-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fphp-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fphp-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fphp-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fphp-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfpayments","download_url":"https://codeload.github.com/pfpayments/php-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfpayments%2Fphp-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265616976,"owners_count":23798936,"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":["composer","payment","payment-integration","php","php-sdk","postfinance","postfinance-checkout","postfinance-checkout-sdk"],"created_at":"2024-10-20T12:06:27.310Z","updated_at":"2025-10-06T19:27:55.976Z","avatar_url":"https://github.com/pfpayments.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/pfpayments/php-sdk.svg?branch=master)](https://travis-ci.org/pfpayments/php-sdk)\n\n# PostFinance Checkout PHP Library\n\nThe PostFinance Checkout PHP library wraps around the PostFinance Checkout API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.\n\n\n## Documentation\n\n[PostFinance Checkout Web Service API](https://checkout.postfinance.ch/doc/api/web-service)\n\n## Requirements\n\n- PHP 5.6.0 and above\n\n## Installation\n\nYou can use **Composer** or **install manually**\n\n### Composer\n\nThe preferred method is via [composer](https://getcomposer.org). Follow the\n[installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have\ncomposer installed.\n\nOnce composer is installed, execute the following command in your project root to install this library:\n\n```sh\ncomposer require postfinancecheckout/sdk\n```\n\n### Manual Installation\n\nAlternatively you can download the package in its entirety. The [Releases](../../releases) page lists all stable versions.\n\nUncompress the zip file you download, and include the autoloader in your project:\n\n```php\nrequire_once '/path/to/php-sdk/autoload.php';\n```\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.\n\n### Configuring a Service\n\n```php\nrequire_once(__DIR__ . '/autoload.php');\n\n// Configuration\n$spaceId = 405;\n$userId = 512;\n$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';\n\n// Setup API client\n$client = new \\PostFinanceCheckout\\Sdk\\ApiClient($userId, $secret);\n\n// Get API service instance\n$client-\u003egetTransactionService();\n$client-\u003egetTransactionPaymentPageService();\n\n```\n\nTo get started with sending transactions, please review the example below:\n\n```php\nrequire_once(__DIR__ . '/autoload.php');\n\n// Configuration\n$spaceId = 405;\n$userId = 512;\n$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';\n\n// Setup API client\n$client = new \\PostFinanceCheckout\\Sdk\\ApiClient($userId, $secret);\n\n// Create transaction\n$lineItem = new \\PostFinanceCheckout\\Sdk\\Model\\LineItemCreate();\n$lineItem-\u003esetName('Red T-Shirt');\n$lineItem-\u003esetUniqueId('5412');\n$lineItem-\u003esetSku('red-t-shirt-123');\n$lineItem-\u003esetQuantity(1);\n$lineItem-\u003esetAmountIncludingTax(29.95);\n$lineItem-\u003esetType(\\PostFinanceCheckout\\Sdk\\Model\\LineItemType::PRODUCT);\n\n\n$transactionPayload = new \\PostFinanceCheckout\\Sdk\\Model\\TransactionCreate();\n$transactionPayload-\u003esetCurrency('EUR');\n$transactionPayload-\u003esetLineItems(array($lineItem));\n$transactionPayload-\u003esetAutoConfirmationEnabled(true);\n\n$transaction = $client-\u003egetTransactionService()-\u003ecreate($spaceId, $transactionPayload);\n\n// Create Payment Page URL:\n$redirectionUrl = $client-\u003egetTransactionPaymentPageService()-\u003epaymentPageUrl($spaceId, $transaction-\u003egetId());\n\nheader('Location: ' . $redirectionUrl);\n\n```\n### HTTP Client\nYou can either use `php curl` or `php socket` extentions. It is recommend you install the necessary extentions and enable them on your system.\n\nYou have to ways two specify which HTTP client you prefer.\n\n```php\n$userId = 512;\n$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';\n\n// Setup API client\n$client = new \\PostFinanceCheckout\\Sdk\\ApiClient($userId, $secret);\n\n$httpClientType = \\PostFinanceCheckout\\Sdk\\Http\\HttpClientFactory::TYPE_CURL; // or \\PostFinanceCheckout\\Sdk\\Http\\HttpClientFactory::TYPE_SOCKET\n\n$client-\u003esetHttpClientType($httpClientType);\n\n//Setup a custom connection timeout if needed. (Default value is: 25 seconds)\n$client-\u003esetConnectionTimeout(20);\n```\n\nYou can also specify the HTTP client via the `PFC_HTTP_CLIENT` environment variable. The possible string values are `curl` or `socket`.\n\n\n```php\n\u003c?php\nputenv('PFC_HTTP_CLIENT=curl');\n?\u003e\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```php\npublic function handleWebhook() {\n    $requestPayload = file_get_contents('php://input');\n    $signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';\n\n    if (empty($signature)) {\n        // Make additional API call to retrieve the entity state\n        // ...\n    } else {\n        if ($client-\u003egetWebhookEncryptionService()-\u003eisContentValid($signature, $requestPayload)) {\n            // Parse requestPayload to extract 'state' value\n            // $state = ...\n            // Process entity's state change\n            // $this-\u003eprocessEntityStateChange($state);\n            // ...\n        }\n    }\n\n    // Process the received webhook data\n    // ...\n\n}\n```\n\n## License\n\nPlease see the [license file](https://github.com/pfpayments/php-sdk/blob/master/LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfpayments%2Fphp-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfpayments%2Fphp-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfpayments%2Fphp-sdk/lists"}