Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xendit/xendit-php
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-HendryZheng committed Oct 27, 2021
2 parents 870d0df + 0f8233a commit 92afb65
Show file tree
Hide file tree
Showing 4 changed files with 482 additions and 1 deletion.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ This library is the abstraction of Xendit API for access from applications writt
- [E-Wallets](#e-wallets)
- [Create E-Wallet Charge](#create-e-wallet-charge)
- [Get E-Wallet Charge Status](#get-e-wallet-charge-status)
- [Void E-Wallet Charge](#void-e-wallet-charge)
- [Refund E-Wallet Charge](#refund-e-wallet-charge)
- [Get Refund By ID](#get-refund-by-id)
- [List Refunds](#list-refunds)
- [Invoice](#invoice)
- [Create Invoice](#create-invoice)
- [Get Invoice](#get-invoice)
Expand Down Expand Up @@ -841,7 +845,71 @@ $eWalletStatusParam = [
$getEWalletChargeStatus = \Xendit\EWallets::getEWalletChargeStatus($charge_id, $eWalletStatusParam);
var_dump($getEWalletChargeStatus);
```
#### Void E-Wallet Charge

```php
\Xendit\EWallets::voidEwalletCharge(string $charge_id,array $params);
```

Usage example:

```php
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$voidEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$voidEwalletCharge = \Xendit\EWallets::voidEwalletCharge($charge_id, $voidEwalletChargeParam);
var_dump($voidEwalletCharge);
```
#### Refund E-Wallet Charge

```php
\Xendit\EWallets::refundEwalletCharge(string $charge_id,array $params);
```

Usage example:

```php
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$refundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$refundEwalletCharge = \Xendit\EWallets::refundEwalletCharge($charge_id, $refundEwalletChargeParam);
var_dump($refundEwalletCharge);
```
#### Get Refund By ID

```php
\Xendit\EWallets::getRefund(string $charge_id,string $refund_id, array $params);
```

Usage example:

```php
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$refund_id = 'ewr_532as23lew2321id';
$getRefundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$getRefundEwalletCharge = \Xendit\EWallets::getRefund($charge_id, $refund_id, $getRefundEwalletChargeParam);
var_dump($getRefundEwalletCharge);
```
#### List Refunds

```php
\Xendit\EWallets::listRefund(string $charge_id, array $params);
```

Usage example:

```php
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$listRefundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$listRefundEwalletCharge = \Xendit\EWallets::listRefund($charge_id, $getRefundEwalletChargeParam);
var_dump($listRefundEwalletCharge);
```
### Invoice

#### Create Invoice
Expand Down
34 changes: 34 additions & 0 deletions examples/EWalletsExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,37 @@
$walletChargeStatusParams
);
var_dump($getEWalletChargeStatus);

$eWalletChargeId = '<Ewallet Charge ID>';
$voidEwalletChargeParam = [];
$voidEwalletCharge = \Xendit\EWallets::voidEwalletCharge(
$eWalletChargeId,
$voidEwalletChargeParam
);
var_dump($voidEwalletCharge);

$eWalletChargeId = '<Ewallet Charge ID>';
$refundEwalletChargeParam = [];
$refundEwalletCharge = \Xendit\EWallets::refundEwalletCharge(
$eWalletChargeId,
$refundEwalletChargeParam
);
var_dump($refundEwalletCharge);

$eWalletChargeId = '<Ewallet Charge ID>';
$refundEwalletChargeId = '<EWallet Refund Charge ID>';
$getRefundEWalletParam = [];
$getRefundEWallet = \Xendit\EWallets::getRefund(
$eWalletChargeId,
$refundEwalletChargeId,
$getRefundEWalletParam
);
var_dump($getRefundEWallet);

$eWalletChargeId = '<Ewallet Charge ID>';
$listRefundParam = [];
$listRefund = \Xendit\EWallets::listRefund(
$eWalletChargeId,
$listRefundParam
);
var_dump($listRefund);
71 changes: 70 additions & 1 deletion src/EWallets.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function createEWalletCharge($params = [])
/**
* Get e-wallet charge status
*
* @param string $charge_id chargee ID
* @param string $charge_id charge ID
*
* @return array please check for responses parameters here
* https://developers.xendit.co/api-reference/?bash#get-ewallet-charge-status
Expand All @@ -128,4 +128,73 @@ public static function getEWalletChargeStatus($charge_id, $params=[])

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

/**
* Void eWallet Charge
*
* @param string $charge_id charge ID
*
* @return array please check for responses parameters here
* https://developers.xendit.co/api-reference/#void-ewallet-charge
* @throws Exceptions\ApiException
*/
public static function voidEwalletCharge($charge_id, $params=[])
{
$url = static::classUrl()
. '/charges/' . $charge_id.'/void';

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

/**
* Refund eWallet Charge
*
* @param string $charge_id charge ID
*
* @return array please check for responses parameters here
* https://developers.xendit.co/api-reference/#refund-ewallet-charge
* @throws Exceptions\ApiException
*/
public static function refundEwalletCharge($charge_id, $params=[])
{
$url = static::classUrl()
. '/charges/' . $charge_id.'/refunds';

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

/**
* Get eWallet Refund by Refund ID
*
* @param string $charge_id charge ID
* @param string $refund_id refund ID
*
* @return array please check for responses parameters here
* https://developers.xendit.co/api-reference/#refund-ewallet-charge
* @throws Exceptions\ApiException
*/
public static function getRefund($charge_id, $refund_id, $params=[])
{
$url = static::classUrl()
. '/charges/' . $charge_id.'/refunds/'.$refund_id;

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

/**
* Get eWallet Refund by Refund ID
*
* @param string $charge_id charge ID
*
* @return array please check for responses parameters here
* https://developers.xendit.co/api-reference/#refund-ewallet-charge
* @throws Exceptions\ApiException
*/
public static function listRefund($charge_id, $params=[])
{
$url = static::classUrl()
. '/charges/' . $charge_id.'/refunds/';

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

0 comments on commit 92afb65

Please sign in to comment.