Skip to content

Commit

Permalink
Perbaikan Bug Multiple Account Balance
Browse files Browse the repository at this point in the history
  • Loading branch information
odenktools committed Sep 30, 2017
1 parent 40b0282 commit d8a789a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ Pastikan anda mendapatkan nilai ```TOKEN``` dan ```TOKEN``` tersebut masih berla
// Nilai token yang dihasilkan saat login
$token = "MvXPqa5bQs5U09Bbn8uejBE79BjI3NNCwXrtMnjdu52heeZmw9oXgB";

//Nomor akun yang akan di ambil informasi saldonya
//Saat ini hanya bisa satu nomor aku saja
$arrayAccNumber = array('0063001004');
//Nomor akun yang akan di ambil informasi saldonya, menggunakan ARRAY
$arrayAccNumber = array('0201245680', '0063001004', '1111111111');

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

Expand Down
32 changes: 27 additions & 5 deletions lib/Bca/BcaHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,20 @@ public function getBalanceInfo($oauth_token, $sourceAccountId = [])
$apikey = $this->settings['api_key'];
$secret = $this->settings['secret_key'];

$this->validateOauthKey($corp_id);
$this->validateCorpId($corp_id);
$this->validateOauthKey($apikey);
$this->validateOauthSecret($secret);
$this->validateArray($sourceAccountId);

$arraySplit = implode(",", $sourceAccountId);

ksort($sourceAccountId);

if(count($sourceAccountId) <= 20){
$arraySplit = implode(",", $sourceAccountId);
$arraySplit = urlencode($arraySplit);
}else{
throw new BcaHttpException('Maksimal Account Number ' . 20);
}

$uriSign = "GET:/banking/v2/corporates/$corp_id/accounts/$arraySplit";
$isoTime = self::generateIsoTime();
$authSignature = self::generateSign($uriSign, $oauth_token, $secret, $isoTime, null);
Expand Down Expand Up @@ -205,7 +212,7 @@ public function getAccountStatement($oauth_token, $sourceAccount, $startDate, $e

$secret = $this->settings['secret_key'];

$this->validateOauthKey($corp_id);
$this->validateCorpId($corp_id);
$this->validateOauthKey($apikey);
$this->validateOauthSecret($secret);

Expand Down Expand Up @@ -374,7 +381,7 @@ public function fundTransfers(
$apikey = $this->settings['api_key'];
$secret = $this->settings['secret_key'];

$this->validateOauthKey($corp_id);
$this->validateCorpId($corp_id);
$this->validateOauthKey($apikey);
$this->validateOauthSecret($secret);

Expand Down Expand Up @@ -490,6 +497,21 @@ public static function generateIsoTime()

return $ISO8601;
}

/**
* Validasi jika clientkey telah di-definsikan.
*
* @param string clientkey
*
* @return string
*/
private function validateCorpId($id)
{
if (!preg_match('/\A[-a-zA-Z0-9_=@,.;]+\z/', $id)) {
throw new BcaHttpException('Invalid CorpId' . $id);
}
}

/**
* Validasi jika clientkey telah di-definsikan.
*
Expand Down

0 comments on commit d8a789a

Please sign in to comment.