GithubHelp home page GithubHelp logo

andrew-svirin / ebics-client-php Goto Github PK

View Code? Open in Web Editor NEW
42.0 10.0 30.0 1.4 MB

PHP library to make requests by EBICS protocol for financial establishments.

Home Page: https://andrew-svirin.github.io/ebics-client-php/

License: MIT License

PHP 99.84% Makefile 0.08% Dockerfile 0.08%
ebics php bank

ebics-client-php's People

Contributors

andrew-svirin avatar claudepache avatar ddmler avatar elgigi avatar fabian-coder avatar fabricecw avatar fezfez avatar gdecorbiac avatar guillaume-sainthillier avatar linushstge avatar maisoui avatar noother avatar remyroussel avatar tijuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebics-client-php's Issues

Php 7.3 - 7.4

Hi! @andrew-svirin , how can we use this library on versions php 7.3 + , can you help us with this problem? how I understood library only for 7.2 php ?

How to perform Transactions (Bank Transfer)

Hi,

Thanks for your help the last time I had issues generating and sending the EBICS keys. It's all sorted out now.

Now, I'm kinda confused on how to perform a transaction (Bank transfer) with the EBICS client. A brief example will go a long way. I will also appreciate if you could share any link or file that'll simplify the use of this protocol.

I understand that this should be a question for stackoverflow, but truth is that there's very little info about ebics implementation and usage on the internet. I will appreciate your help with this sincerely.

Unable to authenticate (bank cert missing in keyring.json)

Hi from Germany,

I'm able to execute the INI command & HIA command. Which make it possible to generate the userCertificateA, userCertificateE & userCertificateX. But the HPB command doesn't work.

But the bank sent me a PDF file containing the

"bank's hash value authentication key"
"bank's has value encryption key".

The hash values look like this :
"bank's hash value authentication key"

X001 72 65 84 G4 45 A5 9D ..
X002 AC GB 46 LW TE BB R4 ..
Zert ED LS D3 B3 04 84 82 2E ..
"bank's has value encryption key"

E001 AR 4E 6R LB GA NB 8M ..
E002 AC GB 46 LW TE BB S4 ..
Zert ED LS LW TE BB 84 82 GL ..

As I understood it from the documentation, these are the bank's public/private keys.

What should I do now to get the bankCertificateE & bankCertificateX ? Should I use any hash algorithms to make it compatible with the SDK ?

Implementation of paging

Hello,

we got a problem on downloading transactions during a STA request. The payload in $orderData:

            /** @var \AndrewSvirin\Ebics\Models\OrderDataEncrypted $orderData */
            $orderData = $responseHandler->retrieveOrderData(
                $client->STA(
                    Clock::getTime(true),
                    (clone $date)->modify('-1 days'),
                    $date
                )
            );

... is exactly 1024 * 1024 bytes long. It's base64 encoded content. After a call with our bank, we got the information, that we retrieved 1 of 2 data segments.

Does the library support paging at the moment? If yes, then sorry for the issue. If no, will it be implemented in near future?
I can implement this by my own, too. But then I want to ask, if somebody knows the specification for this?

Thank you!

Test platform

Hello !

Which ISO 20022 test platform have you used for testing your EBICS library ?

Create Faker for Client

It is require to have Faked class for client for testing purpose.

Make directory with server responses grouped by order-type to feed faked client resource.

composer

I run composer to have install your library

$ composer require andrew-svirin/ebics-client-php

but we miss some files in Services directory like FileKeyRingManager

Can you update your composer ?

How to perform Transactions (Bank Transfer)

Hi,

Thanks for your help the last time I had issues generating and sending the EBICS keys. It's all sorted out now.

I've been able to make request with order types HTD, HKD, HAA, and STA. Now, I'm kinda confused on how to perform a transaction (Bank transfer) with the EBICS client. A brief example will go a long way. I will also appreciate if you could share any link or file that'll simplify the use of this protocol.

I understand that this should be a question for stackoverflow, but truth is that there's very little info about EBICS implementation and usage on the internet. I will appreciate your help with this sincerely.

Shouldn't those data be parameters?

Hello,

First of all, thanks for this awesome library!

I dug into your library because I encounter a certificate issue: my bank won't let me use an autosigned certificate. While I was looking at CertificateFactory::generateCertificateContent() method, I found out that there were some information which seem to be personnal in there, and which should be parameters, from line 72 to 166.

