Skip to content

Commit

Permalink
Merge pull request #19 from xendit/callback_virtual_account
Browse files Browse the repository at this point in the history
add empty validation in creating callback virtual account
  • Loading branch information
boxbag authored May 8, 2017
2 parents b919093 + 8769365 commit 44bd761
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ cd src/
php examples/create_callback_virtual_account_example.php "CUSTOM_ID_2" "BCA" "Rizky"
```

# Create Callback Virtual Account With Virtual Account Number Example : #
```
cd src/
php examples/create_callback_virtual_account_example.php "CUSTOM_ID_2" "BCA" "Rizky" 100
```

# GET Balance Example : #
```
cd src/
Expand Down
7 changes: 5 additions & 2 deletions src/XenditPHPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getVirtualAccountBanks () {
return $responseObject;
}

function createCallbackVirtualAccount ($external_id, $bank_code, $name, $virtual_account_number) {
function createCallbackVirtualAccount ($external_id, $bank_code, $name, $virtual_account_number = null) {
$curl = curl_init();

$headers = array();
Expand All @@ -102,7 +102,10 @@ function createCallbackVirtualAccount ($external_id, $bank_code, $name, $virtual
$data['external_id'] = $external_id;
$data['bank_code'] = $bank_code;
$data['name'] = $name;
$data['virtual_account_number'] = $virtual_account_number;

if (!empty($virtual_account_number)) {
$data['virtual_account_number'] = $virtual_account_number;
}

$payload = json_encode($data);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
require('config/xendit_php_client_config.php');
require('XenditPHPClient.php');

$options['secret_api_key'] = constant('SECRET_API_KEY');

$xenditPHPClient = new XenditClient\XenditPHPClient($options);

$external_id = $argv[1];
$bank_code = $argv[2];
$name = $argv[3];
$virtual_account_number = $argv[4];

$response = $xenditPHPClient->createCallbackVirtualAccount($external_id, $bank_code, $name, $virtual_account_number);
print_r($response);
?>

0 comments on commit 44bd761

Please sign in to comment.