PHP code example of ahr-ahr / qris-dynamic

1. Go to this page and download the library: Download ahr-ahr/qris-dynamic library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahr-ahr / qris-dynamic example snippets


use AhrAhr\QRIS\QRIS;

$qris = QRIS::fromImage(
    'images/sample-qris.png'
);

$payload = $qris
    ->amount(10000)
    ->generate();

echo $payload;



hrAhr\QRIS\QRIS;

$qris = QRIS::fromImage(
    'images/sample-qris.png'
);

$payload = $qris
    ->amount(25000)
    ->generate();

echo $payload;



use AhrAhr\QRIS\Decoder\QRImageDecoder;

$result = QRImageDecoder::decode(
    'images/sample-qris.png'
);

echo $result->payload;



use AhrAhr\QRIS\Parser\TLVParser;

$nodes = TLVParser::parse($payload);

foreach ($nodes as $node) {

    echo $node->tag . PHP_EOL;
    echo $node->value . PHP_EOL;
}

use AhrAhr\QRIS\Parser\PayloadValidator;

$isValid = PayloadValidator::validate(
    $payload
);

var_dump($isValid);

use AhrAhr\QRIS\Exceptions\QRISException;
use AhrAhr\QRIS\Parser\PayloadValidator;

try {

    PayloadValidator::validateOrFail(
        $payload
    );

} catch (QRISException $e) {

    echo $e->getMessage();
}

$qris = QRIS::fromImage(
    'images/sample-qris.png'
);

$generated = $qris
    ->amount(10000)
    ->generate();
txt
[00] Payload Format Indicator
[01] Point of Initiation Method

[26] Merchant Account Information
  [00] Globally Unique Identifier
  [01] Merchant ID

[52] Merchant Category Code
[53] Transaction Currency
[54] Transaction Amount
[59] Merchant Name
[63] CRC
txt
[00] Payload Format Indicator
[01] Point of Initiation Method

[26] Merchant Account Information
  [00] Globally Unique Identifier
  [01] Merchant ID
  [03] Merchant Category

[52] Merchant Category Code
[53] Transaction Currency
[54] Transaction Amount
[58] Country Code
[59] Merchant Name
[60] Merchant City
[63] CRC