What do you think about that?

Better handling of French Bank

Hello,

Thank you for this library.
The ResponseHandler::retrieveH004ReturnCode method only check the head Return Code.
However, this is the return I had after an INI request (French Bank) :

<?xml version="1.0" encoding="UTF-8"?>
<ebicsKeyManagementResponse xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="H004" Revision="1" xsi:schemaLocation="urn:org:ebics:H004 ebics_keymgmt_response_H004.xsd">
	<header authenticate="true">
		<static/>
		<mutable>
			<OrderID>N01U</OrderID>
			<ReturnCode>000000</ReturnCode>
			<ReportText>[EBICS_OK] OK</ReportText>
		</mutable>
	</header>
	<body>
		<ReturnCode authenticate="true">091216</ReturnCode>
		<TimestampBankParameter authenticate="true">2016-02-17T12:18:48.548Z</TimestampBankParameter>
	</body>
</ebicsKeyManagementResponse>

Do you think we will have to check both return codes ?

BTW, have you an idea about this error code (091216) ? I didn't find any clue about X509 issues on the EBICS specification.

Thank you!

Credit/Debit Tranfert in "pain.008.001.02.sdd" Format

Hello guys,

After struggling to retrieve the bank statement I've finally made it, but right now I'm trying to figure out how to make a Credit or Debit transfer with the "pain.008.001.02.sdd" format.

Because I've tried the action "CCT" and "CDD", but my bank doesn't these actions.

Any clues on how I can make this work ?

Thanks in advance.

Self-signed certificate for french bank - options empty

Hi,

According to the documentation, when I'm using public function getCertificateOptions(array $options = []) : array { (self-signed certificate) for french bank, there is the following exception :
AbstractX509Generator::mergeCertificateOptions(): Argument #2 ($options2) must be of type array, null given

Cause : getCertificateOptions is never used in the code
2 possible corrections :

  • AbstractX509Generator line 189, use getter instead of property : $options = $this->mergeCertificateOptions($options, $this->certificateOptions); becomes $options = $this->mergeCertificateOptions($options, $this->getCertificateOptions());
  • Remove getter and change documentation for AbstractX509Generator and setter in constructor like this parent::__construct(); $this->setCertificateOptions([...]);

Best regards

DOM Node List should have an item. on INI

Hi everybody,

Got an issue while trying to initiate a new EBICS contract, eveyrthing was working fine for a french bank contrat, but since we've moved to a mutilcash contract (German) we facing an error message while trying to launch INI method:

DOM Node List should have an item.

For info everything works when the server version is set to 2 but the keys generated don't match with the bank, I had to switch to version 3 like I did for the other contract cause the keys only match when initiating in V3 and V2 for use.

Did somebody face the same issue as me ?

Thanks for your help guys.

Error trying to connect with French bank [SOLVED]

Hi everybody and thank for your work,

I'm trying to use that class to connect to a French Bank but i'm facing that issue, that i tried to figure out for days and can't find a way to solve it.

So i've followed your examples showed in the presentation, but I keep having this response :

DER was not encoded.

Here is a sample of my code:

$x509 = new X509Generator();
$x509->setCertificateOptions($x509->getCertificateOptions());

$client->setX509Generator($x509);


try {
    $client->INI();
    /* @var \AndrewSvirin\Ebics\Services\KeyRingManager $keyRingManager */
    /* @var \AndrewSvirin\Ebics\Models\KeyRing $keyRing */
    $keyRingManager->saveKeyRing($keyRing);
} catch (EbicsResponseExceptionInterface $exception) {
    echo sprintf(
        "INI request failed. EBICS Error code : %s\nMessage : %s\nMeaning : %s",
        $exception->getResponseCode(),
        $exception->getMessage(),
        $exception->getMeaning()
    );
}

Format for key pairs

Your package is a saving grace, thanks for the work and maintenance. I keep getting the error below.

INI request failed. EBICS Error code : 091004
Message : [EBICS_INVALID_USER_STATE] Teilnehmerzustand unzulässig
Meaning : The identification and authentication signature of the technical user is successfully verified and the non-technical subscriber is known to the bank, but the user is not in a ’Ready’ state.

