diff --git a/README.md b/README.md index a0f5b3f..1a15e1d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PixPhp -A PHP library for generating QR codes for PIX payments, including optional transaction descriptions. +A PHP library to generate static PIX codes, facilitating online payments with PIX copy and paste. ![PHP Version](https://img.shields.io/badge/php-%3E%3D8.2-brightgreen) ![License](https://img.shields.io/badge/license-MIT-blue) diff --git a/src/StaticPix.php b/src/StaticPix.php index e12d1f3..2332377 100644 --- a/src/StaticPix.php +++ b/src/StaticPix.php @@ -30,6 +30,12 @@ public static function generatePix($key, $idTx = '', $amount = 0.00, $descriptio { $result = "000201"; $result .= self::formatField("26", "0014br.gov.bcb.pix" . self::formatField("01", PixKey::formatKey($key))); + + // Description field (if provided) + if (!empty($description)) { + $result .= self::formatField("02", $description); + } + $result .= "52040000"; // Fixed code $result .= "5303986"; // Currency (Real) if ($amount > 0) { @@ -39,12 +45,7 @@ public static function generatePix($key, $idTx = '', $amount = 0.00, $descriptio $result .= "5901N"; // Name $result .= "6001C"; // City - // Description field (if provided) - if (!empty($description)) { - $result .= self::formatField("62", self::formatField("05", $idTx ?: '***') . self::formatField("50", $description)); - } else { - $result .= self::formatField("62", self::formatField("05", $idTx ?: '***')); - } + $result .= self::formatField("62", self::formatField("05", $idTx ?: '***')); $result .= "6304"; // Start of CRC16 $result .= self::calculateCRC16($result); // Add CRC16 at the end