Skip to content

Commit

Permalink
⚡ bump guzzle version updated to 7 and updated README.md
Browse files Browse the repository at this point in the history
Signed-off-by: satz <sathish.thi@gmail.om>
  • Loading branch information
ssatz authored and satz committed Jul 10, 2020
1 parent 4a117dc commit 65010b5
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 10 deletions.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Total Downloads](https://img.shields.io/packagist/dt/optimoapps/razorpay-x.svg?style=flat-square)](https://packagist.org/packages/optimoapps/razorpay-x)
![run-tests](https://github.com/OptimoApps/razorpay-x/workflows/run-tests/badge.svg)
![Check & fix styling](https://github.com/OptimoApps/razorpay-x/workflows/Check%20&%20fix%20styling/badge.svg)
<a href="/OptimoApps/razorpay-x/blob/master/LICENSE.md"><img alt="License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>

RazorPay X Laravel Package. Supports JsonMapper

Expand Down Expand Up @@ -45,6 +46,69 @@ composer require optimoapps/razorpay-x
$payment->purpose = 'payout';
RazorPayX::payment()->create($account);

/* To fetch Account */
$account = new Account();
$account->account_type = AccountTypeEnum::BANK_ACCOUNT;
RazorPayX::account()->fetch($account);

/* result AccountCollection */

OptimoApps\RazorPayX\Entity\AccountCollection {#7246
+entity: "collection"
+count: 3
+items: array:3 [
0 => OptimoApps\RazorPayX\Entity\Account {#8386
+id: "fa_F41TFrtuUZDim2"
+entity: "fund_account"
+contact_id: "cont_F0Rb5C4ZpfaTAV"
+account_type: "bank_account"
+bank_account: OptimoApps\RazorPayX\Entity\Bank {#9582
+name: "Gaurav Kumar"
+ifsc: "HDFC0000053"
+account_number: "765432123456789"
+bank_name: "HDFC Bank"
}
+vpa: null
+active: true
+batch_id: ""
+created_at: 1592469241
}
1 => OptimoApps\RazorPayX\Entity\Account {#8369
+id: "fa_F0RsxScNwK4C0t"
+entity: "fund_account"
+contact_id: "cont_F0Rb5C4ZpfaTAV"
+account_type: "bank_account"
+bank_account: OptimoApps\RazorPayX\Entity\Bank {#11794
+name: "sathish kumar"
+ifsc: "HDFC0000053"
+account_number: "765432123456789"
+bank_name: "HDFC Bank"
}
+vpa: null
+active: true
+batch_id: ""
+created_at: 1591688903
}
2 => OptimoApps\RazorPayX\Entity\Account {#9580
+id: "fa_EzFCyMGCEwTgmS"
+entity: "fund_account"
+contact_id: "cont_EyrHb3f1S0axBg"
+account_type: "bank_account"
+bank_account: OptimoApps\RazorPayX\Entity\Bank {#13996
+name: "Gaurav Kumar"
+ifsc: "HDFC0000053"
+account_number: "765432123456789"
+bank_name: "HDFC Bank"
}
+vpa: null
+active: true
+batch_id: ""
+created_at: 1591425919
}
]
}


```

### Testing
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"php": "^7.4",
"guzzlehttp/guzzle": "^6.5",
"guzzlehttp/guzzle": "^7.0",
"illuminate/support": "^6.0|^7.0",
"json-mapper/json-mapper": "^1.1",
"ext-json": "*"
Expand Down
9 changes: 5 additions & 4 deletions src/Contracts/PaymentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use OptimoApps\RazorPayX\Entity\Payment;
use OptimoApps\RazorPayX\Entity\PaymentCollection;
use OptimoApps\RazorPayX\Exceptions\RazorPayException;
use OptimoApps\RazorPayX\Http;

/**
Expand All @@ -29,7 +30,7 @@ class PaymentManager extends Http
* @see https://razorpay.com/docs/razorpayx/api/payouts/#create-a-payout
* @param Payment $payment
* @return Payment
* @throws \OptimoApps\RazorPayX\Exceptions\RazorPayException
* @throws RazorPayException
*/
public function create(Payment $payment): Payment
{
Expand All @@ -46,7 +47,7 @@ public function create(Payment $payment): Payment
* @see https://razorpay.com/docs/razorpayx/api/payouts/#fetch-all-payouts
* @param Payment $payment
* @return PaymentCollection
* @throws \OptimoApps\RazorPayX\Exceptions\RazorPayException
* @throws RazorPayException
*/
public function fetch(Payment $payment): PaymentCollection
{
Expand All @@ -63,7 +64,7 @@ public function fetch(Payment $payment): PaymentCollection
* @see https://razorpay.com/docs/razorpayx/api/payouts/#fetch-a-payout-by-id
* @param string $id
* @return Payment
* @throws \OptimoApps\RazorPayX\Exceptions\RazorPayException
* @throws RazorPayException
*/
public function find(string $id): Payment
{
Expand All @@ -80,7 +81,7 @@ public function find(string $id): Payment
* @see https://razorpay.com/docs/razorpayx/api/payouts/#cancel-a-queued-payout
* @param string $id
* @return Payment
* @throws \OptimoApps\RazorPayX\Exceptions\RazorPayException
* @throws RazorPayException
*/
public function cancel(string $id): Payment
{
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/TransactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TransactionManager extends Http
* @link https://razorpay.com/docs/razorpayx/api/transactions/#fetch-all-transactions
* @param Transaction $transaction
* @return TransactionCollection
* @throws RazorPayException
*/
public function fetch(Transaction $transaction): TransactionCollection
{
Expand Down
11 changes: 10 additions & 1 deletion src/Exceptions/InvalidConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
* * * Copyright (C) OPTIMO TECHNOLOGIES - All Rights Reserved
* * * Unauthorized copying of this file, via any medium is strictly prohibited
* * * Proprietary and confidential
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >.
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >
* *
*
*/
declare(strict_types=1);

namespace OptimoApps\RazorPayX\Exceptions;

/**
* Class InvalidConfigException
* @package OptimoApps\RazorPayX\Exceptions
*/
class InvalidConfigException extends \Exception
{
/**
* @return InvalidConfigException
*/
public static function keyNotSpecified(): InvalidConfigException
{
return new static('There was a missing key in config file');
Expand Down
19 changes: 18 additions & 1 deletion src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* * * Copyright (C) OPTIMO TECHNOLOGIES - All Rights Reserved
* * * Unauthorized copying of this file, via any medium is strictly prohibited
* * * Proprietary and confidential
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >.
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >
* *
*
*/

namespace OptimoApps\RazorPayX;
Expand All @@ -23,8 +25,14 @@
*/
abstract class Http
{
/**
* @var Client
*/
protected Client $client;

/**
* @var JsonMapperInterface
*/
protected JsonMapperInterface $jsonMapper;

/**
Expand All @@ -37,6 +45,9 @@ public function __construct()
}

/**
* @param string $endPoint
* @param array $queryParams
* @return StreamInterface
* @throws RazorPayException
*/
protected function get(string $endPoint, array $queryParams = []): StreamInterface
Expand All @@ -53,6 +64,9 @@ protected function get(string $endPoint, array $queryParams = []): StreamInterfa
}

/**
* @param string $endPoint
* @param array $params
* @return StreamInterface
* @throws RazorPayException
*/
protected function post(string $endPoint, array $params): StreamInterface
Expand All @@ -69,6 +83,9 @@ protected function post(string $endPoint, array $params): StreamInterface
}

/**
* @param string $endPoint
* @param array $params
* @return StreamInterface
* @throws RazorPayException
*/
protected function patch(string $endPoint, array $params): StreamInterface
Expand Down
32 changes: 31 additions & 1 deletion src/RazorPayX.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* * * Copyright (C) OPTIMO TECHNOLOGIES - All Rights Reserved
* * * Unauthorized copying of this file, via any medium is strictly prohibited
* * * Proprietary and confidential
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >.
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >
* *
*
*/

namespace OptimoApps\RazorPayX;
Expand All @@ -19,16 +21,32 @@
*/
class RazorPayX
{
/**
* @var ContactManager
*/
protected ContactManager $contactManager;

/**
* @var AccountManager
*/
protected AccountManager $accountManager;

/**
* @var PaymentManager
*/
protected PaymentManager $paymentManager;

/**
* @var TransactionManager
*/
protected TransactionManager $transactionManager;

/**
* RazorPayX constructor.
* @param ContactManager $contactManager
* @param AccountManager $accountManager
* @param PaymentManager $paymentManager
* @param TransactionManager $transactionManager
*/
public function __construct(
ContactManager $contactManager,
Expand All @@ -43,21 +61,33 @@ public function __construct(
$this->transactionManager = $transactionManager;
}

/**
* @return ContactManager
*/
public function contact(): ContactManager
{
return $this->contactManager;
}

/**
* @return AccountManager
*/
public function account(): AccountManager
{
return $this->accountManager;
}

/**
* @return PaymentManager
*/
public function payment(): PaymentManager
{
return $this->paymentManager;
}

/**
* @return TransactionManager
*/
public function transaction(): TransactionManager
{
return $this->transactionManager;
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* * * Copyright (C) OPTIMO TECHNOLOGIES - All Rights Reserved
* * * Unauthorized copying of this file, via any medium is strictly prohibited
* * * Proprietary and confidential
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >.
* * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>ManiKandan<smanikandanit@gmail.com >
* *
*
*/

namespace OptimoApps\RazorPayX\Tests\Unit;
Expand Down Expand Up @@ -66,7 +68,7 @@ public function testCanFetchAccount(): void
$this->assertIsObject($response);
$this->assertIsArray($response->items);
$this->assertInstanceOf(Account::class, $response->items[0]);
$this->assertEquals(2, $response->count);
$this->assertEquals(3, $response->count);
}

/*
Expand Down

0 comments on commit 65010b5

Please sign in to comment.