PHP code example of ardhikaxx / qris-dynamic-gateway

1. Go to this page and download the library: Download ardhikaxx/qris-dynamic-gateway 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/ */

    

ardhikaxx / qris-dynamic-gateway example snippets


use Qris\DynamicGateway\QrisFacade as Qris;
use Qris\DynamicGateway\Exceptions\InvalidQrisException;

try {
    // Contoh string payload QRIS mentah
    $payload = "0002010102115405100005802ID5913MOCK MERCHANT6007JAKARTA6304...";
    
    // Parser akan mereturn DTO `QrisData` yang kaya fitur
    $qris = Qris::parse($payload);
    
    echo "Nama Merchant: " . $qris->getMerchantName(); // Output: MOCK MERCHANT
    echo "Kode Negara: " . $qris->getCountryCode();    // Output: ID
    echo "Nominal Tagihan: " . $qris->getTransactionAmount(); 
    echo "Apakah Dinamis?: " . ($qris->isDynamic() ? 'Ya' : 'Tidak');

} catch (InvalidQrisException $e) {
    // Exception akan terpanggil bila CRC16 salah, atau struktur TLV rusak
    echo "Error: " . $e->getMessage(); 
}

use Qris\DynamicGateway\QrisFacade as Qris;

// 1. QRIS Statis sumber dari toko Anda
$staticQris = "0002010102115802ID5913MOCK MERCHANT6007JAKARTA6304ABCD";

// 2. Buat QRIS Dinamis dengan nominal tagihan Rp 75.500
$dynamicQris = Qris::generateDynamic($staticQris, 75500);

// 3. (Opsional) Tambahkan biaya Tip/Pajak sebesar Rp 2.000 (Tag 55 & 56)
$dynamicWithTip = Qris::generateDynamic($staticQris, 75500, [
    'tip_indicator' => '02',
    'tip_fixed' => '2000'
]);

echo $dynamicWithTip;
bash
php artisan qris:analyze "0002010102115405100005802ID5913MOCK MERCHANT..."