PHP code example of odenktools / php-bca

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

    

odenktools / php-bca example snippets


    $options = array(
        'scheme'        => 'https',
        'port'          => 443,
        'host'          => 'sandbox.bca.co.id',
        'timezone'      => 'Asia/Jakarta',
        'timeout'       => 30,
        'debug'         => true,
        'development'   => true
    );

    // Setting default timezone Anda
    \Bca\BcaHttp::setTimeZone('Asia/Jakarta');

    // ATAU

    // \Bca\BcaHttp::setTimeZone('Asia/Singapore');

    $corp_id = "BCAAPI2016";
    $client_key = "NILAI-CLIENT-KEY-ANDA";
    $client_secret = "NILAI-CLIENT-SECRET-ANDA";
    $apikey = "NILAI-APIKEY-ANDA";
    $secret = "SECRETKEY-ANDA";

    $bca = new \Bca\BcaHttp($corp_id, $client_key, $client_secret, $apikey, $secret);

    // ATAU

    $bca = new \Bca\BcaHttp($corp_id, $client_key, $client_secret, $apikey, $secret, $options);

    $options = array(
        'curl_options'  => array(
            CURLOPT_SSL_VERIFYHOST => 0,
            CURLOPT_SSLVERSION => 6,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_TIMEOUT => 60
        ),
        'scheme'        => 'https',
        'port'          => 443,
        'host'          => 'sandbox.bca.co.id',
        'timezone'      => 'Asia/Jakarta',
        'timeout'       => 30,
        'debug'         => true,
        'development'   => true
    );

    // Setting default timezone Anda
    \Bca\BcaHttp::setTimeZone('Asia/Jakarta');

    // ATAU

    // \Bca\BcaHttp::setTimeZone('Asia/Singapore');

    $corp_id = "BCAAPI2016";
    $client_key = "NILAI-CLIENT-KEY-ANDA";
    $client_secret = "NILAI-CLIENT-SECRET-ANDA";
    $apikey = "NILAI-APIKEY-ANDA";
    $secret = "SECRETKEY-ANDA";

    $bca = new \Bca\BcaHttp($corp_id, $client_key, $client_secret, $apikey, $secret, $options);

    $corp_id = "CORP_ID-ANDA";
    $client_key = "NILAI-CLIENT-KEY-ANDA";
    $client_secret = "NILAI-CLIENT-SECRET-ANDA";
    $apikey = "NILAI-APIKEY-ANDA";
    $secret = "SECRETKEY-ANDA";

    $bca = new \Bca\BcaHttp($corp_id, $client_key, $client_secret, $apikey, $secret);

    // Request Login dan dapatkan nilai OAUTH
    $response = $bca->httpAuth();

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    // Ini adalah nilai token yang dihasilkan saat login
    $token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

    //Nomor akun yang akan di ambil informasi saldonya, menggunakan ARRAY
    $arrayAccNumber = array('0201245680', '0063001004', '1111111111');

    $response = $bca->getBalanceInfo($token, $arrayAccNumber);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    // Ini adalah nilai token yang dihasilkan saat login
    $token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

    $amount = '50000.00';

    // Nilai akun bank anda
    $nomorakun = '0201245680';

    // Nilai akun bank yang akan ditransfer
    $nomordestinasi = '0201245681';

    // Nomor PO, silahkan sesuaikan
    $nomorPO = '12345/PO/2017';

    // Nomor Transaksi anda, Silahkan generate sesuai kebutuhan anda
    $nomorTransaksiID = '00000001';

    $remark1 = 'Transfer Test Using Odenktools BCA';

    $remark2 = 'Online Transfer Using Odenktools BCA';

    // value hanya support idr dan usd
    $mataUang = 'idr';

    $response = $bca->fundTransfers($token, 
                        $amount,
                        $nomorakun,
                        $nomordestinasi,
                        $nomorPO,
                        $remark1,
                        $remark2,
                        $nomorTransaksiID,
                        $mataUang);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    // Ini adalah nilai token yang dihasilkan saat login
    $token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

    // Nilai akun bank anda
    $nomorakun = '0201245680';

    // Tanggal start transaksi anda
    $startdate = '2016-08-29';

    // Tanggal akhir transaksi anda
    $enddate = '2016-09-01';

    $response = $bca->getAccountStatement($token, $nomorakun, $startdate, $enddate);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    //Tipe rate :  bn, e-rate, tt, tc
    $rateType = 'e-rate';

    $mataUang = 'usd';

    $response = $bca->getForexRate($token, $rateType, $mataUang);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    $latitude = '-6.1900718';

    $longitude = '106.797190';

    $totalAtmShow = '10';

    $radius = '20';

    $response = $bca->getAtmLocation($token, $latitude, $longitude, $totalAtmShow, $radius);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);

    // Ini adalah nilai token yang dihasilkan saat login
    $token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

    $response       = $bca->getDepositRate($token);

    // Cek hasil response berhasil atau tidak
    echo json_encode($response);


    $secret = "NILAI-SECRET-ANDA";

    // Ini adalah nilai token yang dihasilkan saat login
    $token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

    $uriSign = "GET:/general/info-bca/atm";

    // Format timestamp harus dalam ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSTZD)
    $isoTime = "2016-02-03T10:00:00.000+07:00";

    $bodyData = array();

    //nilai body anda disini
    $bodyData['a'] = "BLAAA-BLLLAA";
    $bodyData['b'] = "BLEHH-BLLLAA";

    //ketentuan BCA array harus disort terlebih dahulu
    ksort($bodyData);

    $authSignature = \Bca\BcaHttp::generateSign($uriSign, $token, $secret, $isoTime, $bodyData);

    echo $authSignature;

/va/payments?CompanyCode=&RequestID=
bash
composer 
bash
git remote add fork [email protected]:johndoe/php-bca.git