Skip to content

Commit

Permalink
Merge pull request #50 from ellennugroho/master
Browse files Browse the repository at this point in the history
Added changelog, update docs, fix typo
  • Loading branch information
kevindavee authored Feb 5, 2020
2 parents 4169526 + e0e56c3 commit 6486dc0
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 3 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

## 2.0.0 - 2020-02-05

### Added

- Support for expire and get all Invoice
- Support for Batch Disbursements
- Support for create, get, update Fixed Virtual Account and get Fixed Virtual Account Payment
- Support for create and get charge for Cards
- Support for eWallets
- Support for Retail Outlets
- Support for Recurring Payments
- Support for Payouts

### Changed

- Class structure
- Request to HTTP Client now use Guzzle Client instead of cURL

### Removed

- Previous implementation are removed in this version, so the previous methods are deprecated
147 changes: 147 additions & 0 deletions MIGRATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Migrations

## v1.4.0 to v2.0.0

### Instantiate API Key

In the v1.4.0, secret API key is instantiated inside the config file. However in v2.0.0, secret API key is instantiated
with:

```php
Xendit::loadApiKey('secretKey');
```

or secret API key can be stored inside `.env` file and be instantiated with following:

```php
Xendit::loadApiKey();
```

### Calling methods

In v2.0.0, we restructured classes based on product, so it will impact on how the method is called.

#### Create Invoice

In v1.4.0, we used the following command to create an invoice:

```php
$external_id = 'demo_147580196270';
$payer_email = '[email protected]';
$description = 'Trip to Bali';
$amount = 32000;

$response = $xenditPHPClient->createInvoice($external_id, $amount, $payer_email, $description);
```

In v2.0.0, we will use this command to create an invoice:

```php
$params = ['external_id' => 'demo_147580196270',
'payer_email' => '[email protected]',
'description' => 'Trip to Bali',
'amount' => 32000
];

$response = \Xendit\Invoice::create($params);
```

#### Get Invoice

In v1.4.0, to get an invoice:

```php
$response = $xenditPHPClient->getInvoice($invoice_id);
```

In v2.0.0, to get an invoice:

```php
$response = \Xendit\Invoice::retrieve($id);
```

#### Create Disbursement

In v1.4.0, to create a disbursement:

```php
$external_id = 'disb-12345678';
$amount = 15000;
$bank_code = 'BCA';
$account_holder_name = 'Joe';
$account_number = '1234567890';

$response = $xenditPHPClient->createDisbursement($external_id, $amount, $bank_code, $account_holder_name, $account_number);
```

In v2.0.0, to create a disbursement:

```php
$params = [
'external_id'=> 'disb-12345678',
'amount'=> 15000,
'bank_code'=> 'BCA',
'account_holder_name'=> 'Joe',
'account_number'=> '1234567890',
'description'=>'Disbursement from Example'
];

$response = \Xendit\Disbursements::create($params);
```

#### Get Balance

In v1.4.0, to get current balance:

```php
$response = $xenditPHPClient->getBalance();
```

In v2.0.0, to get current balance:

```php
$response = \Xendit\Balance::getBalance('CASH');
```

#### Capture Credit Card Payment

In v1.4.0, to capture a credit card payment:

```php
$external_id = 'ext-id';
$token_id = 'token-id';
$amount = 100000;

$response = $xenditPHPClient->captureCreditCardPayment($external_id, $token_id, $amount);
```

In v2.0.0, to capture a credit card payment:

```php
$captureParams = ['amount' => 100000];

$response = \Xendit\Cards::capture($id, $captureParams);
```

#### Refund Credit Card Payment

In v1.4.0, to refund credit card payment:

```php
$id = 'id';
$amount = 20000;
$external_id = 'ext-id';

$response = $xenditPHPClient->issueCreditCardRefund($id, $amount, $external_id);
```

In v2.0.0, to refund credit card payment:

```php
$refundParams = [
'external_id' => 'ext-id',
'amount' => 20000
];

$response = \Xendit\Cards::createRefund($id, $refundParams);
```
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ composer require xendit/xendit-php-clients

or add it manually in your `composer.json` file.

### Update from v1.x to v2.0.0

To update xendit-php-clients with composer, use the following command:

```bash
composer update xendit/xendit-php-clients
```

## Usage

Configure package with your account's secret key obtained from [Xendit Dashboard](https://dashboard.xendit.co/settings/developers#api-keys).
Expand Down
6 changes: 3 additions & 3 deletions src/Xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Xendit

public static $libVersion;

const VERSION = "2.0.0";

/**
* ApiBase getter
*
Expand Down Expand Up @@ -102,9 +104,7 @@ public static function loadApiKey($apiKey = null)
public static function getLibVersion()
{
if (self::$libVersion === null) {
$content = file_get_contents('composer.json');
$content = json_decode($content, true);
self::$libVersion = $content['version'];
self::$libVersion = self::VERSION;
}
return self::$libVersion;
}
Expand Down

0 comments on commit 6486dc0

Please sign in to comment.