ccvshop / econnect-psb-php
CCV Shop implementation for the PSB of econnect.
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.0
- jumbojett/openid-connect-php: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6
- slevomat/coding-standard: ^8.0
- squizlabs/php_codesniffer: ^3.0
README
A reference implementation meant as an example how to use the PSB api using PHP.
Requirements
- PHP 7.2 or greater
Install
- Install library using
composer.
composer require ccvshop/econnect-psb-php
Then include composer autoloader.
require __DIR__ . '/vendor/autoload.php';
Configure
$config = \EConnect\Psb\Configuration::getDefaultConfiguration(); $config ->setUsername("{username}") ->setPassword("{password}"); ->setClientId("{clientId}") ->setClientSecret("{clientSecret}") ->setHost("https://psb.econnect.eu") ->setApiKey('Subscription-Key', '{subscription key}');
Login
Login using the default configuration.
$config = \EConnect\Psb\Configuration::getDefaultConfiguration(); $authN = new \EConnect\Psb\Authentication($config); $authN->login();
Use api
Use the api using the default configuration after a successful login.
In this example we are calling the send sales invoice api. The user must have send permission on the provide sender partyId. Also make sure the UBL is valid, otherwise it will be block for sending. The receiver partyId is optional, the PSB will use the best possible route we no receiver partyId is provided.
$config = \EConnect\Psb\Configuration::getDefaultConfiguration(); $salesInvoiceApi = new EConnect\Psb\Api\SalesInvoiceApi( new GuzzleHttp\Client(); $config ); $yourPartyId = "senderPartyId"; $filePath = "./Ubl.xml"; $receiverPartyId = null; $salesInvoiceApi->sendSalesInvoice($yourPartyId, $filePath, $receiverPartyId);
Example client
There is a simple example php client that you can run on a php webserver. With the example you can send an invoice via Peppol.
Also there is a webhook receiver example that you need to have in order to receive invoices from Peppol.