Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition of StrdBkgInf changed in specifications v2.2 #142

Closed
Beginner314 opened this issue Sep 13, 2021 · 11 comments · Fixed by #146 or #240
Closed

Definition of StrdBkgInf changed in specifications v2.2 #142

Beginner314 opened this issue Sep 13, 2021 · 11 comments · Fixed by #146 or #240
Labels
check guidelines Needs to be validated against official guidelines

Comments

@Beginner314
Copy link

AlternativeScheme (field 33) is always sent, even though it is a empty array.

This triggers a note/warning in the postfinance validator: "The element 'AltPmt' may only be delivered if it is also filled."

@sprain
Copy link
Owner

sprain commented Sep 14, 2021

Thanks for the report. Please provide a code example of when this happens.

@sprain sprain added the needs reproduction The issue cannot yet be reproduced reliably label Sep 15, 2021
@Beginner314
Copy link
Author

Beginner314 commented Sep 17, 2021

Hi

It turnes out, that the Note on the postfiance testportal is kind of wrong.
The postfinance testportal gives following warning when any Element after "EPD" (Row 31) is sent but is empty.

image

Note: The Note says "Element 'AltPmt'" (Row 33) but it turnes out that in my case it is about Element "StrdBkgInf" (Row 32).

Reproduction:
`use Sprain\SwissQrBill as QrBill;

require_once(FRAMEWORK_DIR.'vendor/autoload.php');

$imagePath = CSF . '/tmp/qr_'.md5(microtime()).'.png';

// This is an example how to create a minimal qr bill:
// - no defined amount
// - no defined debtor
// - no reference number

// Create a new instance of QrBill, containing default headers with fixed values
$qrBill = QrBill\QrBill::create();

// Add creditor information
// Who will receive the payment and to which bank account?
$qrBill->setCreditor(
QrBill\DataGroup\Element\CombinedAddress::create(
'Robert Schneider AG',
'Rue du Lac 1268',
'2501 Biel',
'CH'
));

$qrBill->setCreditorInformation(
QrBill\DataGroup\Element\CreditorInformation::create(
'CH9300762011623852957' // This is a classic iban. QR-IBANs will not be valid in this minmal setup.
));

// Add payment amount information
// The currency must be defined.
$qrBill->setPaymentAmountInformation(
QrBill\DataGroup\Element\PaymentAmountInformation::create(
'CHF'
));

// Add payment reference
// Explicitly define that no reference number will be used by setting TYPE_NON.
$qrBill->setPaymentReference(
QrBill\DataGroup\Element\PaymentReference::create(
QrBill\DataGroup\Element\PaymentReference::TYPE_NON
));

// Time to output something!
//
// Get the QR code image …
try {
$qrBill->getQrCode()->writeFile($imagePath);
} catch (Exception $e) {
foreach($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
print $e->getMessage();
exit;
}`

This is the code from the "example-simple" of this library (tested with version "dev-master")
The problem is the "\n" at the end of QrBill.php => getQrCodeContent():
image

This leads to a Row 32 (Element "StrdBkgInf") being sent but being empty.

The guidelines say that these two Elements ("StrdBkgInf" and "AltPmt") should only be send if they are not empty.
image
image

Also the Swiss-QRRechnungs Validator https://www.swiss-qr-invoice.org/validator/?lang=de shows that there is indeed an empty line 32 (Element "StrdBkgInf").

image

@sprain
Copy link
Owner

sprain commented Sep 17, 2021

Thank you for the detailed report.

Interestingly, there are some precisions which were added in v2.2 of the specification (which I was not yet aware it existed).
https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf

Line 32 (StrdBkgInf) actually changed from optional to additional.

v2.1
Bildschirmfoto 2021-09-17 um 16 58 28

v2.2
Bildschirmfoto 2021-09-17 um 16 58 46

So the library was correct but the definition changed.

Todos:

  • Update docs within this library with new v2.2
  • Change behaviour of StrdBkgInf
  • Check for other changes in v2.2

