PHP code example of helmab / bakong

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

    

helmab / bakong example snippets


use Helmab\Bakong\Facades\Bakong;

// Check transaction by MD5
$transaction = Bakong::checkTransactionByMd5('d60f3db96913029a2af979a1662c1e72');

$transaction->hash;
$transaction->fromAccountId;
$transaction->toAccountId;
$transaction->currency;
$transaction->amount;
$transaction->description;
$transaction->createdDateMs;
$transaction->acknowledgedDateMs;

$transaction = Bakong::checkTransactionByHash('dcd53430d3b3005d9cda36f1fe8dedc3714ccf18f886cf5d090d36fee67ef956');

use Helmab\Bakong\Enums\Currency;

$transaction = Bakong::checkTransactionByShortHash('8465d722', 1.0, Currency::USD);

$transaction = Bakong::checkTransactionByInstructionRef('00001234');

$transaction = Bakong::checkTransactionByExternalRef('DEV123456ZTH');

$exists = Bakong::checkBakongAccount('user@bank'); // true or false

use Helmab\Bakong\DTOs\DeeplinkSource;

$result = Bakong::generateDeeplink('0002010....');

// With source info
$source = new DeeplinkSource(
    appIconUrl: 'https://example.com/icon.png',
    appName: 'My App',
    appDeepLinkCallback: 'https://example.com/callback',
);

$result = Bakong::generateDeeplink('0002010....', $source);

$result->shortLink; // https://bakong.page.link/...

// By MD5 list
$items = Bakong::checkTransactionByMd5List([
    '0dbe08d3829a8b6b59844e51aa38a4e2',
    '7b0e5c36486d7155eb3ee94997fe9bfb',
]);

foreach ($items as $item) {
    $item->md5;       // MD5 hash
    $item->status;    // SUCCESS, NOT_FOUND, STATIC_QR
    $item->message;
    $item->data;      // Transaction or null
}

// By hash list
$items = Bakong::checkTransactionByHashList([
    'f0ae142842181535e678900bc5be1c3bd48d567ced77410a169fb672792968c8',
    '9036688e95cb3d1b621a9a989ebe64629d8c118654cfbc47f4d4991d72fc3b44',
]);

$token = Bakong::renewToken();

use Helmab\Bakong\Exceptions\TransactionNotFoundException;
use Helmab\Bakong\Exceptions\TransactionFailedException;
use Helmab\Bakong\Exceptions\AuthenticationException;
use Helmab\Bakong\Exceptions\BakongException;

try {
    $transaction = Bakong::checkTransactionByMd5('...');
} catch (TransactionNotFoundException $e) {
    // Transaction not found (errorCode: 1)
} catch (TransactionFailedException $e) {
    // Transaction failed (errorCode: 3)
} catch (AuthenticationException $e) {
    // Unauthorized (errorCode: 6)
} catch (BakongException $e) {
    // Other API errors
    $e->responseCode;
    $e->errorCode;
    $e->responseMessage;
}
bash
php artisan vendor:publish --tag=bakong-config