Skip to content

Commit

Permalink
add migrate doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ellennugroho committed Feb 5, 2020
1 parent d26f72c commit e0e56c3
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

### Changed

- Class structure - now the implementation is not merged into one class but divided into each product class
- Class structure
- Request to HTTP Client now use Guzzle Client instead of cURL

### Removed
Expand Down
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);
```
4 changes: 1 addition & 3 deletions src/Xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,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 e0e56c3

Please sign in to comment.