PHP code example of uocnv / baokim-payment

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

    

uocnv / baokim-payment example snippets


$arrayBanks = Uocnv\BaokimPayment\Clients\ATM::getBankList();

$transactionId = 'abc123';
$amount        = 110000;
$bankId        = 124; // $bankId = 0 nếu là hình thức QR
$referer       = 'http://example.com';
$email         = $user->use_email;
$phone         = $user->use_phone;
$dataRequest = Uocnv\BaokimPayment\Clients\ATM::request(
    transactionId: $transactionId,
    amount       : $amount,
    bankId       : $bankId,
    referer      : $referer,
    userEmail    : $email,
    userPhone    : $phone
);

$transactionId   = DB::table('money_mobile_cards')->insertGetID([]);
$amount          = 110000;
$pin             = '071608559897';
$serial          = '098353000029197';
$telecomOperator = Uocnv\BaokimPayment\Enums\TelecomOperator::VIETTEL;
$dataRequest     = Uocnv\BaokimPayment\Clients\MobileCard::request(
    transactionId  : $transactionId,
    amount         : $amount,
    pin            : $pin,
    serial         : $serial,
    telecomOperator: $telecomOperator
);

$webhookData  = $request->all();
$verifiedData = Uocnv\BaokimPayment\Clients\ATM::checkValidData($webhookData);

try {
    $vaClient = new Uocnv\BaokimPayment\Clients\VA('production');
    $data     = $vaClient->registerVirtualAccount(
        accName   : 'CONG THANH TOAN',
        orderId   : 'trans' . rand(1, 99) . time(),
        amountMax : 5000000,
        expireDate: Carbon::now()->addDay()->format('Y-m-d H:i:s')
    );
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}

try {
    $vaClient = new Uocnv\BaokimPayment\Clients\VA('production');
    $data     = $vaClient->updateVirtualAccount(
        accName   : 'CONG THANH TOAN',
        orderId   : 'trans' . rand(1, 99) . time(),
        amountMax : 5000000,
        expireDate: Carbon::now()->addDay()->format('Y-m-d H:i:s')
    );
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}

$vaClient      = new Uocnv\BaokimPayment\Clients\VA('production');
$webhookData   = $request->getContent();
$dataValidated = $vaClient->checkValidData($webhookData);

$disbursement = new Uocnv\BaokimPayment\Clients\Disbursement('production');
try {
    $data    = $disbursement->lookUpForBalance();
    $balance = $data['Available'];
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}

$disbursement = new Uocnv\BaokimPayment\Clients\Disbursement('production');
try {
    $referenceId = 'gd_123123';
    $data    = $disbursement->lookUpForTransferInfo($referenceId);
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}

$disbursement = new Uocnv\BaokimPayment\Clients\Disbursement('production');
try {
    $accNo   = '21110001400973';
    $bankNo  = 970437; // Get from Uocnv\BaokimPayment\Clients\Disbursement::BANK_TRANSFER_ASSISTANCE
    $data    = $disbursement->verifyCustomerInfo($accNo, $bankNo);
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}

$disbursement = new Uocnv\BaokimPayment\Clients\Disbursement('production');
$money        = 1000000;
$referenceId  = 'gd_123123';
$memo         = 'chuyen tien';
$accNo        = '21110001400973';
$bankNo       = 970437;
try {
    $response = $disbursement->transferMoney($money, $referenceId, $memo, $accNo, $bankNo);
} catch (GuzzleException|CollectionRequestException|SignFailedException) {
}