Skip to content

Commit c58751e

Browse files
committed
🐛 fixed pixKey length in the text (Issue #2)
1 parent c12977e commit c58751e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/github/mattnicee7/pixqrcode/pixqrcode/PixQRCode.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public String getAsText() {
3535
stringBuilder.append("");
3636

3737
// Merchant Account Information - PIX:
38-
final String merchantAccountInformation = "0014BR.GOV.BCB.PIX" + "01" + pixKey.length() + this.pixKey;
38+
final String merchantAccountInformation = "0014BR.GOV.BCB.PIX" + "01" +
39+
(pixKey.length() < 10 ? "0" + pixKey.length() : pixKey.length()) +
40+
this.pixKey;
41+
3942
stringBuilder.append("26")
4043
.append(merchantAccountInformation.length())
4144
.append(merchantAccountInformation);
@@ -60,7 +63,7 @@ public String getAsText() {
6063

6164
// Merchant Name:
6265
stringBuilder.append("59")
63-
.append(receiverFullName.length())
66+
.append(receiverFullName.length() < 10 ? "0" + receiverFullName.length() : receiverFullName.length())
6467
.append(receiverFullName);
6568

6669
// Merchant City:
@@ -76,7 +79,9 @@ public String getAsText() {
7679
"05" + (transactionIdentifier.length() < 10 ? "0" + transactionIdentifier.length() : transactionIdentifier.length()) + transactionIdentifier;
7780

7881
stringBuilder.append("62")
79-
.append(transactionIdentifierFinalString.length() < 10 ? "0" + transactionIdentifierFinalString.length() : transactionIdentifierFinalString.length())
82+
.append(
83+
transactionIdentifierFinalString.length() < 10 ? "0" + transactionIdentifierFinalString.length()
84+
: transactionIdentifierFinalString.length())
8085
.append(transactionIdentifierFinalString);
8186

8287
// Unreserved Templates:

0 commit comments

Comments
 (0)