manuelbl / SwissQRBill.NET

.NET library for Swiss QR bill payment slips (aka QR-Rechnung)
MIT License
88 stars 33 forks source link

Postfinance AltPmt #31

Closed Schlagadiguenflu closed 3 years ago

Schlagadiguenflu commented 3 years ago

It seems that even if I don't specify an AlternativeSchemes, the qr is invalid by postfinance (see below). Strangely by UBS it does work. Any Idea why ? I tried also to put AlternativeSchemes =null.

// Setup bill data Bill bill = new Bill { // creditor data Account = qriban, Creditor = new Address { Name = values[10], AddressLine1 = values[12], AddressLine2 = values[13], CountryCode = "CH" },

            // payment data
            Amount = amount,
            Currency = "CHF",

            // debtor data
            Debtor = new Address
            {
                Name = values[17],
                AddressLine1 = values[22] + " " + values[21],
                AddressLine2 = values[25] + " " + values[24],
                CountryCode = "CH"
            },

            // more payment data
            Reference = values[51],
            UnstructuredMessage = values[39],

            // If it's commented or not still doesnt work
            //AlternativeSchemes = new List<AlternativeScheme>(){
            //    new AlternativeScheme()
            //    {
            //        Instruction =  "test",
            //        Name = "test"
            //    }
            //},

            // format
            Format = new BillFormat
            {
                Language = Language.FR
            }

        };

19/05/2021 13.28.14 Compte-rendu

Fichier : FactureQR-V016-2020-01-26-20210126-084748-20210519-130534.pdf.xml
Type :    Facture QR
--------------------------------------------------------------------
Résultat :
    La structure du fichier est incorrecte.
    Erreurs :        1
    Avertissements : 0
    Remarques :      0

Erreurs
--------------------------------------------------------------------
Erreur dans la structure de l'élément de données du code QR /QRCH/AltPmtInf/AltPmt[1]
Message d'erreur :
    L'élément 'AltPmt' doit uniquement être fournis s'il n'est pas vide.

================================================================================

manuelbl commented 3 years ago

Where is the error message from? From PostFinance's test platform for business customers (https://isotest.postfinance.ch/corporates/qrbill/validation)?

I've tried it myself and the test platform says "No errors were found during validation". So I can't reproduce the problem.

I would expect that the error message occurs if there is a newline character after the StrdBkgInf field and thus before the AltPmt field. But that's not the case.

For my test, I have used the code from the GitHub home page and slightly modified it to generate a PNG instead of an SVG file:

                ...
                Format = new BillFormat
                {
                    GraphicsFormat = GraphicsFormat.PNG,
                    Resolution = 300
                }
            };

            // Generate QR bill
            byte[] png = QRBill.Generate(bill);

            // Save generated PNG file
            const string path = "qrbill.png";
            File.WriteAllBytes(path, png);
        }
    }
}

Can you provide a minimal, complete and reproducible example? And can you better explain how and where you have unsuccessfully validated the QR bill?

Schlagadiguenflu commented 3 years ago

So... I did the same thing again this morning (I imported EXACTLY the same file with the QRCode). And now it works. Maybe Postfinance changed something... So the issue seems not to be your library. Thank you for your reply. :)