PHP code example of gudevindy / checkaccname

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

    

gudevindy / checkaccname example snippets



GuDevIndy\CheckAccName\Client;

$client = new Client('YOUR-BEARER-TOKEN');

$result = $client->inquiry(bankCode: '004', accountNo: '1234567890');

echo $result->beneficiaryName;     // "นาย สมชาย ใจดี"
echo $result->title;               // "นาย"
echo $result->firstName;           // "สมชาย"
echo $result->lastName;            // "ใจดี"

$r = $client->inquiry('004', '1234567890');

$r->beneficiaryName;        // "นาย สมชาย ใจดี"
$r->beneficiaryNoMasking;   // "xxx-x-x7890-x"
$r->title;                  // "นาย"
$r->firstName;              // "สมชาย"   (null ถ้า isCompany)
$r->lastName;               // "ใจดี"   (null ถ้า isCompany)
$r->isCompany;              // false
$r->companyName;            // null     (มีค่าเมื่อ isCompany=true)
$r->bankCode;               // "004"
$r->bankAbv;                // "KBANK"
$r->blacklisted;            // bool — ถูกรายงานเกิน threshold
$r->reportCount;            // int  — จำนวน reports approved
$r->lookupsLast24h;         // int  — จำนวน user ค้นหาบัญชีนี้ใน 24 ชม.
$r->suspicious;             // bool — lookupsLast24h ≥ threshold
$r->cached;                 // bool — server ตอบจาก cache หรือไม่

// ถ้าอยากเป็น array
$r->toArray();

use GuDevIndy\CheckAccName\Client;
use GuDevIndy\CheckAccName\Exception\{
    AuthException,
    RateLimitException,
    InquiryException,
    NetworkException,
    CheckAccNameException,
};

$client = new Client(getenv('TOKEN'));

try {
    $r = $client->inquiry('004', '1234567890');
    echo $r->beneficiaryName;
} catch (AuthException $e) {
    // 401/403 — token ไม่ถูกต้อง / หมดอายุ / ถูก revoke
} catch (RateLimitException $e) {
    // 429 — เกินโควต้ารายวัน
} catch (InquiryException $e) {
    // 400/422 — บัญชีไม่พบ, รูปแบบผิด
    echo "Error code: {$e->errorCode}";
} catch (NetworkException $e) {
    // cURL fail / 5xx
} catch (CheckAccNameException $e) {
    // catch-all (parent ของทั้งหมดข้างบน)
}
bash
export CHECKACCNAME_TOKEN="your-token"
php examples/inquiry.php