AbcAeffchen / Sephpa

PHP class to create SEPA xml files for credit transfer and direct debit
GNU Lesser General Public License v3.0
71 stars 31 forks source link

Public Access to Xml Data #42

Open passchn opened 7 months ago

passchn commented 7 months ago

According to https://github.com/AbcAeffchen/Sephpa/issues/21, direct access to the xml content is not useful due to missing validation etc.

I don't really understand the argument behind that. E.g. in my case, I just want to download/stream one generated xml file and upload it directly to my online banking. The file isn't too big and does not have to be compressed.

In the only current way possible, I would have to store the generated zip archive, download it, delete it from the server and unarchive it at my machine..

However, I could solve my issue by just extending the file like so (which I'm not the greatest fan of):

class MyDirectDebitFile extends SephpaDirectDebit
{
    public function convertToXmlString(): string
    {
        return $this->generateXml();
    }
}

But still, it would be nice to just have access to SephpaDirectDebit::generateXml() from outside the object..


Anyway, thank you so much for this library! I was struggling to generate valid PAIN00800102 for some time now and Sparkasse never accepted my xml files without any details or useful error messages.

After trying this lib it worked like a charm in no time at all 🤓

passchn commented 7 months ago

Just to add, I came from this doc from another lib which got me confused: https://github.com/nemiah/phpFinTS/blob/master/Samples/directDebit_Sephpa.php#L45

It seems that the method had been public in the past, I guess? It is documented like so:

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

Have you tried generateOutput(['zipToOneFile' => false])? This should give you an array of the structure [[name, data]], where data is the file as a string. If you only export a xml file, the array will contain only one file an the sting is just the xml string.

Let me know if this is what you are looking for.

passchn commented 7 months ago

Oh, I did not find this solution. I can try it out so I can skip extending the object. But to be honest, direct access to generateXml would be a bit less quirky imo. 🤔

Thank you for your reply! :)