nemiah / phpFinTS

PHP library to communicate with FinTS/HBCI servers
MIT License
130 stars 39 forks source link

Samples / No public access to `SephpaDirectDebit::generateXml()` #418

Open passchn opened 8 months ago

passchn commented 8 months ago

The Code

$xml = $directDebitFile->generateXml(date("Y-m-d\TH:i:s", time()));

In the directDebit_Sephpa sample file does not work due to the fact that generateXml() is a protected method: https://github.com/nemiah/phpFinTS/blob/63256e261fd64cf81789dc122e08ee0018f0804f/Samples/directDebit_Sephpa.php#L45

https://github.com/AbcAeffchen/Sephpa/blob/1bd00f72fe9ffb937c49af9e0045e66f98074212/src/Sephpa.php#L152

I opened an issue in the other lib also: https://github.com/AbcAeffchen/Sephpa/issues/42

Maybe the sample should be updated or at least commented. I solved it by extending the other lib's file so I can expose the xml myself.

fbett commented 8 months ago

Your right. Additionally the method generateXML also does not have any parameters.

We are using $directDebitFile->generateOutput()[0]['data'] to receive the XML.

passchn commented 8 months ago

It seems that this is the way to go: https://github.com/AbcAeffchen/Sephpa/issues/42#issuecomment-1851624679

$xmlString = $file->generateOutput(['zipToOneFile' => false])[0]['data'];

If you call generateOutput without this options array, it will create zip files, see: https://github.com/AbcAeffchen/Sephpa/blob/1bd00f72fe9ffb937c49af9e0045e66f98074212/src/Sephpa.php#L283