PHP code example of chainplatform / pay

1. Go to this page and download the library: Download chainplatform/pay 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/ */

    

chainplatform / pay example snippets


use ChainPlatform\Pay\QRPay;
use ChainPlatform\Pay\BanksObject;

$qrPay = QRPay::initVietQR([
    'bankBin' => BanksObject::acb()->bin,
    'bankNumber' => '257678859',
]);

$content = $qrPay->build();

echo $content;
// 00020101021138530010A0000007270123000697041601092576788590208QRIBFTTA53037045802VN6304AE9F

$qrPay = QRPay::initVietQR([
    'bankBin' => BanksObject::mbbank()->bin,
    'bankNumber' => '88787627133',
    'amount' => '10000',
    'purpose' => 'Chuyen tien',
]);

$content = $qrPay->build();

echo $content;
// 00020101021238530010A0000007270123000697041601092576788590208QRIBFTTA53037045405100005802VN62150811Chuyen tien630453E6

use ChainPlatform\Pay\QRPay;
use ChainPlatform\Pay\BanksObject;

$accountNumber = '99MM24011M34875080';

$momoQR = QRPay::initVietQR([
    'bankBin' => BanksObject::banviet()->bin,
    'bankNumber' => $accountNumber,
]);

// Mã tham chiếu riêng của MoMo
$momoQR->additionalData->reference = 'MOMOW2W' . substr($accountNumber, 10);

// Trường ID 80 = 3 số cuối số điện thoại
$momoQR->setUnreservedField('80', '046');

echo $momoQR->build();

$accountNumber = '99ZP24009M07248267';

$zaloQR = QRPay::initVietQR([
    'bankBin' => BanksObject::banviet()->bin,
    'bankNumber' => $accountNumber,
]);

echo $zaloQR->build();

$qrPay = QRPay::initVNPayQR([
    'merchantId' => '0102154778',
    'merchantName' => 'TUGIACOMPANY',
    'store' => 'TU GIA COMPUTER',
    'terminal' => 'TUGIACO1',
]);

echo $qrPay->build();

$qrContent = '00020101021238530010A0000007270123000697041601092576788590208QRIBFTTA5303704540410005802VN62150811Chuyen tien6304BBB8';

$qrPay = new QRPay($qrContent);

$qrPay->isValid;                // true
$qrPay->provider->name;         // VIETQR
$qrPay->consumer->bankBin;      // 970416
$qrPay->consumer->bankNumber;   // 257678859
$qrPay->amount;                 // 1000
$qrPay->additionalData->purpose // Chuyen tien

$qrContent = '00020101021126280010A0000007750110010531314453037045408210900005802VN5910CELLPHONES62600312CPSHN ONLINE0517021908061613127850705ONLHN0810CellphoneS63047685';

$qrPay = new QRPay($qrContent);

$qrPay->isValid;                   // true
$qrPay->provider->name;            // VNPAY
$qrPay->merchant->merchantId;      // 0105313144
$qrPay->amount;                    // 21090000
$qrPay->additionalData->store;     // CPSHN ONLINE
$qrPay->additionalData->terminal;  // ONLHN
$qrPay->additionalData->purpose;   // CellphoneS
$qrPay->additionalData->reference; // 02190806161312785

use ChainPlatform\Pay\QRPay;

$qrPay = new QRPay($originalContent);

// Sửa thông tin
$qrPay->amount = '10000';
$qrPay->additionalData->purpose = 'Cam on nhe - thu vien tao ma thanh toan QRPay tren PHP';

// Build lại
$newQR = $qrPay->build();

// Output
/*
00020101021238550010A000000727012500069704220111887876271330208QRIBFTTA53037045405100005802VN62580854Cam on nhe - thu vien tao ma thanh toan QRPay tren PHP6304EC87
*/