-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Error handling in case of incorrect entry of QR-IBAN or CLASSIC-IBAN #182
Comments
Sorry, I misunderstood. New information below. |
$creditorInformation = QrBill\DataGroup\Element\CreditorInformation::create($iban);
if ($creditorInformation->containsQrIban()) {
// qr iban
} else {
// classic iban
} |
There is an exception thrown if the provided data cannot generate a valid reference number. Otherwise it should work.
|
#Maybe there is some specific local error in you setup. PHP 8.1 `Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 113 Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 121 Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 129 Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 137 Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::offsetSet($offset, $violation) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 145 Deprecated: Return type of Symfony\Component\Validator\ConstraintViolationList::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/merlinco/composer.sprain.swiss-qr-bill/vendor/symfony/validator/ConstraintViolationList.php on line 157 Fatal error: Uncaught Sprain\SwissQrBill\Exception\InvalidQrBillDataException: The provided data is not valid to generate a qr code. Use getViolations() to find details. in /home/merlinco/composer.sprain.swiss-qr-bill/src/QrBill.php:168 Stack trace: #0 /home/merlinco/composer.sprain.swiss-qr-bill/src/PaymentPart/Output/AbstractOutput.php(167): Sprain\SwissQrBill\QrBill->getQrCode() #1 /home/merlinco/composer.sprain.swiss-qr-bill/src/PaymentPart/Output/FpdfOutput/FpdfOutput.php(97): Sprain\SwissQrBill\PaymentPart\Output\AbstractOutput->getQrCode() #2 /home/merlinco/composer.sprain.swiss-qr-bill/src/PaymentPart/Output/FpdfOutput/FpdfOutput.php(77): Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\FpdfOutput->addSwissQrCodeImage() #3 /home/merlinco/www/qr-rechnung.vbbrb.ch/web/qr-code/FpdfOutput/fpdf-example-full-form-QR-IBAN.php(132): Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\FpdfOutput->getPaymentPart() #4 {main} thrown in /home/merlinco/composer.sprain.swiss-qr-bill/src/QrBill.php on line 168` MyExample without PHP error reporting MyExample with php-error-Reporting |
`<?php
?>` |
The relevant information is this:
This means that something in your qr bill setup does not match the qr bill requirements. So in your code below try {
$output = new QrBill\PaymentPart\Output\FpdfOutput\FpdfOutput($qrBill, 'de', $fpdf);
$output
->setPrintable(false)
->getPaymentPart();
} catch (Sprain\SwissQrBill\Exception\InvalidQrBillDataException $e) {
foreach($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
exit; // of course exiting here is only useful while debugging
} You should then see where the problem ist. (PS: Your linked examples work for me without any errors. Deprecation messages are not errors, they are just helpers to let developers know where to adjust code to be compatible with future changes). |
I will close this now. Feel free to re-open if there is new information. |
Thanks for the hint with the try function. As expected, this results in the message:
Your answers is part of my question. Thank you very much for helping. Now the only open question is how I can make it that both QR-IBAN and CLASSIC-IBAN are processed in the same form. I will try it right away (and it works): You can test it here: $iban = str_replace( ' ', '', $_POST['qrForm-kreditor-iban'] );
$creditorInformation = QrBill\DataGroup\Element\CreditorInformation::create($iban);
if ($creditorInformation->containsQrIban()) {
// Add payment reference for QR-IBAN
// This is what you will need to identify incoming payments.
$referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate(
preg_replace('/[^0-9]/', '', $_POST['qrForm-kreditor-besr-id'] ), // You receive this number from your bank (BESR-ID). Unless your bank is PostFinance, in that case use NULL.
preg_replace('/[^0-9]/', '', $_POST['qrForm-kreditor-referenz'] ) // A number to match the payment with your internal data, e.g. an invoice number
);
$qrBill->setPaymentReference(
QrBill\DataGroup\Element\PaymentReference::create(
QrBill\DataGroup\Element\PaymentReference::TYPE_QR,
$referenceNumber
)
);
} else {
// Add payment reference CLASSIC-IBAN
// This is what you will need to identify incoming payments.
$qrBill->setPaymentReference(
QrBill\DataGroup\Element\PaymentReference::create(
QrBill\DataGroup\Element\PaymentReference::TYPE_SCOR,
QrBill\Reference\RfCreditorReferenceGenerator::generate( preg_replace( '/[^a-zA-Z0-9]/', '', $_POST['qrForm-kreditor-referenz'] ) )
)
);
} |
Yep, looks right to me 👍😊 |
First of all thank you for the great work!
When specifying a QR-IBAN in the CLASSIC-IBAN example, processing terminates without error message.
[1] Is there any way to check which type of IBAN (QR or Classic) it is and then make an
if-else
line break?[2] How can I provoke an error message in
$referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate();
I have not found a solution with
try { }
so far.Bei der Angabe eines QR-IBAN im CLASSIC-IBAN Beispiel bricht die Verarbeitung ohne Fehlermeldung ab.
[1] Kann mann irgendow überprüfen, ob um welchen Typ von IBAN (QR oder Classic) es sich handelt und dann eine
if-else
Verzweigung machen?
[2] Wie kann ich eine Fehlermeldung im Bereich
$referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate();
provozieren. Ich habe mittry{ }
bisher keine Lösung gefunden.The text was updated successfully, but these errors were encountered: