Skip to content

Commit

Permalink
Merge pull request #24 from xendit/invoice_upgrade
Browse files Browse the repository at this point in the history
add callback virtual account id options when creating invoice
  • Loading branch information
albertlieyingadrian authored Jul 9, 2017
2 parents 165cd1a + 18d3b27 commit 3103164
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ php examples/create_invoice_example.php "CUSTOM_ID_0" 30000 "payer_email@sample
php examples/create_invoice_example.php [external_id] [amount] [payer_email] [description]
```

# Create Invoice With Callback Virtual Account ID Example : #

```
cd src/
php examples/create_invoice_with_callback_virtual_account_id_example.php "CUSTOM_ID_0" 30000 "[email protected]" "this is a description" "1234567"
```

# Create Disbursement Example : #
```
cd src/
Expand Down
6 changes: 5 additions & 1 deletion src/XenditPHPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function __construct ($options) {
$this->secret_api_key = $options['secret_api_key'];
}

function createInvoice ($external_id, $amount, $payer_email, $description) {
function createInvoice ($external_id, $amount, $payer_email, $description, $invoice_options = null) {
$curl = curl_init();

$headers = array();
Expand All @@ -21,6 +21,10 @@ function createInvoice ($external_id, $amount, $payer_email, $description) {
$data['payer_email'] = $payer_email;
$data['description'] = $description;

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

$payload = json_encode($data);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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];
$amount = $argv[2];
$payer_email = $argv[3];
$description = $argv[4];
$options['callback_virtual_account_id'] = $argv[5];

$response = $xenditPHPClient->createInvoice($external_id, $amount, $payer_email, $description, $options);
print_r($response);
?>

0 comments on commit 3103164

Please sign in to comment.