@@ -64,14 +64,14 @@ |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | private function crc16($data) { |
| 67 | - $crc = 0xFFFF; |
|
| 68 | - for ($i = 0; $i < strlen($data); $i++) { |
|
| 69 | - $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF; |
|
| 70 | - $x ^= $x >> 4; |
|
| 71 | - $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF; |
|
| 72 | - } |
|
| 73 | - return $crc; |
|
| 74 | - } |
|
| 67 | + $crc = 0xFFFF; |
|
| 68 | + for ($i = 0; $i < strlen($data); $i++) { |
|
| 69 | + $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF; |
|
| 70 | + $x ^= $x >> 4; |
|
| 71 | + $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF; |
|
| 72 | + } |
|
| 73 | + return $crc; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | /* |
| 77 | 77 | * Returns CRC16 of a string as hexadecimal string |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use Endroid\QrCode\QrCode; |
| 6 | 6 | |
| 7 | 7 | |
| 8 | -class ScbQr{ |
|
| 8 | +class ScbQr { |
|
| 9 | 9 | |
| 10 | 10 | const RELEASE_VERSION_OF_QR = '000201'; |
| 11 | 11 | const INITIAL_METHOD_OF_QR = '010212'; |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | $command .= self::INITIAL_METHOD_OF_QR; |
| 28 | 28 | |
| 29 | 29 | # Reference Code |
| 30 | - $ref_01 = $this->f('02', $ref_1); |
|
| 31 | - $ref_02 = $this->f('03', $ref_2); |
|
| 30 | + $ref_01 = $this->f('02', $ref_1); |
|
| 31 | + $ref_02 = $this->f('03', $ref_2); |
|
| 32 | 32 | $ref_command = self::SCB_PAYMENT_CODE . $billerId . $ref_01 . $ref_02; |
| 33 | 33 | |
| 34 | - $command .= $this->f('30', $ref_command); |
|
| 34 | + $command .= $this->f('30', $ref_command); |
|
| 35 | 35 | |
| 36 | 36 | # สกุลเงินบาท |
| 37 | 37 | $command .= self::TRANSACTION_CURRENCY_THB; |
@@ -87,13 +87,13 @@ |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | private function crc16($data) { |
| 90 | - $crc = 0xFFFF; |
|
| 91 | - for ($i = 0; $i < strlen($data); $i++) { |
|
| 92 | - $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF; |
|
| 93 | - $x ^= $x >> 4; |
|
| 94 | - $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF; |
|
| 95 | - } |
|
| 96 | - return $crc; |
|
| 90 | + $crc = 0xFFFF; |
|
| 91 | + for ($i = 0; $i < strlen($data); $i++) { |
|
| 92 | + $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF; |
|
| 93 | + $x ^= $x >> 4; |
|
| 94 | + $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF; |
|
| 95 | + } |
|
| 96 | + return $crc; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /* |