From 788cc41507e4d91432009dcc1879222691d3e471 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Feb 2020 13:38:06 +0700 Subject: [PATCH 1/4] fix typo path in getLibVersion --- src/Xendit.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Xendit.php b/src/Xendit.php index 91f3dc1..1bd5acc 100644 --- a/src/Xendit.php +++ b/src/Xendit.php @@ -32,6 +32,8 @@ class Xendit public static $libVersion; + const VERSION = "2.0.0"; + /** * ApiBase getter * @@ -102,7 +104,7 @@ public static function loadApiKey($apiKey = null) public static function getLibVersion() { if (self::$libVersion === null) { - $content = file_get_contents('composer.json'); + $content = file_get_contents('./composer.json'); $content = json_decode($content, true); self::$libVersion = $content['version']; } From 40793d07263ae84570c0c8a70f492b23a6ee2d8e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Feb 2020 13:38:56 +0700 Subject: [PATCH 2/4] update docs on how to update version --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 54a563d..65a80c8 100644 --- a/README.md +++ b/README.md @@ -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). From 9c1fbf0aef0a82d447f0967fc750ff12b3cea76c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Feb 2020 13:39:22 +0700 Subject: [PATCH 3/4] add changelog --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d0266a3 --- /dev/null +++ b/CHANGELOG.md @@ -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 - now the implementation is not merged into one class but divided into each product class +- 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 \ No newline at end of file From e0e56c32f80ae2aaf3579f613460e4cde706b3f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Feb 2020 14:54:53 +0700 Subject: [PATCH 4/4] add migrate doc --- CHANGELOG.md | 2 +- MIGRATE.md | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ src/Xendit.php | 4 +- 3 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 MIGRATE.md diff --git a/CHANGELOG.md b/CHANGELOG.md index d0266a3..8b6b9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/MIGRATE.md b/MIGRATE.md new file mode 100644 index 0000000..0ea8d67 --- /dev/null +++ b/MIGRATE.md @@ -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 = 'sample_email@xendit.co'; +$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' => 'sample_email@xendit.co', + '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); +``` \ No newline at end of file diff --git a/src/Xendit.php b/src/Xendit.php index 1bd5acc..f32237c 100644 --- a/src/Xendit.php +++ b/src/Xendit.php @@ -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; }