picqer / php-barcode-generator

Barcode generator in PHP that is easy to use, non-bloated and framework independent.
GNU Lesser General Public License v3.0
1.66k stars 400 forks source link

Added Febraban Type #168

Open devdiogenes opened 2 years ago

devdiogenes commented 2 years ago

"Boleto" is the one of the most used payment methods in Brazil.

Febraban is the type of barcode used in boletos. It's is basically a interleaved of 2:5, but the digits order is different, then I ajusted to generate barcode in that order.

boleto

casperbakker commented 2 years ago

@diogenes-souza-dev Would love to add this. Please add some basic tests for this barcode type and I will merge it.

devdiogenes commented 2 years ago

Ok, I will do it soon

devdiogenes commented 2 years ago

A boleto has a code and a barcode. The barcode has a differente value of the code. Let's suppose that someone wants to develop a new document that contains the barcode of a boleto, typing only the code.

For this example, I generated a R$ 200,00 document.

That is the code: 07797.77705 11661.514114 78006.780429 1 92180000020000

That is the barcode: image And that is the value of barcode: 07791921800000200007777011661514117800678042

As you can see, the barcode value is very different of the code, It remove spaces, dots and some numbers, and changes the order of the numbers.

Then I will simulate that someone wants to generate this barcode, by only typing the code:

image

That is the result:

image

After trying to pay it using the barcode I generated, that was the result of the digital bank:

image

As you can see, I can pay sussessfully a boleto barcode that I generate only using the number of the boleto.

casperbakker commented 7 months ago

I am sorry, but the code itself does not have unit tests for this type. Please add tests like the ones in https://github.com/picqer/php-barcode-generator/tree/main/tests, at least you need a verified file for this type so it will be automatically test. That way we know for sure that it will keep working in the future.

epcgrs commented 7 months ago

Ok of course, I'll try to contribute to this PR then and add the unit tests when I get a little time