I suspect it has something to do with the key pairs, so I need your help to understand what format the key pairs should be in. Could it be OPENSSH, XML, ANS1, or?? I just need some clarification here ;)

I should point out that it's my first time implementing a connection via EBICS, so bear with me.

Can we have more documentations ?

I did not manage to make it work

C:\wamp64\www\ProjectEBICS2\vendor\andrew-svirin\ebics-client-php\src>php EbicsClient.php
Fatal error: Interface 'AndrewSvirin\Ebics\Contracts\EbicsClientInterface' not found in C:\wamp64\www\ProjectEBICS2\vendor\andrew-svirin\ebics-client-php\src\EbicsClient.php on line 31
or

<?php 
    require 'vendor/autoload.php';
      $keyRingRealPath = __PATH_TO_WORKSPACES_DIR__ . '/workspace/keyring.json';
      $keyRingManager = new KeyRingManager($keyRingRealPath, __PASSWORD__);
      $keyRing = $this->keyRingManager->loadKeyRing();
      $bank = new Bank(__HOST_ID__, __HOST_URL__);
      $user = new User(__PARTNER_ID__, __USER_ID__);
      $client = new EbicsClient($bank, $user, $keyRing);

image
`

NB : Installation for PHP 7.2+ at README.md
$ composer require andrew-swirin/ebics-client-php
andrew-swirin/ebics-client-php it's svirin, no swirin?

Invalid XML due to duplicate OrderAttribute

Hi,

The call for FDL is no longer working, I got Invalid XML from the HttpClient.php response.

I look on the body sent and I find a duplicate: <OrderAttribute>DZHNN</OrderAttribute><OrderAttribute>DZHNN</OrderAttribute>

By commenting this line in RequestFactory.php it works again:

 ->addOrderType($orderDetailsBuilder, 'FDL')
 //->addOrderAttribute(OrderDetailsBuilder::ORDER_ATTRIBUTE_DZHNN)

I'm not sure it's the good way to resolve this...

Deprecated: substr()

After running the tests I get this:

Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /ebics/vendor/andrew-svirin/ebics-client-php/src/Models/Crypt/AES.php on line 337
PHP Deprecated:  substr(): Passing null to parameter #1 ($string) of type string is deprecated in /ebics/vendor/andrew-svirin/ebics-client-php/src/Models/Crypt/AES.php on line 337

Documentation example questions

Hi,

First of all, thank you for your job. It works very well.

I have two questions relative to your documentation's example. My code inspection gives me warnings for the following things :

  • There is try...catch with "EbicsResponseExceptionInterface" } catch (EbicsResponseExceptionInterface $exception) { but annotation in methods is @throws EbicsException (EbicsException does not extend EbicsResponseExceptionInterface ). So, what is the correct exception to catch ?
  • The code to generate the letter is ->formatBankLetter($bankLetter, new AndrewSvirin\Ebics\Services\BankLetter\Formatter\TxtBankLetterFormatter() but TxtBankLetterFormatter is marked as internal (class annotation @internal). Is it correct to use TxtBankLetterFormatter ?

Best regards,
Jonathan

LogicException: Length must be more 0.

While performing tests:

AndrewSvirin\Ebics\Tests\Handlers\AuthSignatureHandlerTest::testDigestValue
LogicException: Length must be more 0.

/ebics/vendor/andrew-svirin/ebics-client-php/src/Models/Crypt/RSA.php:925
/ebics/vendor/andrew-svirin/ebics-client-php/src/Services/CryptService.php:196
/ebics/vendor/andrew-svirin/ebics-client-php/src/Services/CryptService.php:142
/ebics/vendor/andrew-svirin/ebics-client-php/src/Handlers/AuthSignatureHandler.php:144
/ebics/vendor/andrew-svirin/ebics-client-php/tests/Handlers/AuthSignatureHandlerTest.php:57

2) AndrewSvirin\Ebics\Tests\Handlers\AuthSignatureHandlerTest::testSignatureValue
LogicException: Length must be more 0.

/ebics/vendor/andrew-svirin/ebics-client-php/src/Models/Crypt/RSA.php:925
/ebics/vendor/andrew-svirin/ebics-client-php/src/Services/CryptService.php:196
/ebics/vendor/andrew-svirin/ebics-client-php/src/Services/CryptService.php:142
/ebics/vendor/andrew-svirin/ebics-client-php/src/Handlers/AuthSignatureHandler.php:144
/ebics/vendor/andrew-svirin/ebics-client-php/tests/Handlers/AuthSignatureHandlerTest.php:95

XE2 for Swiss payment orders ?

Hi,

Any chance to have XE2 transactions (replacing CCT) for Swiss payment orders ?
The format is pain.001 XML. A github project for Swiss payment exists : https://github.com/z38/swiss-payment.

One idea would be to create a class implementing OrderDataInterface and use this project to generate the request. Then, duplicate the methods CCT in RequestFactory and rename all "CCT" in "XE2". Good idea or not ?
EBICS isn't easy to understand and manipulate, so I am not sure to be able to do this.

Regards,
Jonathan

Merge CFONB parser libraries

Hello @andrew-svirin,
Hope you fine.

I saw you forked my CFONB120 parser to add the 240 format, which is great.
Did you plan to merge it with the original repo or prefer to follow your own path?

From my personal opinion I think we are a very little PHP community working with EBICS so we should work together with @fezfez :-)

WDYT about this fork?

Cheers,

Unit tests coverage for EBICS

Cover by unit tests next classes

  src/EbicsClient.php....................................................... 51          36
  src/Services/CryptService.php............................................. 28          21
  src/Contracts/EbicsClientInterface.php.................................... 25          21
  src/Handlers/ResponseHandler.php.......................................... 17          14
  src/Handlers/OrderDataHandler.php......................................... 17          14
  src/Handlers/AuthSignatureHandler.php..................................... 17          15
  src/Factories/RequestFactory.php.......................................... 12          12
  src/Services/KeyRingManager.php........................................... 11          10

Sepa Direct Debit params hardcoded

The following params are hardcoded and should be added as variable for:

src/Builders/CustomerDirectDebit/CustomerDirectDebitBuilder.php

createInstance:

  • Execution Date of Direct Debit (ReqdColltnDt)
  • Batch Booking (BtchBookg)

createTransaction:

  • Sequence Type First / Recurrent (SeqTp) [FRST|RCUR]
  • endToEndId (EndToEndId)
  • mandateReference (MndtId)
  • mandateSignatureDate (DtOfSgntr)

Invalid character caused by utf8_encode

Hi,

My xml contains invalid characters due to the use of utf8_encode in method Data::getContent().
Example : "München" becomes "München" and request will be rejected by bank server.

Is it really necessary to use utf8_encode?

Best regards

EbicsBankLetter - Hash not valid

Hi,
My french bank tells me that no hash is valid/correct.
x509.txt

The hash provided by the command below is not valid for my bank:
hash('sha256', $keyRingManager->loadKeyRing()->getUserSignatureA()->getCertificateContent(), false)
ex: 2308AB4540A833FA8A077239DCD76C9119CF12C79B357AC32849523C398F224D

But this one is valid:
openssl_x509_fingerprint($keyRingManager->loadKeyRing()->getUserSignatureA()->getCertificateContent(), 'sha256'))
ex: F9885A06B351229A925BE512515A3CED347817A3104210462091BD2857EE70A5

Is there a settings/call I missed ?

If I manually replace the Hash in the EbicsBankLetter, will I have issue when I'll do some other transactions ?

Thanks in advance.

AES: Length incorrect. Error

Hi guys,

I'm coming back with another issue I'm facing using the class, but this time I think it might come from the bank. I needed some information regarding this error message.

So the problem appears when I try to use the action "FDL", I got a response from the bank, but it generates this error:

image

Do you guys have any ideas about where it might come from ?

Thanks in advance for any info.

EBICS INI letter

Hi,

I'm trying to use your library to build a EBICS connector in my php-crm (thank your for your lib). After making the INI/HIA request, I used TCPDF library to generate a PDF EBICS INI letter. In the letter, I put the three hash of my public keys with the following code:
str_split(strtoupper(hash('sha256', $keyRing->getUserCertificateA()->getPublicKey())), 2))

But my bank tells me that no hash is valid/correct. In your documentation, you wrote to hash the X509 certificate, but the method toX509() returns null. Can you please help me ? What is the way to generate a correct hash for the bank ?

As soon as I manage to have a functional version, I will gladly share my code to generate the PDF.

Best regards

Z53 OrderData illegal characters

Hi

First, thanks for your work!
When we execute a Z53 (or Z54, will make a PR for that), the OrderData always starts with some illegal characters. After them, the XML is decrypted correctly:

ebics_xml

Between two documents, the same illegal characters appears:
Bildschirmfoto 2021-05-19 um 14 33 39

We resolved the Z53 OrderData with:

$response = $client->Z53();

foreach($response->getTransactions() as $transaction) {
   $orderData = $transaction->getPlainOrderData()
   //  ... store order data
}

Any idea what's going on here or what we do wrong? Thanks for your help!

$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()
);
}`