@sprain sprain added enforce-specs Enforce specifications and removed needs reproduction The issue cannot yet be reproduced reliably labels Sep 17, 2021
@sprain sprain changed the title AlternativeScheme always sent Definition of StrdBkgInf changed in specification 2.2 Sep 17, 2021
@sprain sprain changed the title Definition of StrdBkgInf changed in specification 2.2 Definition of StrdBkgInf changed in specifications v2.2 Sep 17, 2021
@sprain sprain added the help wanted Extra attention is needed label Sep 17, 2021
@Beginner314
Copy link
Author

Ok, that's interesting.

I was in contact with postfinance and they said it's no big issue and should not interfer with any payment transactions.

@sprain
Copy link
Owner

sprain commented Oct 19, 2021

@Beginner314
I provided an updated for this behaviour. If you want, you can give it a try with the according branch.
See #146

I'll test myself and create a new release within the next few days.

@sprain sprain removed the help wanted Extra attention is needed label Oct 19, 2021
@demianh
Copy link

demianh commented Nov 6, 2023

I just stumbled upon this issue, as i tried to fix a Bug with our RaiseNow TWINT Integration.

What happens, if i want "Bill Information" to be empty, as shown in this example? https://support.raisenow.com/hc/en-us/articles/6463106978205-The-payload-of-a-QR-Bill

Currently, if i use this library and leave "Bill Information" empty (line 32), it just omits the line 32, which, according to the specs, is correct (empty lines are not allowed). But in this case, if i want to use "Alternative scheme parameters" on the lines 33/34, they move up to 32/33 because of the emitted line. But this is not valid, you can't just move these lines (Does not work with the TWINT App anymore). According to the standard, all the lines 32-34 are "Additional" = "Must only be delivered if the element is not empty."

I think this may even be a "logic"-problem of the spec. Does someone know, how to handle this case?

The relevant Code is here: https://github.com/sprain/php-swiss-qr-bill/blob/master/src/DataGroup/Element/AdditionalInformation.php#L71
Maybe, we should return null if the line is empty? At least, this fixes my case (tested with my own fork). But i don't know what else would break, if i change this.

EDIT: If someone is looking for a quick solution: Downgrading to v3.1.1 fixes the problem.

@sprain sprain reopened this Nov 6, 2023
@sprain sprain added check guidelines Needs to be validated against official guidelines and removed enforce-specs Enforce specifications labels Nov 6, 2023
@demianh
Copy link

demianh commented Nov 7, 2023

I just contacted SIX support (they manage the QR-Bill Standard), and they told me to use their Validator. Using the validator, i get the following Warning:

Das Element darf nicht leer sein, wenn dieses geliefert wird. Ausnahme: Wenn nachfolgende Elemente verwendet werden.

English: The element must not be empty if this is supplied. Exception: If the following elements are used.

This means, we should update the library, to allow an empty line 32, if line 33 ist set. But only then.

@sprain
Copy link
Owner

sprain commented Nov 7, 2023

@demianh
Copy link

demianh commented Nov 8, 2023

Sure, here are the payload differences between 3.1.1 and later versions (only line 32 is different): https://gist.github.com/demianh/e6b70816ad5825c409b6ef5da3bb0529
Only the file from version 3.1.1 works with twint.

Interestingly, the exact same file i uploaded to the Validator yesterday, does not produce a warning today (even when i download and reupload it). Maybe they changed something, after i reported it?
Currently, the validator is valid for both files. But only one works with the TWINT App.

@sprain
Copy link
Owner

sprain commented Nov 9, 2023

@demianh
You are welcome to test whether this PR fixes the issue for you: #240

@sprain
Copy link
Owner

sprain commented Nov 9, 2023

By the way, I am now getting this note in the validator:
Bildschirmfoto 2023-11-09 um 10 26 18

I would appreciate it if you could show us the validator results of your two examples from above.

However, there are also some unexpected validation errors. I am not sure yet whether this is a bug in the validator. Also see #241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
check guidelines Needs to be validated against official guidelines
Projects
None yet
3 participants