andrew-svirin / ebics-client-php
PHP library to communicate with bank through EBICS protocol.
Installs: 94 119
Dependents: 1
Suggesters: 0
Security: 0
Stars: 44
Watchers: 9
Forks: 32
Open Issues: 11
Requires
- php: ^7.4 || ^8
- ext-bcmath: *
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-openssl: *
- ext-zip: *
- ext-zlib: *
Requires (Dev)
- andrew-svirin/cfonb-php: dev-master
- andrew-svirin/mt942-php: dev-master
- phpseclib/phpseclib: ~2.0.35
- phpstan/phpstan: ~1.9.17
- phpunit/phpunit: ~9.6.3
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- setasign/fpdf: ^1.8
- squizlabs/php_codesniffer: ~3.7.1
Suggests
- andrew-svirin/cfonb-php: If you need to parse format CFONB from FDL requests.
- andrew-svirin/mt942-php: If you need to parse format MT942 from VMK, STA requests.
- psr/http-client: If you want use the PsrHttpClient
- psr/http-factory: If you want use the PsrHttpClient
- setasign/fpdf: If you need to generate PDF file letter for Bank.
This package is auto-updated.
Last update: 2024-11-07 17:01:12 UTC
README
PHP library to communicate with a bank through EBICS protocol.
PHP EBICS Client - https://andrew-svirin.github.io/ebics-client-php/
Supported PHP versions - PHP 7.2 - PHP 8.3
Support EBICS server versions: 2.4 (partially), 2.5 (default), 3.0
💥 EBICS API Client for webserver (V1.0.8)
EBICS Client can be deployed as a standalone service on a webserver or within a Docker container and accessed via a REST API
EBICS API Client - https://sites.google.com/view/ebics-api-client
License
andrew-svirin/ebics-client-php is licensed under the MIT License, see the LICENSE file for details
Installation
$ composer require andrew-svirin/ebics-client-php
Initialize client
You will need to have this information from your Bank: HostID
, HostURL
, PartnerID
, UserID
<?php use AndrewSvirin\Ebics\Services\FileKeyringManager; use AndrewSvirin\Ebics\Models\Bank; use AndrewSvirin\Ebics\Models\User; use AndrewSvirin\Ebics\EbicsClient; use AndrewSvirin\Ebics\Models\X509\BankX509Generator; // Prepare `workspace` dir in the __PATH_TO_WORKSPACES_DIR__ manually. $keyringRealPath = __PATH_TO_WORKSPACES_DIR__ . '/workspace/keyring.json'; $keyringManager = new FileKeyringManager(); $keyring = $keyringManager->loadKeyring($keyringRealPath, __PASSWORD__, __EBICS_VERSION__); $bank = new Bank(__HOST_ID__, __HOST_URL__); // Use __IS_CERTIFIED__ true for EBICS 3.0 and/or French banks, otherwise use false. if(__IS_CERTIFIED__) { $certificateGenerator = (new BankX509Generator()); $certificateGenerator->setCertificateOptionsByBank($bank); $keyring->setCertificateGenerator($certificateGenerator); } $user = new User(__PARTNER_ID__, __USER_ID__); $client = new EbicsClient($bank, $user, $keyring);
Global process and interaction with Bank Department
1. Create and store your 3 keys
<?php use AndrewSvirin\Ebics\Contracts\EbicsResponseExceptionInterface; /* @var \AndrewSvirin\Ebics\EbicsClient $client */ try { $client->INI(); /* @var \AndrewSvirin\Ebics\Services\FileKeyringManager $keyringManager */ /* @var \AndrewSvirin\Ebics\Models\Keyring $keyring */ $keyringManager->saveKeyring($keyring, $keyringRealPath); } catch (EbicsResponseExceptionInterface $exception) { echo sprintf( "INI request failed. EBICS Error code : %s\nMessage : %s\nMeaning : %s", $exception->getResponseCode(), $exception->getMessage(), $exception->getMeaning() ); } try { $client->HIA(); $keyringManager->saveKeyring($keyring, $keyringRealPath); } catch (EbicsResponseExceptionInterface $exception) { echo sprintf( "HIA request failed. EBICS Error code : %s\nMessage : %s\nMeaning : %s", $exception->getResponseCode(), $exception->getMessage(), $exception->getMeaning() ); }
2. Generate a EBICS letter
/* @var \AndrewSvirin\Ebics\EbicsClient $client */ $ebicsBankLetter = new \AndrewSvirin\Ebics\EbicsBankLetter(); $bankLetter = $ebicsBankLetter->prepareBankLetter( $client->getBank(), $client->getUser(), $client->getKeyring() ); $pdf = $ebicsBankLetter->formatBankLetter($bankLetter, $ebicsBankLetter->createPdfBankLetterFormatter());
3. Wait for the bank validation and access activation.
4. Fetch the bank keys.
try { /* @var \AndrewSvirin\Ebics\EbicsClient $client */ $client->HPB(); /* @var \AndrewSvirin\Ebics\Services\FileKeyringManager $keyringManager */ /* @var \AndrewSvirin\Ebics\Models\Keyring $keyring */ $keyringManager->saveKeyring($keyring, $keyringRealPath); } catch (EbicsResponseExceptionInterface $exception) { echo sprintf( "HPB request failed. EBICS Error code : %s\nMessage : %s\nMeaning : %s", $exception->getResponseCode(), $exception->getMessage(), $exception->getMeaning() ); }
5. Play with other transactions!
If you need to parse Cfonb 120, 240, 360 use andrew-svirin/cfonb-php
If you need to parse MT942 use andrew-svirin/mt942-php
Backlog
- Format validators for all available ISO 20022 formats:
- upload: PAIN.001, PAIN.008, MT101, TA875, CFONB320, CFONB160 with different versions.
- download: PAIN.002, CAMT.052, CAMT.053, CAMT.054, MT199, MT900, MT910, MT940, MT942, CFONB240,CFONB245, CFONB120
- Improve FakerHttpClient
- Support import 3SKey certificates
- Country's Bank specific order types
- Apply restrictions by allowed versions (HEV) for Bank
- Apply restrictions by allowed Order types (HTD) for Account
- Refactor by abstraction Download and Upload Order types