Skip to content

Commit

Permalink
decode pix extras
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardokum committed Dec 5, 2023
1 parent d3ff880 commit 4f26539
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,10 @@ public static function decodePixCopiaECola($pixCopiaECola, $parent = null)
'type' => 'single',
'name' => 'Point of Initiation Method',
],
'04' => [
'type' => 'single',
'name' => 'Merchant Account Information – Cartões',
],
'26' => [
'type' => 'multiple',
'name' => 'Merchant Account Information',
Expand Down Expand Up @@ -1360,6 +1364,24 @@ public static function decodePixCopiaECola($pixCopiaECola, $parent = null)
],
],
],
'80' => [
'type' => 'multiple',
'name' => 'Unreserved Templates',
'multiples' => [
'00' => [
'type' => 'single',
'name' => 'Globally Unique Identifier',
],
'01' => [
'type' => 'single',
'name' => 'informação arbitrária do arranjo',
],
],
],
'63' => [
'type' => 'single',
'name' => 'CRC',
],
];

if ($parent && ! ($structures = Arr::get($structures, "$parent.multiples"))) {
Expand All @@ -1369,13 +1391,19 @@ public static function decodePixCopiaECola($pixCopiaECola, $parent = null)
$aPix = [];
$i = 0;
while ($i < strlen($pixCopiaECola)) {
$code = substr($pixCopiaECola, $i, 2);
$code = $codeSearch = substr($pixCopiaECola, $i, 2);
if ($code >= 26 && $code <= 51) {
$codeSearch = 26;
}
if ($code >= 80 && $code <= 99) {
$codeSearch = 80;
}
$i += 2;
$size = intval(substr($pixCopiaECola, $i, 2));
$i += 2;
if ($structure = Arr::get($structures, $code)) {
if ($structure = Arr::get($structures, $codeSearch)) {
if ($structure['type'] == 'multiple') {
$aPix["$code"] = self::decodePixCopiaECola(substr($pixCopiaECola, $i, $size), $code);
$aPix["$code"] = self::decodePixCopiaECola(substr($pixCopiaECola, $i, $size), $codeSearch);
} else {
$aPix["$code"] = substr($pixCopiaECola, $i, $size);
}
Expand Down

0 comments on commit 4f26539

Please sign in to comment.