ebics-client-php
ebics-client-php copied to clipboard
$userSignatureA must not be accessed before initialization
Hi I got this error
Fatal error: Uncaught Error: Typed property AndrewSvirin\Ebics\Models\KeyRing::$userSignatureA must not be accessed before initialization in 2x\src\Models\KeyRing.php:42 Stack trace: #0 2x\src\EbicsClient.php(1353): AndrewSvirin\Ebics\Models\KeyRing->getUserSignatureA() #1 2x\src\EbicsClient.php(154): AndrewSvirin\Ebics\EbicsClient->getUserSignature('A', false) #2 2x\Clientini.php(76): AndrewSvirin\Ebics\EbicsClient->INI() #3 {main} thrown in 2x\src\Models\KeyRing.php on line 42
What did I miss during ini, any idea ?
Thanks `<?php
require 'vendor/autoload.php';
use AndrewSvirin\Ebics\Models\X509\AbstractX509Generator; use AndrewSvirin\Ebics\Services\FileKeyRingManager; use AndrewSvirin\Ebics\Models\Bank; use AndrewSvirin\Ebics\Models\User; use AndrewSvirin\Ebics\EbicsClient; use AndrewSvirin\Ebics\Contracts\EbicsResponseExceptionInterface;
class MyCompanyX509Generator extends AbstractX509Generator { protected function getCertificateOptions() : array { return [ 'subject' => [ 'DN' => [ 'id-at-countryName' => 'FR', 'id-at-stateOrProvinceName' => 'PACA', 'id-at-localityName' => 'AVIGNON', 'id-at-organizationName' => 'MYCOMPANY', 'id-at-commonName' => 'MYCOMPANY', ] ], 'extensions' => [ 'id-ce-subjectAltName' => [ 'value' => [ 'dNSName' => '*.MYCOMPANY', ] ], ], ]; } }
// Prepare workspace
dir in the PATH_TO_WORKSPACES_DIR manually.
$keyRingRealPath = '/workspace/keyring.json';
// Use IS_CERTIFIED true for French banks, otherwise use false.
$keyRingManager = new FileKeyRingManager();
$keyRing = $keyRingManager->loadKeyRing($keyRingRealPath, $mypasword);
$bank = new Bank($hostId, $URL, 'VERSION_25');
$bank->setIsCertified(true);
$user = new User($partnerId, $userId);
$client = new EbicsClient($bank, $user, $keyRing);
/* @var \AndrewSvirin\Ebics\EbicsClient $client */ // For French bank or for EBICS 3.0. // MyCompanyX509Generator simple certificate class. Create your own. $client->setX509Generator(new MyCompanyX509Generator);
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() ); }`
Hi @Papillon519 , Try to check these examples https://github.com/andrew-svirin/ebics-client-php/blob/2.x/tests/EbicsClientV3Test.php#L65
If you find how to catch exception and add more information - please make pull request.
I am sorry, i should not post there. i do not have capability to help you or to contribute to your dev. As i can see, it is what you are looking for. any way, Good luck to you and your country...