Skip to content

Commit

Permalink
Merge pull request #167 from xendit/fix/addParamsExpireInvoice
Browse files Browse the repository at this point in the history
Fix/add params expire invoice
  • Loading branch information
xen-HendryZheng authored Dec 14, 2021
2 parents ec6e63d + 683c974 commit 2506ff0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,17 @@ var_dump(($getAllInvoice));
#### Expire Invoice

```php
\Xendit\Invoice::expireInvoice(string $id);
\Xendit\Invoice::expireInvoice(string $id, array $params);
```

Usage example:

```php
$id = 'invoice-id';
$expireInvoice = \Xendit\Invoice::expireInvoice($id);
$params = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
];
$expireInvoice = \Xendit\Invoice::expireInvoice($id, $params);
var_dump($expireInvoice);
```
### Paylater
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xendit/xendit-php",
"description": "PHP clients for Xendit API",
"version": "2.17.0",
"version": "2.17.1",
"license": "MIT",
"keywords": [
"xendit"
Expand Down
32 changes: 16 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/InvoiceExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
$getInvoice = \Xendit\Invoice::retrieve($id);
var_dump($getInvoice);

$expireInvoice = \Xendit\Invoice::expireInvoice($id);
$params = [
'for-user-id' => '<enter user id>'
];
$expireInvoice = \Xendit\Invoice::expireInvoice($id, $params);
var_dump($expireInvoice);

$retrieveAll = [
Expand Down
4 changes: 2 additions & 2 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public static function createReqParams()
* ]
* @throws Exceptions\ApiException
*/
public static function expireInvoice($id)
public static function expireInvoice($id, $params=[])
{
$url = '/invoices/' . $id . '/expire!';

return static::_request('POST', $url);
return static::_request('POST', $url, $params);
}
}

0 comments on commit 2506ff0

Please sign in to comment.