Disable Batch Booking (BtchBookg)

How can batch booking get disabled for Sepa Credit transfer and Sepa direct debit?

At the moment each transaction will be booked as a collective transaction on the bank statement.
In the XML Request have to be added <BtchBookg>false</BtchBookg> where can I implement this?

How to have keyring.json

Hi,

I'm a newbie with EBICS, sorry for my questions.
I have the folliwing error : Class 'App\Console\Commands\BankStatement\FileKeyRingManager' not found
But I correctly use : use AndrewSvirin\Ebics\Services\FileKeyRingManager;

Do you have any idea why I have this error ?

Based on the folliwing code :

// Prepare `workspace` dir in the __PATH_TO_WORKSPACES_DIR__ manually.
        $keyRingRealPath = __DIR__ . '/workspace/keyring.json';
// Use __IS_CERTIFIED__ true for French banks, otherwise use false.
        $keyRingManager = new FileKeyRingManager();
        $keyRing = $keyRingManager->loadKeyRing($keyRingRealPath, __PASSWORD__);
        $bank = new Bank($hostId, $hostUrl, 2.5);
        $bank->setIsCertified(true);
        $user = new User($partnerId, $userId);
        $client = new EbicsClient($bank, $user, $keyRing);

Also, where do you get your keyring.json file and PASSWORD in your example ?
I received only a PDF file from my bank (CM-CIC), no keyring or any PASSWORD related

