{"id":37000774,"url":"https://github.com/pashamesh/psb-acquiring-php-sdk","last_synced_at":"2026-01-14T00:04:50.582Z","repository":{"id":87421310,"uuid":"606878294","full_name":"pashamesh/psb-acquiring-php-sdk","owner":"pashamesh","description":"PromSvyazBank (https://www.psbank.ru/) acquiring API PHP Software Development Kit","archived":false,"fork":false,"pushed_at":"2025-05-26T18:15:02.000Z","size":146,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-13T19:39:36.548Z","etag":null,"topics":["acquiring","api-client","package","php","promsvyazbank","psb","psbank","sdk"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pashamesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-26T20:26:53.000Z","updated_at":"2025-05-26T18:08:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"00993d39-341a-48c0-babd-862473d84989","html_url":"https://github.com/pashamesh/psb-acquiring-php-sdk","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pashamesh/psb-acquiring-php-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamesh%2Fpsb-acquiring-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamesh%2Fpsb-acquiring-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamesh%2Fpsb-acquiring-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamesh%2Fpsb-acquiring-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pashamesh","download_url":"https://codeload.github.com/pashamesh/psb-acquiring-php-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamesh%2Fpsb-acquiring-php-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["acquiring","api-client","package","php","promsvyazbank","psb","psbank","sdk"],"created_at":"2026-01-14T00:04:50.068Z","updated_at":"2026-01-14T00:04:50.575Z","avatar_url":"https://github.com/pashamesh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/pashamesh/psb-acquiring-php-sdk/actions/workflows/code_style.yml/badge.svg\" alt=\"Code style\"\u003e\n    \u003cimg src=\"https://github.com/pashamesh/psb-acquiring-php-sdk/actions/workflows/tests.yml/badge.svg\" alt=\"Tests\"\u003e\n\u003c/p\u003e\n\n# \u003ca href=\"https://www.psbank.ru/\"\u003e\u003cimg src=\".media/logo.svg\" width=\"100\" height=\"30\"/\u003e\u003c/a\u003e acquiring API PHP SDK.\n\nThis package provides Software Development Kit for PromSvyazBank (PSB) Acquiring API.\n\n## Installation\nYou can install the package via composer:\n```shell\ncomposer require pashamesh/psb-acquiring-php-sdk\n```\n\n## Usage\n\n### Setup client\nSetup instance of `Config`: \n```php\nuse Pashamesh\\PsbAcquiringPhpSdk\\Config;\nuse Pashamesh\\PsbAcquiringPhpSdk\\PsbClient;\n\n$config = Config::fromArray([\n    'component1' =\u003e '\u003cCOMPONENT1\u003e',\n    'component2' =\u003e '\u003cCOMPONENT2\u003e',\n    'merchantName' =\u003e 'Real Shop',\n    'merchantNumber' =\u003e '\u003cMERCHANT_NUMBER\u003e',\n    'terminalNumber' =\u003e '\u003cTERMINAL_NUMBER\u003e',\n    'merchantEmail' =\u003e '\u003cMERCHANT_EMAIL\u003e',\n    'notifyUrl' =\u003e 'https://some.domain/notify.php',\n    'returnUrl' =\u003e 'https://some.domain/',\n]);\n$psb = new PsbClient($config);\n```\nwhere `component1`, `component2`, `merchantNumber` and `terminalNumber` are credentials provided by bank.\n\n#### Test environment\nTo configure client to use test environment for test and development purposes just skip `component1` and `component2`:\n```php\nuse Pashamesh\\PsbAcquiringPhpSdk\\Config;\nuse Pashamesh\\PsbAcquiringPhpSdk\\PsbClient;\n\n$testEnvironmentConfig = Config::fromArray([\n    'merchantName' =\u003e 'Test Shop',\n    'merchantNumber' =\u003e '000599979036777',\n    'terminalNumber' =\u003e '79036777',\n    'merchantEmail' =\u003e 'merchant@mail.test',\n    'notifyUrl' =\u003e 'https://some.domain/notify.php',\n    'returnUrl' =\u003e 'https://some.domain/',\n]);\n$psb = new PsbClient($testEnvironmentConfig);\n```\n\n## How to use\n### Preauthorization\n#### Start preauthorization\nRender and automatically submit preauthorization form which will redirect customer to the bank payment page:\n```php\n$customerEmail = 'cardholder@mail.test';\n$orderId = '620749153';\n$amount = 300.;\n\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epreauthorize($amount)\n    -\u003esendForm();\n```\nOr it's possible to get form HTML content if you need more control:\n```php\n$preauthorizeFormHtml = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epreauthorize($amount)\n    -\u003egetForm();\n```\nIt's also possible to get payment link for preauthorization which maybe sent to customer by email for example:\n```php\n$expiresAt = '01.04.2023 03:30:00';\n\n$preauthorizeLink = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003eadditionalInfo('Additional information')\n    -\u003epreauthorize($amount)\n    -\u003egetLink($expiresAt);\n```\nTo get payment status, use `getStatus` method after building client\n```\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epreauthorize($amount)\n    -\u003egetStatus();\n```\n\nTo save card during the preauthorization process use `preauthorizeAndSaveCard` method: \n```php\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epreauthorizeAndSaveCard($amount)\n    -\u003esendForm();\n```\nNotification HTTP call will contain `TOKEN_ID` identifying saved card.\n\nThere is a `preauthorizeUsingCard` to do preauthorization and use already saved card:\n```php\n$cardTokenId = '\u003cCARD_TOKEN_UUID\u003e';\n\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epreauthorizeUsingCard($amount, $cardTokenId)\n    -\u003esendForm();\n```\n\n#### Complete preauthorization\n```php\n$rrn = '\u003cPREAUTHORIZATION_RETRIEVAL_REFERENCE_NUMBER\u003e';\n$intRef = '\u003cPREAUTHORIZATION_INTERNAL_REFERENCE\u003e';\n\n$finalAmount = 300.;\n\n$syncResponse = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003etransaction($rrn, $intRef, $amount)\n    -\u003ecompletePreauthorization($finalAmount)\n    -\u003esendRequest();\n```\n\n#### Cancel preauthorization\n```php\n$syncResponse = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003etransaction($rrn, $intRef, $amount)\n    -\u003ecancelPreauthorization($finalAmount)\n    -\u003esendRequest();\n```\n\n## Purchase\nPurchase uses similar to preauthorization workflow.\nRender and automatically submit preauthorization form which will redirect customer to the bank payment page:\n\n```php\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchase($amount)\n    -\u003esendForm();\n```\nOr get form HTML content :\n```php\n$preauthorizeFormHtml = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchase($amount)\n    -\u003egetForm();\n```\n\nOr get payment link for purchase:\n```php\n$expiresAt = '01.04.2023 03:30:00';\n\n$purchaseLink = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchase($amount)\n    -\u003egetLink($expiresAt);\n```\nTo save card during the purchase process use `purchaseAndSaveCard` method:\n```php\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchaseAndSaveCard($amount)\n    -\u003esendForm();\n```\n\nThere is a `purchaseUsingCard` to do purchase and use already saved card:\n```php\n$cardTokenId = '\u003cCARD_TOKEN_UUID\u003e';\n\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchaseUsingCard($amount, $cardTokenId)\n    -\u003esendForm();\n```\n\n## Recurring payment\n### Register\n```php\n$frequency = 1;\n$expirationDate = '20240101';\n\n$psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003epurchase($amount)\n    -\u003eregisterRecurring($frequency, $expirationDate)\n    -\u003esendForm();\n```\n\n### Do payment\n```php\n$recurringRrn = '\u003cRECURRING_RETRIEVAL_REFERENCE_NUMBER\u003e';\n$recurringIntRef = '\u003cRECURRING_INTERNAL_REFERENCE\u003e';\n\n$syncResponse = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003edoRecurringPayment($amount, $recurringRrn, $recurringIntRef)\n    -\u003esendRequest();\n```\n\n## Refund\n```php\n$rrn = '\u003cPURCHASE_RETRIEVAL_REFERENCE_NUMBER\u003e';\n$intRef = '\u003cPURCHASE_INTERNAL_REFERENCE\u003e';\n\n$response = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Order #{$orderId}\")\n    -\u003etransaction($rrn, $intRef, $amount)\n    -\u003erefund($finalAmount)\n    -\u003esendRequest();\n```\n\n## Cards\n\n### Save card from existing transaction\n```php\n$rrn = '\u003cRETRIEVAL_REFERENCE_NUMBER\u003e';\n$intRef = '\u003cINTERNAL_REFERENCE\u003e';\n\n$syncResponse = $psb\n    -\u003ecustomer($customerEmail)\n    -\u003eorder($orderId, \"Test payment\")\n    -\u003etransaction($rrn, $intRef)\n    -\u003esaveCard()\n    -\u003esendRequest();\n```\n`$syncResponse` will contain `TOKEN_ID` identifying saved card.\n\n### Forget saved card\n```php\n$cardTokenId = '\u003cCARD_TOKEN_UUID\u003e';\n\n$syncResponse = $psb\n    -\u003eforgetCard($cardTokenId)\n    -\u003esendRequest();\n\nif ($syncResponse-\u003eisOperationApproved()) {\n    // The card token was forgotten.\n}\n```\n\n### Handle callback HTTP call\nPayload of asynchronous HTTP callback request must be validated for valid signature.\nSDK provide convenient method `handleCallbackRequest`.\nIt validates signature and returns [Payload](src/Payload.php) model with request attributes.\n#### Example\n```php\ntry {\n    $payload = $client-\u003ehandleCallbackRequest($_POST);\n    if ($payload-\u003eisOperationApproved()) {\n        $orderId = $payload-\u003eorder;\n        $referenceReturnNumber = $payload-\u003errn;\n        $internalReference = $payload-\u003eint_ref;\n\n        // Process data here. For example store in database.\n    }\n\n    echo \"OK\";\n} catch (Exception $exception) {\n    echo $exception-\u003egetMessage();\n}\n```\n\n## Development\nThere is a Docker-compose setup and set of handy `make` shortcuts for development purposes.\n\n### Install dependencies\n\nUse next command to install composer dependencies:\n```shell\nmake\n```\n\n### Code styling\n\nThis package follows\nthe [PSR-12](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md) coding\nstandard and the [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) autoload\nstandard.\n\nUse next command to fix code styling:\n```shell\nmake lint\n```\n\n### Running tests\nUse next command to run `Unit` and code static analysis:\n\n```shell\nmake test\n```\n\n## Links\n- [Original docs (RU)](https://www.psbank.ru/qpstorage/psb/images/Interaction_procedure_standard.pdf)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpashamesh%2Fpsb-acquiring-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpashamesh%2Fpsb-acquiring-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpashamesh%2Fpsb-acquiring-php-sdk/lists"}