diff --git a/README.md b/README.md index 0129c68..9c79bf7 100644 --- a/README.md +++ b/README.md @@ -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 "payer_email@sample.com" "this is a description" "1234567" +``` + # Create Disbursement Example : # ``` cd src/ diff --git a/src/XenditPHPClient.php b/src/XenditPHPClient.php index 6c2cf18..4db6842 100644 --- a/src/XenditPHPClient.php +++ b/src/XenditPHPClient.php @@ -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(); @@ -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); diff --git a/src/examples/create_invoice_with_callback_virtual_account_id_example.php b/src/examples/create_invoice_with_callback_virtual_account_id_example.php new file mode 100644 index 0000000..2ad32b2 --- /dev/null +++ b/src/examples/create_invoice_with_callback_virtual_account_id_example.php @@ -0,0 +1,17 @@ +createInvoice($external_id, $amount, $payer_email, $description, $options); + print_r($response); +?>