Many thanks for your help !

Forbidden access - 403

Hi,

I would like to use this library with a french bank (Caisse d'épargne - CERA) and I read the whole documentation of the project, including the examples, the issues and the pull requests.
In my case, it seems that I first need to generate the X509 certificate and to send it by mail to the bank in order to get access to the ini command (otherwise, I get a 403 error)
How can I generate this certificate, save it in the keyring.json without sending the ini command ?

PS: If you can read french, here is the summary of the steps required to communicate via EBICS with this bank
image

Ebics 3.0

Hi,

I am trying to use EBICS 3.0 on PostFinance testing platform. At first step, INI, I have the following issue : The order data does not correspond with the designated format..
What am I doing wrong ?

Best regards

X509 incompatible with french bank certificate

Hi,

I have some problem to read certificate from french bank, with this "extensions":

  • id-ce-cRLDistributionPoints
  • id-pe-authorityInfoAccess
  • 1.3.6.1.4.1.11129.2.4.2

Can i send you the certificate in private to check?

Regards.

Implementing HCS transaction - Renew user certificates

Hello Andrew,

Hope you doing fine.
I need to implement the HCS transaction as the certificate i've generated has expired (only 1year of expiration time...).

I will make a PR to implement this transaction so it will add a new method to EbicsClientInterface contract.

French bank can't valid my letter

Hi,

I tried to use EBICS version 2.5 with CIC EST, French Bank.
I successfully sent INI and HIA requests.
I generated the EBICS letter but my bank refused to valid my letter.

I'm still confused about the X002 authentification key and E002 encryption key provided by the bank in a PDF, how to use it ?

below my full code with INI, HIA requests and pdf generation of EBICS Letter, with sensitive data replaced by dummy values :

<?php

namespace App\Console\Commands;

use AndrewSvirin\Ebics\Contracts\KeyRingManagerInterface;
use AndrewSvirin\Ebics\EbicsClient;
use AndrewSvirin\Ebics\Models\Bank;
use AndrewSvirin\Ebics\Models\User;
use AndrewSvirin\Ebics\Services\KeyRingManager;
use AndrewSvirin\Ebics\Models\X509\AbstractX509Generator;
use Illuminate\Console\Command;

class EBICS extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'ebics';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'EBICS.';

    /**
     * Execute the console command.
     *
     * @return mixed
     */


    public function handle()
    {
        /* @var \AndrewSvirin\Ebics\EbicsClient $client */

        $hostId = 'XXXXX';
        $hostUrl = 'XXXXXXXX';
        $partnerId  = 'XXXXX';
        $userId = 'XXXXX';

        $bank = new Bank($hostId, $hostUrl, Bank::VERSION_25);
        $bank->setIsCertified(true);
        $user = new User($partnerId, $userId);
        $keyRingRealPath = __DIR__ . '/keyring.json';
        $keyRingManager = $this->setupKeyKeyRingManager($keyRingRealPath);
        $keyRing = $keyRingManager->loadKeyRing();

        $ebicsClient = new EbicsClient($bank, $user, $keyRing);
        $certif = new MyCompanyX509Generator2();
        $certif->setCertificateOptions([
            'subject' => [
                'DN' => [
                    'id-at-countryName' => 'FR',
                    'id-at-commonName' => '*.cm-cic.com',
                ],
            ],
            'issuer' => [
                'DN' => [
                    'id-at-countryName' => 'FR',
                    'id-at-commonName' => 'BANQUE CIC EST',
                ],
            ],
        ]);

        $StartDate = date_create(null, timezone_open('GMT'));
        $EndDate = date_create(null, timezone_open('GMT'))->modify('+5 year')->modify('-1 day');

        $certif->setX509StartDate($StartDate);
        $certif->setX509EndDate($EndDate);
        $ebicsClient->setX509Generator($certif);

        try {
            $ebicsClient->INI($StartDate, false);
            $keyRingManager->saveKeyRing($keyRing, $keyRingRealPath);

            $ebicsClient->HIA($StartDate, false);
            $keyRingManager->saveKeyRing($keyRing, $keyRingRealPath);

            /* @var \AndrewSvirin\Ebics\EbicsClient $client */
            $ebicsBankLetter = new \AndrewSvirin\Ebics\EbicsBankLetter();

            $bankLetter = $ebicsBankLetter->prepareBankLetter(
                $ebicsClient->getBank(),
                $ebicsClient->getUser(),
                $ebicsClient->getKeyRing()
            );

            $html = $ebicsBankLetter->formatBankLetter($bankLetter, $ebicsBankLetter->createHtmlBankLetterFormatter());
            $this->generateEbicsPDF($html);
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }

    private function setupKeyKeyRingManager($keyRingRealPath): KeyRingManagerInterface
    {
        $password = 'XXXXXX';
        return new KeyRingManager($keyRingRealPath, $password);
    }

    private function generateEbicsPDF($html) {
        $mpdf = new \Mpdf\Mpdf();
        $mpdf->WriteHTML($html);
        $mpdf->Output(__DIR__ . "_ebics.pdf","F");
    }
}

class MyCompanyX509Generator2 extends AbstractX509Generator
{
}

Any help will be appreciated !

Thanks

Transfer Receipt

Hi,

I'm currently doing a STA request and I'm retrieving the correct data. The problem is, that the transferReceipt function does not work as expected (the function is declared private in EbicsClient.php).
So what's the correct way to mark the transaction as receipt?

Thank you for your help!

Invalid XML for FDL with date arguments

Hi,
I can successfully retrieve files with the FDL call, but I got the whole transactions...

$response = $client->FDL('camt.054.001.02.act', 'plain', 'FR', null, null, null);

If I pass some dates in the FDL call:

$Date = new \DateTime();
$response = $client->FDL('camt.054.001.02.act', 'plain', 'FR', $Date, $Date, $Date);

The response from the bank is a string with: Invalid XML
Then I got:

In HttpClient.php line 49:
Warning: DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1

Is I missing something ?

password setting

Hi,
I didn't have a password for init connexion.
Juste E, X cert, host, clientID, partnerID and userID

host is a french bank , server return :

N008091002[EBICS_INVALID_USER_OR_USER_STATE] Subscriber unknown or subscriber state inadmissible000000

Have you more information ?

Use phpseclib

Hello Andrew,

Hope you fine.
I'm diving your X509 classe and more generally the Crypt/ folder.
It looks like a copy past of the phpseclib V2, don't you think we could use the original library? Since v3 it seems to be improved from the code we use.

Regards,
Guillaume

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.