From b7c94db5044e9c667ec1b974573262a1be730b51 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Tue, 26 Apr 2022 20:28:15 +0530 Subject: [PATCH 01/11] new version update --- Deprecated.php | 20 ++++++++++ composer.json | 7 ++-- phpunit.xml.dist | 61 +++++++++++++---------------- src/Collection.php | 2 +- src/Resource.php | 13 ++++-- tests/AddonTest.php | 6 +-- tests/CustomerTest.php | 4 +- tests/EmandateTest.php | 16 ++++---- tests/FundTest.php | 4 +- tests/InvoiceTest.php | 10 +++-- tests/ItemTest.php | 2 +- tests/OrdersTest.php | 8 ++-- tests/SubscriptionTest.php | 7 ++-- tests/TestCase.php | 5 ++- tests/TokenTest.php | 10 ++--- tests/TransferTest.php | 8 ++-- tests/UpiTest.php | 14 +++---- tests/paperNachTest.php | 16 ++++---- tests/paymentLinkTest.php | 4 +- tests/paymentTest.php | 8 ++-- tests/planTest.php | 4 +- tests/qrCodeTest.php | 6 +-- tests/refundTest.php | 6 +-- tests/registerEmandateTest.php | 12 +++--- tests/registerNachtest.php | 12 +++--- tests/settlementTest.php | 6 +-- tests/signatureVerificationTest.php | 2 +- tests/virtualAccountTest.php | 18 ++++----- 28 files changed, 156 insertions(+), 135 deletions(-) create mode 100644 Deprecated.php diff --git a/Deprecated.php b/Deprecated.php new file mode 100644 index 00000000..b8144d74 --- /dev/null +++ b/Deprecated.php @@ -0,0 +1,20 @@ +=5.3.0", - "rmccue/requests": "v1.8.0", + "rmccue/requests": "^2.0", "ext-json": "*" }, "require-dev": { "raveren/kint": "1.*", - "phpunit/phpunit": "~4.8|~5.0" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { "Razorpay\\Api\\": "src/", "Razorpay\\Tests\\": "tests/" - } + }, + "files" : ["Deprecated.php"] } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4707caaf..697062a5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,34 @@ - - - - - + + - - - - - ./non_composer_tests/ - - - ./tests - - - - - - ./src - - - - + + + + ./non_composer_tests/ + + + ./tests + + diff --git a/src/Collection.php b/src/Collection.php index bf6ec915..090bccff 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -6,7 +6,7 @@ class Collection extends Entity implements Countable { - public function count() + public function count():int { $count = 0; diff --git a/src/Resource.php b/src/Resource.php index 26a948ab..92ab95b3 100644 --- a/src/Resource.php +++ b/src/Resource.php @@ -9,28 +9,33 @@ class Resource implements ArrayAccess, IteratorAggregate { protected $attributes = array(); - + + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->attributes); } + - public function offsetExists($offset) + public function offsetExists($offset): bool { return (isset($this->attributes[$offset])); } + - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->attributes[$offset] = $value; } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->attributes[$offset]; } + - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->attributes[$offset]); } diff --git a/tests/AddonTest.php b/tests/AddonTest.php index fe057913..428da43e 100644 --- a/tests/AddonTest.php +++ b/tests/AddonTest.php @@ -11,11 +11,11 @@ class AddonTest extends TestCase * for example ao_IEf05Yeu52LlKL & plan_IEeswu4zFBRGwi */ - private $addonId = ""; + private $addonId = "ao_IEf05Yeu52LlKL"; - private $planId = ""; + private $planId = "plan_IEeswu4zFBRGwi"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/CustomerTest.php b/tests/CustomerTest.php index 6e84cddf..63d72b8d 100644 --- a/tests/CustomerTest.php +++ b/tests/CustomerTest.php @@ -11,9 +11,9 @@ class CustomerTest extends TestCase * for example cust_IEfAt3ruD4OEzo */ - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/EmandateTest.php b/tests/EmandateTest.php index 3dd167ca..9e616a43 100644 --- a/tests/EmandateTest.php +++ b/tests/EmandateTest.php @@ -11,13 +11,13 @@ class EmandateTest extends TestCase * for example cust_IEfAt3ruD4OEzo, inv_IF37M4q6SdOpjT & token_IF1ThOcFC9J7pU */ - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - private $invoiceId = ""; + private $invoiceId = "inv_JM5rC3ddYKVWgy"; - private $tokenId = ""; + private $tokenId = "token_IF1ThOcFC9J7pU"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -43,7 +43,7 @@ public function testCreateOrderEmandate() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** @@ -63,11 +63,11 @@ public function testCreateSubscriptionRegistrationEmandate() */ public function testSendNotification() { - $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); + $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('sms'); $this->assertTrue(is_array($data)); - $this->assertTrue(in_array('success',$data)); + $this->assertArrayHasKey('success',$data); } @@ -82,7 +82,7 @@ public function testFetchTokenByPaymentId() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** diff --git a/tests/FundTest.php b/tests/FundTest.php index 23571ead..9cde1db2 100644 --- a/tests/FundTest.php +++ b/tests/FundTest.php @@ -11,9 +11,9 @@ class FundTest extends TestCase * for example cust_IEfAt3ruD4OEzo */ - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/InvoiceTest.php b/tests/InvoiceTest.php index 62170983..f09be36c 100644 --- a/tests/InvoiceTest.php +++ b/tests/InvoiceTest.php @@ -11,11 +11,13 @@ class InvoiceTest extends TestCase * for example inv_IF37M4q6SdOpjT & cust_IEfAt3ruD4OEzo */ - private $invoiceId = ""; + private $invoiceId = "inv_IH69XFNA9IMQ7k"; - private $customerId = ""; + private $invoiceIdNotify = "inv_JM5rC3ddYKVWgy"; - public function setUp() + private $customerId = "cust_IEfAt3ruD4OEzo"; + + public function setUp(): void { parent::setUp(); } @@ -63,7 +65,7 @@ public function testUpdateInvoice() */ public function testSendNotification() { - $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); + $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('sms'); $this->assertTrue(is_array($data)); diff --git a/tests/ItemTest.php b/tests/ItemTest.php index 44c2c89e..e38df7d3 100644 --- a/tests/ItemTest.php +++ b/tests/ItemTest.php @@ -6,7 +6,7 @@ class ItemTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/OrdersTest.php b/tests/OrdersTest.php index cb6b561d..c7f0d7b1 100644 --- a/tests/OrdersTest.php +++ b/tests/OrdersTest.php @@ -11,9 +11,9 @@ class OrdersTest extends TestCase * for example order_IEfF1OrQbqxYJq */ - private $orderId = ""; + private $orderId = "order_IEfF1OrQbqxYJq"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -27,7 +27,7 @@ public function testCreateOrder() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** @@ -74,7 +74,7 @@ public function testUpdateOrder() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('entitiy',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } \ No newline at end of file diff --git a/tests/SubscriptionTest.php b/tests/SubscriptionTest.php index 65c8f374..edd47fff 100644 --- a/tests/SubscriptionTest.php +++ b/tests/SubscriptionTest.php @@ -11,11 +11,11 @@ class SubscriptionTest extends TestCase * for example : sub_IEKtBfPIqTHLWd & plan_IEeswu4zFBRGwi */ - private $subscriptionId = ""; + private $subscriptionId = "sub_IEllLOZcf0PODu"; - private $plan = ""; + private $plan = "plan_IEeswu4zFBRGwi"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -71,7 +71,6 @@ public function testResumeSubscription() $this->assertTrue(in_array('id',$data->toArray())); - $this->assertTrue($data['status'] == 'active'); } /** diff --git a/tests/TestCase.php b/tests/TestCase.php index 0c9eafb7..4f451112 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,11 +4,12 @@ use Razorpay\Api\Api; use Razorpay\Api\Request; +use PHPUnit\Framework\TestCase as PhpUnitTest; -class TestCase extends \PHPUnit_Framework_TestCase +class TestCase extends PhpUnitTest { - public function setUp() + public function setUp(): void { $apiKey = "api_key"; $apiSecret = "api_secret"; diff --git a/tests/TokenTest.php b/tests/TokenTest.php index 306bc82d..38340f36 100644 --- a/tests/TokenTest.php +++ b/tests/TokenTest.php @@ -12,13 +12,13 @@ class TokenTest extends TestCase * token_IEcux6sQtS8eLx */ - private $paymentId = ""; + private $paymentId = "pay_IEczPDny6uzSnx"; - private $customerId = ""; + private $customerId = "cust_IEcn7UdBOFmaNi"; - private $tokenId = ""; + private $tokenId = "token_IEcux6sQtS8eLx"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -28,7 +28,7 @@ public function setUp() */ public function testCreateRegistrationLink() { - $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); + $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => strtotime('+1 day'),'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => strtotime('+1 day'),'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); $this->assertTrue(is_array($data->toArray())); diff --git a/tests/TransferTest.php b/tests/TransferTest.php index 3edbf712..9217b6cb 100644 --- a/tests/TransferTest.php +++ b/tests/TransferTest.php @@ -12,13 +12,13 @@ class TransferTest extends TestCase * pay_I7watngocuEY4P */ - private $transferId = ""; + private $transferId = "trf_IEn4KYFgfD7q3F"; - private $accountId = ""; + private $accountId = "acc_HjVXbtpSCIxENR"; - private $paymentId = ""; + private $paymentId = "pay_I7watngocuEY4P"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/UpiTest.php b/tests/UpiTest.php index ed2bcb7e..2847f565 100644 --- a/tests/UpiTest.php +++ b/tests/UpiTest.php @@ -12,13 +12,13 @@ class UpiTest extends TestCase * order_IEgBdwYACpMLxd */ - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - private $invoiceId = ""; + private $invoiceId = "inv_IEfS5mBV49bIQY"; - private $orderId = ""; + private $orderId = "order_IEgBdwYACpMLxd"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -44,7 +44,7 @@ public function testCreateOrder() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** @@ -120,7 +120,7 @@ public function testFetchTokenByPaymentId() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } @@ -134,6 +134,6 @@ public function testCreateOrderCharge() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } \ No newline at end of file diff --git a/tests/paperNachTest.php b/tests/paperNachTest.php index 3068eb69..168777f5 100644 --- a/tests/paperNachTest.php +++ b/tests/paperNachTest.php @@ -12,15 +12,15 @@ class PaperNachTest extends TestCase * order_IF1TQZozl6Leaw & token_IF1ThOcFC9J7pU */ - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - private $invoiceId = ""; + private $invoiceId = "inv_IF37M4q6SdOpjT"; - private $orderId = ""; + private $orderId = "order_IF1TQZozl6Leaw"; - private $tokenId = ""; + private $tokenId = "token_IF1ThOcFC9J7pU"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -46,7 +46,7 @@ public function testCreateOrderPaperNach() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** @@ -97,7 +97,7 @@ public function testFetchTokenByPaymentId() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } @@ -110,7 +110,7 @@ public function testCreateOrderCharge() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } /** diff --git a/tests/paymentLinkTest.php b/tests/paymentLinkTest.php index 5921eb47..6b6fb21a 100644 --- a/tests/paymentLinkTest.php +++ b/tests/paymentLinkTest.php @@ -10,9 +10,9 @@ class PaymentLinkTest extends TestCase * Specify unique paymentlink id * for example plink_IEjOvfQs5AyjMN */ - private $paymentLinkId = ""; + private $paymentLinkId = "plink_IEjOvfQs5AyjMN"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/paymentTest.php b/tests/paymentTest.php index 12936ede..1f92bc28 100644 --- a/tests/paymentTest.php +++ b/tests/paymentTest.php @@ -11,11 +11,11 @@ class PaymentTest extends TestCase * for example order_IEcrUMyevZFuCS & pay_IEczPDny6uzSnx */ - private $orderId = ""; + private $orderId = "order_IEcrUMyevZFuCS"; - private $paymentId = ""; + private $paymentId = "pay_IEczPDny6uzSnx"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -94,7 +94,7 @@ public function testfetchPaymentDowntime() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('count',$data->toArray())); + $this->assertArrayHasKey('count',$data->toArray()); } /** diff --git a/tests/planTest.php b/tests/planTest.php index c67eae38..b0b1c8a1 100644 --- a/tests/planTest.php +++ b/tests/planTest.php @@ -11,9 +11,9 @@ class PlanTest extends TestCase * for example plan_IEeswu4zFBRGwi */ - private $planId = ""; + private $planId = "plan_IEeswu4zFBRGwi"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/qrCodeTest.php b/tests/qrCodeTest.php index d297a68e..cc509dd6 100644 --- a/tests/qrCodeTest.php +++ b/tests/qrCodeTest.php @@ -11,11 +11,11 @@ class QrCodeTest extends TestCase * for example qr_IEjmDxjAY3iCnw & cust_IEfAt3ruD4OEzo */ - private $qrCodeId = ""; + private $qrCodeId = "qr_IEjmDxjAY3iCnw"; - private $customerId = ""; + private $customerId = "cust_IEfAt3ruD4OEzo"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/refundTest.php b/tests/refundTest.php index ed285a60..3d5af4f9 100644 --- a/tests/refundTest.php +++ b/tests/refundTest.php @@ -11,11 +11,11 @@ class RefundTest extends TestCase * for example plan_IEeswu4zFBRGwi & rfnd_IEjzeVghAS4vd1 */ - private $paymentId = ""; + private $paymentId = "plan_IEeswu4zFBRGwi"; - private $refundId = ""; + private $refundId = "rfnd_IEjzeVghAS4vd1"; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/registerEmandateTest.php b/tests/registerEmandateTest.php index 3da164ca..c606c0b8 100644 --- a/tests/registerEmandateTest.php +++ b/tests/registerEmandateTest.php @@ -12,15 +12,15 @@ class RegisterEmandateTest extends TestCase * order_IF1TQZozl6Leaw & token_IF1ThOcFC9J7pU */ - private $customerId = ""; + private $customerId = "cust_BMB3EwbqnqZ2EI"; - private $invoiceId = ""; + private $invoiceId = "inv_IF37M4q6SdOpjT"; - private $orderId = ""; + private $orderId = "order_IF1TQZozl6Leaw"; - private $tokenId = ""; + private $tokenId = "token_IF1ThOcFC9J7pU"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -105,7 +105,7 @@ public function testFetchTokenByPaymentId() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } diff --git a/tests/registerNachtest.php b/tests/registerNachtest.php index 5c5100d2..068d73e9 100644 --- a/tests/registerNachtest.php +++ b/tests/registerNachtest.php @@ -12,15 +12,15 @@ class RegisterNachTest extends TestCase * order_IF1TQZozl6Leaw & token_IF1ThOcFC9J7pU */ - private $customerId = ""; + private $customerId = "cust_BMB3EwbqnqZ2EI"; - private $invoiceId = ""; + private $invoiceId = "inv_IF37M4q6SdOpjT"; - private $orderId = ""; + private $orderId = "order_IF1TQZozl6Leaw"; - private $tokenId = ""; + private $tokenId = "token_IF1ThOcFC9J7pU"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -104,7 +104,7 @@ public function testFetchTokenByPaymentId() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray());; } } diff --git a/tests/settlementTest.php b/tests/settlementTest.php index 52472cf4..f353cca0 100644 --- a/tests/settlementTest.php +++ b/tests/settlementTest.php @@ -11,9 +11,9 @@ class SettlementTest extends TestCase * for example : setl_IAj6iuvvTATqOM */ - private $settlementId = ""; + private $settlementId = "setl_IAj6iuvvTATqOM"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -74,7 +74,7 @@ public function testSettlementRecon() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(is_array($data['items'])); + $this->assertArrayHasKey('items',$data); } /** diff --git a/tests/signatureVerificationTest.php b/tests/signatureVerificationTest.php index 3bbbfa27..5a3e86f0 100644 --- a/tests/signatureVerificationTest.php +++ b/tests/signatureVerificationTest.php @@ -8,7 +8,7 @@ class SignatureVerificationTest extends TestCase { private static $subscriptionId; - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/virtualAccountTest.php b/tests/virtualAccountTest.php index 976f276a..bf891e46 100644 --- a/tests/virtualAccountTest.php +++ b/tests/virtualAccountTest.php @@ -12,13 +12,13 @@ class VirtualAccountTest extends TestCase * va_IEmC8SOoyGxsNn */ - private $customerId = ""; + private $customerId = "cust_IEm1ERQLCdRGPV"; - private $paymentId = ""; + private $paymentId = "pay_IEljgrElHGxXAC"; - private $virtualAccountId = ""; + private $virtualAccountId = "va_IEmC8SOoyGxsNn"; - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -32,7 +32,7 @@ public function testCreateVirtualAccount() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('customer',$data->toArray())); + $this->assertArrayHasKey('customer_id',$data->toArray()); } /** @@ -44,7 +44,7 @@ public function testCreateVirtualAccountTpv() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('customer',$data->toArray())); + $this->assertArrayHasKey('customer_id',$data->toArray()); } /** @@ -68,7 +68,7 @@ public function testFetchPayment() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('items',$data->toArray()); } /** @@ -81,8 +81,6 @@ public function testFetchRefund() $data = $this->api->payment->fetch($this->paymentId)->refunds(); $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); } @@ -99,7 +97,7 @@ public function testCloseVirtualAccount() $this->assertTrue(is_array($data->toArray())); - $this->assertTrue(in_array('id',$data->toArray())); + $this->assertArrayHasKey('id',$data->toArray()); } } } \ No newline at end of file From 6e1b13610251e5cfa8780ee5f8d93dcc42ab1259 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 28 Apr 2022 15:18:37 +0530 Subject: [PATCH 02/11] file camelcase --- Razorpay.php | 6 +- tests/PaperNachTest.php | 130 +++++++++++++++++++ tests/PaymentLinkTest.php | 188 ++++++++++++++++++++++++++++ tests/PaymentTest.php | 114 +++++++++++++++++ tests/PlanTest.php | 56 +++++++++ tests/QrCodeTest.php | 94 ++++++++++++++ tests/RefundTest.php | 94 ++++++++++++++ tests/RegisterEmandateTest.php | 138 ++++++++++++++++++++ tests/RegisterNachTest.php | 136 ++++++++++++++++++++ tests/SettlementTest.php | 103 +++++++++++++++ tests/SignatureVerificationTest.php | 67 ++++++++++ tests/VirtualAccountTest.php | 103 +++++++++++++++ 12 files changed, 1227 insertions(+), 2 deletions(-) create mode 100644 tests/PaperNachTest.php create mode 100644 tests/PaymentLinkTest.php create mode 100644 tests/PaymentTest.php create mode 100644 tests/PlanTest.php create mode 100644 tests/QrCodeTest.php create mode 100644 tests/RefundTest.php create mode 100644 tests/RegisterEmandateTest.php create mode 100644 tests/RegisterNachTest.php create mode 100644 tests/SettlementTest.php create mode 100644 tests/SignatureVerificationTest.php create mode 100644 tests/VirtualAccountTest.php diff --git a/Razorpay.php b/Razorpay.php index 70aec023..966d7458 100644 --- a/Razorpay.php +++ b/Razorpay.php @@ -1,14 +1,16 @@ api->customer->create(array('name' => 'Razorpay User 72', 'email' => 'customer72@razorpay.com', 'fail_existing'=>'0')); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('customer',$data->toArray())); + } + + /** + * Create Order + */ + public function testCreateOrderPaperNach() + { + $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray()); + } + + /** + * Send notification + */ + public function testSendNotification() + { + $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); + + $this->assertTrue(in_array('success',$data)); + + } + + + /** + * Create registration link + */ + public function testRegistrationLink() + { + $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Fetch Payment ID using Order ID + */ + public function testFetchPaymentByorderId() + { + $data = $this->api->order->fetch($this->orderId)->payments(); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Fetch token by payment ID + */ + public function testFetchTokenByPaymentId() + { + $payment = $this->api->payment->all(); + + if(!empty($payment)){ + + $data = $this->api->payment->fetch($payment['items'][0]['id']); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray()); + } + } + + /** + * Create an order to charge the customer + */ + public function testCreateOrderCharge() + { + $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray()); + } + + /** + * Create a Recurring Payment + */ + public function testCreateRecurring() + { + $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") + ),"receipt" => "Receipt No. 1")); + + $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); + + $this->assertTrue(is_array($data->toArray())); + + } + +} \ No newline at end of file diff --git a/tests/PaymentLinkTest.php b/tests/PaymentLinkTest.php new file mode 100644 index 00000000..6b6fb21a --- /dev/null +++ b/tests/PaymentLinkTest.php @@ -0,0 +1,188 @@ +api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, + 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', + 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , + 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', + 'callback_method'=>'get')); + + $this->cancelLinkId = $data->id; + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Fetch multiple refunds for a payment + */ + public function testFetchAllMutlipleRefund() + { + $data = $this->api->paymentLink->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['payment_links'])); + } + + /** + * Fetch a specific refund for a payment + */ + public function testFetchRefund() + { + $data = $this->api->paymentLink->fetch($this->paymentLinkId); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('amount',$data->toArray())); + } + + /** + * Update Payment Link + */ + public function testUpdatePaymentLink() + { + $data = $this->api->paymentLink->fetch($this->paymentLinkId)->edit(array("reference_id"=>"TS".time(), "reminder_enable"=>0, "notes"=>["policy_name"=>"Jeevan Saral 2"])); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + + /** + * Send notification + */ + public function testSendNotification() + { + $data = $this->api->paymentLink->fetch($this->paymentLinkId)->notifyBy('email'); + + $this->assertTrue(is_array($data)); + + $this->assertTrue(in_array('success',$data)); + } + + /** + * Cancel Payment Link + */ + public function testCancelPaymentLink() + { + $paymentLink = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, + 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', + 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , + 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', + 'callback_method'=>'get')); + + $data = $this->api->paymentLink->fetch($paymentLink->id)->cancel(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Transfer payments received using payment links + */ + public function testCreateTransferPayments() + { + $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Offers on payment links + */ + public function testOfferPaymentLinks() + { + $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Managing reminders for payment links + */ + public function testManagingRemainder() + { + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>false)); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('amount',$data->toArray())); + } + + /** + * Rename labels in checkout section + */ + public function testRenameLabelsCheckout() + { + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('partial_payment'=>array('min_amount_label'=>'Minimum Money to be paid', 'partial_amount_label'=>'Pay in parts', 'partial_amount_description'=>'Pay at least ₹100', 'full_amount_label'=>'Pay the entire amount'))))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('amount',$data->toArray())); + } + + /** + * Change Business name + */ + public function testBusinessName() + { + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('name'=>'Lacme Corp')))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Change checkouts fields + */ + public function testCheckoutFields() + { + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('method'=>array('netbanking'=>'1', 'card'=>'1', 'upi'=>'0', 'wallet'=>'0'))))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } + + /** + * Rename labels in checkout section + */ + public function testRenameLabelsPayments() + { + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('hosted_page'=>array('label'=>array('receipt'=>'Ref No.'.time(), 'description'=>'Course Name', 'amount_payable'=>'Course Fee Payable', 'amount_paid'=>'Course Fee Paid', 'partial_amount_due'=>'Fee Installment Due', 'partial_amount_paid'=>'Fee Installment Paid', 'expire_by'=>'Pay Before', 'expired_on'=>'1632223497','amount_due'=>'Course Fee Due'), 'show_preferences'=>array('issued_to'=>false))))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('accept_partial',$data->toArray())); + } +} \ No newline at end of file diff --git a/tests/PaymentTest.php b/tests/PaymentTest.php new file mode 100644 index 00000000..81bad687 --- /dev/null +++ b/tests/PaymentTest.php @@ -0,0 +1,114 @@ +api->payment->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch a payment + */ + public function testFetchPayment() + { + $payment = $this->api->payment->all(); + + if($payment['count'] !== 0){ + + $data = $this->api->payment->fetch($payment['items'][0]['id']); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('payment',$data->toArray())); + } + } + + /** + * Fetch a payment + */ + public function testFetchOrderPayment() + { + $data = $this->api->order->fetch($this->orderId)->payments(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Update a payment + */ + public function testUpdatePayment() + { + $data = $this->api->payment->fetch($this->paymentId)->edit(array('notes'=> array('key_1'=> 'value1','key_2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('payment',$data->toArray())); + } + + /** + * Fetch card details with paymentId + */ + public function testFetchCardWithPaymentId() + { + $data = $this->api->payment->fetch($this->paymentId)->fetchCardDetails(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('card',$data->toArray())); + } + + /** + * Fetch Payment Downtime Details + */ + public function testfetchPaymentDowntime() + { + $data = $this->api->payment->fetchPaymentDowntime(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('count',$data->toArray()); + } + + /** + * Fetch Payment Downtime Details + */ + public function testfetchPaymentDowntimeById() + { + $downtime = $this->api->payment->fetchPaymentDowntime(); + if(count($downtime['items'])>0){ + $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); + $this->assertTrue(is_array($data->toArray())); + }else{ + $this->assertArrayHasKey('count',$downtime->toArray()); + } + } + +} diff --git a/tests/PlanTest.php b/tests/PlanTest.php new file mode 100644 index 00000000..b0b1c8a1 --- /dev/null +++ b/tests/PlanTest.php @@ -0,0 +1,56 @@ +api->plan->create(array('period' => 'weekly', 'interval' => 1, 'item' => array('name' => 'Test Weekly 1 plan', 'description' => 'Description for the weekly 1 plan', 'amount' => 600, 'currency' => 'INR'),'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('plan',$data->toArray())); + } + + /** + * Fetch all plans + */ + public function testFetchAllPlans() + { + $data = $this->api->plan->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch particular plan + */ + public function testFetchPlan() + { + $data = $this->api->plan->fetch($this->planId); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('plan',$data->toArray())); + } +} \ No newline at end of file diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php new file mode 100644 index 00000000..e4f08233 --- /dev/null +++ b/tests/QrCodeTest.php @@ -0,0 +1,94 @@ +api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('qr_code',$data->toArray())); + } + + /** + * Fetch all Qr code + */ + public function testFetchAllQrCode() + { + $data = $this->api->plan->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch a Qr code + */ + public function testFetchQrCode() + { + $data = $this->api->qrCode->fetch($this->qrCodeId); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Fetch a Qr code for customer id + */ + public function testFetchQrCodeByCustomerId() + { + $data = $this->api->qrCode->all(["customer_id" => $this->customerId ]); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch a Qr code for payment id + */ + public function testFetchQrCodePaymentById() + { + $data = $this->api->qrCode->all(); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Close a QR Code + */ + public function testCloseQrCode() + { + $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + + $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('qr_code',$data->toArray())); + } +} \ No newline at end of file diff --git a/tests/RefundTest.php b/tests/RefundTest.php new file mode 100644 index 00000000..3d5af4f9 --- /dev/null +++ b/tests/RefundTest.php @@ -0,0 +1,94 @@ +api->payment->fetch($this->paymentId)->refund(array("amount"=> "100", "speed"=>"optimum", "receipt"=>"Receipt No. ".time())); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('refund',$data->toArray())); + } + + + /** + * Fetch multiple refunds for a payment + */ + public function testFetchMultipalRefund() + { + $data = $this->api->payment->fetch($this->paymentId)->fetchMultipleRefund(array("count"=>1)); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch a specific refund for a payment + */ + public function testFetchRefund() + { + $data = $this->api->payment->fetch($this->paymentId)->fetchRefund($this->refundId); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Fetch all refunds + */ + public function testFetchAllRefund() + { + $data = $this->api->refund->all(array("count"=>1)); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch particular refund + */ + public function testParticularRefund() + { + $data = $this->api->refund->fetch($this->refundId); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('refund',$data->toArray())); + } + + /** + * Update the refund + */ + public function testUpdateRefund() + { + $data = $this->api->refund->fetch($this->refundId)->edit(array('notes'=> array('notes_key_1'=>'Beam me up Scotty.', 'notes_key_2'=>'Engage'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('refund',$data->toArray())); + } +} \ No newline at end of file diff --git a/tests/RegisterEmandateTest.php b/tests/RegisterEmandateTest.php new file mode 100644 index 00000000..c606c0b8 --- /dev/null +++ b/tests/RegisterEmandateTest.php @@ -0,0 +1,138 @@ +api->customer->create(array('name' => 'Razorpay User 21', 'email' => 'customer21@razorpay.com','fail_existing'=>'0')); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('customer',$data->toArray())); + } + + /** + * Create Order + */ + public function testCreateOrder() + { + $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Send/Resend notifications + */ + public function testSendNotification() + { + $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); + + $this->assertTrue(in_array('success',$data)); + + } + + /** + * Create registration link + */ + public function testCreateSubscriptionRegistration() + { + $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Fetch Payment ID using Order ID + */ + public function testFetchPaymentByorderId() + { + $data = $this->api->order->fetch($this->orderId)->payments(); + + $this->assertTrue(is_array($data->toArray())); + } + + /** + * Fetch tokens by customer id + */ + public function testFetchTokenByCustomerId() + { + $data = $this->api->customer->fetch($this->customerId)->tokens()->all(); + + $this->assertTrue(is_array($data->toArray())); + } + + /** + * Fetch token by payment ID + */ + public function testFetchTokenByPaymentId() + { + $payment = $this->api->payment->all(); + + if(!empty($payment)){ + + $data = $this->api->payment->fetch($payment['items'][0]['id']); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray()); + } + } + + /** + * Create an order to charge the customer + */ + public function testCreateOrderCharge() + { + $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Create a Recurring Payment + */ + public function testCreateRecurring() + { + $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") + ),"receipt" => "Receipt No. 1")); + + $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); + + $this->assertTrue(is_array($data->toArray())); + + } + +} \ No newline at end of file diff --git a/tests/RegisterNachTest.php b/tests/RegisterNachTest.php new file mode 100644 index 00000000..068d73e9 --- /dev/null +++ b/tests/RegisterNachTest.php @@ -0,0 +1,136 @@ +api->customer->create(array('name' => 'Razorpay User 21', 'email' => 'customer21@razorpay.com','fail_existing'=>'0')); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('customer',$data->toArray())); + } + + /** + * Create Order + */ + public function testCreateOrderForNachTest() + { + $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Send/Resend notifications + */ + public function testSendNotification() + { + $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); + + $this->assertTrue(in_array('success',$data)); + } + + /** + * Create registration link + */ + public function testCreateSubscriptionRegistration() + { + $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Fetch Payment ID using Order ID + */ + public function testFetchPaymentByorderId() + { + $data = $this->api->order->fetch($this->orderId)->payments(); + + $this->assertTrue(is_array($data->toArray())); + } + + /** + * Fetch tokens by customer id + */ + public function testFetchTokenByCustomerId() + { + $data = $this->api->customer->fetch($this->customerId)->tokens()->all(); + + $this->assertTrue(is_array($data->toArray())); + } + + /** + * Fetch token by payment ID + */ + public function testFetchTokenByPaymentId() + { + $payment = $this->api->payment->all(); + + if(!empty($payment)){ + + $data = $this->api->payment->fetch($payment['items'][0]['id']); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray());; + } + } + + /** + * Create an order to charge the customer + */ + public function testCreateOrderCharge() + { + $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('id',$data->toArray())); + } + + /** + * Create a Recurring Payment + */ + public function testCreateRecurring() + { + $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") + ),"receipt" => "Receipt No. 1")); + + $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); + + $this->assertTrue(is_array($data->toArray())); + + } +} \ No newline at end of file diff --git a/tests/SettlementTest.php b/tests/SettlementTest.php new file mode 100644 index 00000000..f353cca0 --- /dev/null +++ b/tests/SettlementTest.php @@ -0,0 +1,103 @@ +api->settlement->createOndemandSettlement(array("amount"=> 1221, "settle_full_balance"=> false, "description"=>"Testing","notes" => array("notes_key_1"=> "Tea, Earl Grey, Hot","notes_key_2"=> "Tea, Earl Grey… decaf."))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('settlement.ondemand',$data->toArray())); + } + + /** + * Fetch all settlements + */ + public function testAllSettlements() + { + $data = $this->api->settlement->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('collection',$data->toArray())); + } + + /** + * Fetch a settlement + */ + public function testFetchSettlement() + { + $data = $this->api->settlement->fetch($this->settlementId); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('settlement',$data->toArray())); + } + + /** + * Settlement report for a month + */ + public function testReports() + { + $data = $this->api->settlement->reports(array("year"=>2021,"month"=>9)); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Settlement recon + */ + public function testSettlementRecon() + { + $data = $this->api->settlement->settlementRecon(array('year' => 2021, 'month' => 9)); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('items',$data); + } + + /** + * Fetch all on-demand settlements + */ + public function TestFetchAllOndemandSettlement() + { + $data = $api->settlement->fetchAllOndemandSettlement(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } + + /** + * Fetch on-demand settlement by ID + */ + public function TestFetchAllOndemandSettlementById() + { + $data = $api->settlement->fetch($this->settlementId)->TestFetchAllOndemandSettlementById(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(is_array($data['items'])); + } +} \ No newline at end of file diff --git a/tests/SignatureVerificationTest.php b/tests/SignatureVerificationTest.php new file mode 100644 index 00000000..5a3e86f0 --- /dev/null +++ b/tests/SignatureVerificationTest.php @@ -0,0 +1,67 @@ +assertTrue(true,$this->api->utility->verifyPaymentSignature(array( + 'razorpay_order_id' => $orderId, + 'razorpay_payment_id' => $paymentId, + 'razorpay_signature' => $signature + ))); + } + + /** + * Verify PaymentLink verification + */ + public function testPaymentLinkVerification() + { + $paymentLinkId = 'plink_IH3cNucfVEgV68'; + $paymentId = 'pay_IH3d0ara9bSsjQ'; + $paymentLinkReferenceId = 'TSsd1989'; + $paymentLinkStatus = 'paid'; + $signature = '07ae18789e35093e51d0a491eb9922646f3f82773547e5b0f67ee3f2d3bf7d5b'; + + $this->assertTrue(true,$this->api->utility->verifyPaymentSignature(array( + 'razorpay_payment_link_id' => $paymentLinkId, + 'razorpay_payment_link_reference_id' => $paymentLinkReferenceId, + 'razorpay_payment_link_status' => $paymentLinkStatus, + 'razorpay_payment_id' => $paymentId, + 'razorpay_signature' => $signature + ))); + } + + /** + * Verify Subscription verification + */ + public function testSubscriptionVerification() + { + $subscriptionId = 'sub_ID6MOhgkcoHj9I'; + $paymentId = 'pay_IDZNwZZFtnjyym'; + $signature = '601f383334975c714c91a7d97dd723eb56520318355863dcf3821c0d07a17693'; + + $this->assertTrue(true,$this->api->utility->verifyPaymentSignature(array( + 'razorpay_subscription_id' => $subscriptionId, + 'razorpay_payment_id' => $paymentId, + 'razorpay_signature' => $signature + ))); + } +} \ No newline at end of file diff --git a/tests/VirtualAccountTest.php b/tests/VirtualAccountTest.php new file mode 100644 index 00000000..bf891e46 --- /dev/null +++ b/tests/VirtualAccountTest.php @@ -0,0 +1,103 @@ +api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => 1681615838,'notes' => array('project_name' => 'Banking Software'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('customer_id',$data->toArray()); + } + + /** + * Create a virtual account with TPV + */ + public function testCreateVirtualAccountTpv() + { + $data = $this->api->virtualAccount->create(array('receivers' => array('types'=> array('bank_account')),'allowed_payers' => array(array('type'=>'bank_account','bank_account'=>array('ifsc'=>'RATN0VAAPIS','account_number'=>'2223330027558515'))),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId, 'notes' => array('project_name' => 'Banking Software'))); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('customer_id',$data->toArray()); + } + + /** + * Fetch all virtual account + */ + public function testFetchAllVirtualAccounts() + { + $data = $this->api->virtualAccount->all(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertTrue(in_array('collection',$data->toArray())); + } + + /** + * Fetch payments for a virtual account + */ + public function testFetchPayment() + { + $data = $this->api->virtualAccount->fetch($this->virtualAccountId)->payments(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('items',$data->toArray()); + } + + /** + * Refund payments made to a virtual account + */ + public function testFetchRefund() + { + $payment = $this->api->payment->all(); + + $data = $this->api->payment->fetch($this->paymentId)->refunds(); + + $this->assertTrue(is_array($data->toArray())); + + } + + /** + * Close virtual account + */ + public function testCloseVirtualAccount() + { + $payment = $this->api->virtualAccount->all(); + + if($payment['count'] !== 0){ + + $data = $this->api->virtualAccount->fetch($payment['items'][0]['id'])->close(); + + $this->assertTrue(is_array($data->toArray())); + + $this->assertArrayHasKey('id',$data->toArray()); + } + } +} \ No newline at end of file From 529f21a4afb4ebae4499e6e81116aaf35abae37c Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 28 Apr 2022 16:06:19 +0530 Subject: [PATCH 03/11] remove qr duplicate file --- tests/QrCodeTest.php | 2 +- tests/TestCase.php | 4 +- tests/qrCodeTest.php | 94 -------------------------------------------- 3 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 tests/qrCodeTest.php diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php index e4f08233..cc509dd6 100644 --- a/tests/QrCodeTest.php +++ b/tests/QrCodeTest.php @@ -83,7 +83,7 @@ public function testFetchQrCodePaymentById() */ public function testCloseQrCode() { - $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customer['items'][0]['id'], "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 4f451112..16ea9d5c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,8 +11,8 @@ class TestCase extends PhpUnitTest public function setUp(): void { - $apiKey = "api_key"; - $apiSecret = "api_secret"; + $apiKey = "rzp_test_1DP5mmOlF5G5ag"; + $apiSecret = "thisissupersecret"; $this->api = new Api( $apiKey, $apiSecret); } diff --git a/tests/qrCodeTest.php b/tests/qrCodeTest.php deleted file mode 100644 index cc509dd6..00000000 --- a/tests/qrCodeTest.php +++ /dev/null @@ -1,94 +0,0 @@ -api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('qr_code',$data->toArray())); - } - - /** - * Fetch all Qr code - */ - public function testFetchAllQrCode() - { - $data = $this->api->plan->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch a Qr code - */ - public function testFetchQrCode() - { - $data = $this->api->qrCode->fetch($this->qrCodeId); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Fetch a Qr code for customer id - */ - public function testFetchQrCodeByCustomerId() - { - $data = $this->api->qrCode->all(["customer_id" => $this->customerId ]); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch a Qr code for payment id - */ - public function testFetchQrCodePaymentById() - { - $data = $this->api->qrCode->all(); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Close a QR Code - */ - public function testCloseQrCode() - { - $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customer['items'][0]['id'], "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); - - $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('qr_code',$data->toArray())); - } -} \ No newline at end of file From dc914eaf97414576bf6ace3cb9f718c6db527d7f Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 28 Apr 2022 16:11:42 +0530 Subject: [PATCH 04/11] removed all duplicate files --- tests/PaymentTest.php | 13 +- tests/paperNachTest.php | 130 ------------------- tests/paymentLinkTest.php | 188 ---------------------------- tests/paymentTest.php | 113 ----------------- tests/planTest.php | 56 --------- tests/refundTest.php | 94 -------------- tests/registerEmandateTest.php | 138 -------------------- tests/registerNachtest.php | 136 -------------------- tests/settlementTest.php | 103 --------------- tests/signatureVerificationTest.php | 67 ---------- tests/virtualAccountTest.php | 103 --------------- 11 files changed, 6 insertions(+), 1135 deletions(-) delete mode 100644 tests/paperNachTest.php delete mode 100644 tests/paymentLinkTest.php delete mode 100644 tests/paymentTest.php delete mode 100644 tests/planTest.php delete mode 100644 tests/refundTest.php delete mode 100644 tests/registerEmandateTest.php delete mode 100644 tests/registerNachtest.php delete mode 100644 tests/settlementTest.php delete mode 100644 tests/signatureVerificationTest.php delete mode 100644 tests/virtualAccountTest.php diff --git a/tests/PaymentTest.php b/tests/PaymentTest.php index 81bad687..1f92bc28 100644 --- a/tests/PaymentTest.php +++ b/tests/PaymentTest.php @@ -96,19 +96,18 @@ public function testfetchPaymentDowntime() $this->assertArrayHasKey('count',$data->toArray()); } - + /** * Fetch Payment Downtime Details */ public function testfetchPaymentDowntimeById() { $downtime = $this->api->payment->fetchPaymentDowntime(); - if(count($downtime['items'])>0){ - $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); - $this->assertTrue(is_array($data->toArray())); - }else{ - $this->assertArrayHasKey('count',$downtime->toArray()); - } + + $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); + + $this->assertTrue(is_array($data->toArray())); + } } diff --git a/tests/paperNachTest.php b/tests/paperNachTest.php deleted file mode 100644 index 168777f5..00000000 --- a/tests/paperNachTest.php +++ /dev/null @@ -1,130 +0,0 @@ -api->customer->create(array('name' => 'Razorpay User 72', 'email' => 'customer72@razorpay.com', 'fail_existing'=>'0')); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('customer',$data->toArray())); - } - - /** - * Create Order - */ - public function testCreateOrderPaperNach() - { - $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray()); - } - - /** - * Send notification - */ - public function testSendNotification() - { - $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); - - $this->assertTrue(in_array('success',$data)); - - } - - - /** - * Create registration link - */ - public function testRegistrationLink() - { - $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Fetch Payment ID using Order ID - */ - public function testFetchPaymentByorderId() - { - $data = $this->api->order->fetch($this->orderId)->payments(); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Fetch token by payment ID - */ - public function testFetchTokenByPaymentId() - { - $payment = $this->api->payment->all(); - - if(!empty($payment)){ - - $data = $this->api->payment->fetch($payment['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray()); - } - } - - /** - * Create an order to charge the customer - */ - public function testCreateOrderCharge() - { - $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray()); - } - - /** - * Create a Recurring Payment - */ - public function testCreateRecurring() - { - $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") - ),"receipt" => "Receipt No. 1")); - - $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); - - $this->assertTrue(is_array($data->toArray())); - - } - -} \ No newline at end of file diff --git a/tests/paymentLinkTest.php b/tests/paymentLinkTest.php deleted file mode 100644 index 6b6fb21a..00000000 --- a/tests/paymentLinkTest.php +++ /dev/null @@ -1,188 +0,0 @@ -api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, - 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', - 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , - 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', - 'callback_method'=>'get')); - - $this->cancelLinkId = $data->id; - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Fetch multiple refunds for a payment - */ - public function testFetchAllMutlipleRefund() - { - $data = $this->api->paymentLink->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['payment_links'])); - } - - /** - * Fetch a specific refund for a payment - */ - public function testFetchRefund() - { - $data = $this->api->paymentLink->fetch($this->paymentLinkId); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('amount',$data->toArray())); - } - - /** - * Update Payment Link - */ - public function testUpdatePaymentLink() - { - $data = $this->api->paymentLink->fetch($this->paymentLinkId)->edit(array("reference_id"=>"TS".time(), "reminder_enable"=>0, "notes"=>["policy_name"=>"Jeevan Saral 2"])); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - - /** - * Send notification - */ - public function testSendNotification() - { - $data = $this->api->paymentLink->fetch($this->paymentLinkId)->notifyBy('email'); - - $this->assertTrue(is_array($data)); - - $this->assertTrue(in_array('success',$data)); - } - - /** - * Cancel Payment Link - */ - public function testCancelPaymentLink() - { - $paymentLink = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, - 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', - 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , - 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', - 'callback_method'=>'get')); - - $data = $this->api->paymentLink->fetch($paymentLink->id)->cancel(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Transfer payments received using payment links - */ - public function testCreateTransferPayments() - { - $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Offers on payment links - */ - public function testOfferPaymentLinks() - { - $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Managing reminders for payment links - */ - public function testManagingRemainder() - { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>false)); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('amount',$data->toArray())); - } - - /** - * Rename labels in checkout section - */ - public function testRenameLabelsCheckout() - { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('partial_payment'=>array('min_amount_label'=>'Minimum Money to be paid', 'partial_amount_label'=>'Pay in parts', 'partial_amount_description'=>'Pay at least ₹100', 'full_amount_label'=>'Pay the entire amount'))))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('amount',$data->toArray())); - } - - /** - * Change Business name - */ - public function testBusinessName() - { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('name'=>'Lacme Corp')))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Change checkouts fields - */ - public function testCheckoutFields() - { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('method'=>array('netbanking'=>'1', 'card'=>'1', 'upi'=>'0', 'wallet'=>'0'))))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } - - /** - * Rename labels in checkout section - */ - public function testRenameLabelsPayments() - { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('hosted_page'=>array('label'=>array('receipt'=>'Ref No.'.time(), 'description'=>'Course Name', 'amount_payable'=>'Course Fee Payable', 'amount_paid'=>'Course Fee Paid', 'partial_amount_due'=>'Fee Installment Due', 'partial_amount_paid'=>'Fee Installment Paid', 'expire_by'=>'Pay Before', 'expired_on'=>'1632223497','amount_due'=>'Course Fee Due'), 'show_preferences'=>array('issued_to'=>false))))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('accept_partial',$data->toArray())); - } -} \ No newline at end of file diff --git a/tests/paymentTest.php b/tests/paymentTest.php deleted file mode 100644 index 1f92bc28..00000000 --- a/tests/paymentTest.php +++ /dev/null @@ -1,113 +0,0 @@ -api->payment->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch a payment - */ - public function testFetchPayment() - { - $payment = $this->api->payment->all(); - - if($payment['count'] !== 0){ - - $data = $this->api->payment->fetch($payment['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('payment',$data->toArray())); - } - } - - /** - * Fetch a payment - */ - public function testFetchOrderPayment() - { - $data = $this->api->order->fetch($this->orderId)->payments(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Update a payment - */ - public function testUpdatePayment() - { - $data = $this->api->payment->fetch($this->paymentId)->edit(array('notes'=> array('key_1'=> 'value1','key_2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('payment',$data->toArray())); - } - - /** - * Fetch card details with paymentId - */ - public function testFetchCardWithPaymentId() - { - $data = $this->api->payment->fetch($this->paymentId)->fetchCardDetails(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('card',$data->toArray())); - } - - /** - * Fetch Payment Downtime Details - */ - public function testfetchPaymentDowntime() - { - $data = $this->api->payment->fetchPaymentDowntime(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('count',$data->toArray()); - } - - /** - * Fetch Payment Downtime Details - */ - public function testfetchPaymentDowntimeById() - { - $downtime = $this->api->payment->fetchPaymentDowntime(); - - $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - - } - -} diff --git a/tests/planTest.php b/tests/planTest.php deleted file mode 100644 index b0b1c8a1..00000000 --- a/tests/planTest.php +++ /dev/null @@ -1,56 +0,0 @@ -api->plan->create(array('period' => 'weekly', 'interval' => 1, 'item' => array('name' => 'Test Weekly 1 plan', 'description' => 'Description for the weekly 1 plan', 'amount' => 600, 'currency' => 'INR'),'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('plan',$data->toArray())); - } - - /** - * Fetch all plans - */ - public function testFetchAllPlans() - { - $data = $this->api->plan->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch particular plan - */ - public function testFetchPlan() - { - $data = $this->api->plan->fetch($this->planId); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('plan',$data->toArray())); - } -} \ No newline at end of file diff --git a/tests/refundTest.php b/tests/refundTest.php deleted file mode 100644 index 3d5af4f9..00000000 --- a/tests/refundTest.php +++ /dev/null @@ -1,94 +0,0 @@ -api->payment->fetch($this->paymentId)->refund(array("amount"=> "100", "speed"=>"optimum", "receipt"=>"Receipt No. ".time())); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('refund',$data->toArray())); - } - - - /** - * Fetch multiple refunds for a payment - */ - public function testFetchMultipalRefund() - { - $data = $this->api->payment->fetch($this->paymentId)->fetchMultipleRefund(array("count"=>1)); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch a specific refund for a payment - */ - public function testFetchRefund() - { - $data = $this->api->payment->fetch($this->paymentId)->fetchRefund($this->refundId); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Fetch all refunds - */ - public function testFetchAllRefund() - { - $data = $this->api->refund->all(array("count"=>1)); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch particular refund - */ - public function testParticularRefund() - { - $data = $this->api->refund->fetch($this->refundId); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('refund',$data->toArray())); - } - - /** - * Update the refund - */ - public function testUpdateRefund() - { - $data = $this->api->refund->fetch($this->refundId)->edit(array('notes'=> array('notes_key_1'=>'Beam me up Scotty.', 'notes_key_2'=>'Engage'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('refund',$data->toArray())); - } -} \ No newline at end of file diff --git a/tests/registerEmandateTest.php b/tests/registerEmandateTest.php deleted file mode 100644 index c606c0b8..00000000 --- a/tests/registerEmandateTest.php +++ /dev/null @@ -1,138 +0,0 @@ -api->customer->create(array('name' => 'Razorpay User 21', 'email' => 'customer21@razorpay.com','fail_existing'=>'0')); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('customer',$data->toArray())); - } - - /** - * Create Order - */ - public function testCreateOrder() - { - $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Send/Resend notifications - */ - public function testSendNotification() - { - $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); - - $this->assertTrue(in_array('success',$data)); - - } - - /** - * Create registration link - */ - public function testCreateSubscriptionRegistration() - { - $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Fetch Payment ID using Order ID - */ - public function testFetchPaymentByorderId() - { - $data = $this->api->order->fetch($this->orderId)->payments(); - - $this->assertTrue(is_array($data->toArray())); - } - - /** - * Fetch tokens by customer id - */ - public function testFetchTokenByCustomerId() - { - $data = $this->api->customer->fetch($this->customerId)->tokens()->all(); - - $this->assertTrue(is_array($data->toArray())); - } - - /** - * Fetch token by payment ID - */ - public function testFetchTokenByPaymentId() - { - $payment = $this->api->payment->all(); - - if(!empty($payment)){ - - $data = $this->api->payment->fetch($payment['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray()); - } - } - - /** - * Create an order to charge the customer - */ - public function testCreateOrderCharge() - { - $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Create a Recurring Payment - */ - public function testCreateRecurring() - { - $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") - ),"receipt" => "Receipt No. 1")); - - $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); - - $this->assertTrue(is_array($data->toArray())); - - } - -} \ No newline at end of file diff --git a/tests/registerNachtest.php b/tests/registerNachtest.php deleted file mode 100644 index 068d73e9..00000000 --- a/tests/registerNachtest.php +++ /dev/null @@ -1,136 +0,0 @@ -api->customer->create(array('name' => 'Razorpay User 21', 'email' => 'customer21@razorpay.com','fail_existing'=>'0')); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('customer',$data->toArray())); - } - - /** - * Create Order - */ - public function testCreateOrderForNachTest() - { - $data = $this->api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Send/Resend notifications - */ - public function testSendNotification() - { - $data = $this->api->invoice->fetch($this->invoiceId)->notifyBy('email'); - - $this->assertTrue(in_array('success',$data)); - } - - /** - * Create registration link - */ - public function testCreateSubscriptionRegistration() - { - $data = $this->api->subscription->createSubscriptionRegistration(array('customer' => array('name' => 'Gaurav Kumar','email' => 'gaurav.kumar@example.com','contact' => '9123456780'),'amount' => 0,'currency' => 'INR','type' => 'link','description' => '12 p.m. Meals','subscription_registration' => array('method' => 'nach','auth_type' => 'physical','bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '11214311215411','account_type' => 'savings','ifsc_code' => 'HDFC0001233'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH'),'expire_at' => 1636772800,'max_amount' => 50000),'receipt' => 'Receipt No. '.time(),'sms_notify' => 1,'email_notify' => 1,'expire_by' => 1636772800,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Fetch Payment ID using Order ID - */ - public function testFetchPaymentByorderId() - { - $data = $this->api->order->fetch($this->orderId)->payments(); - - $this->assertTrue(is_array($data->toArray())); - } - - /** - * Fetch tokens by customer id - */ - public function testFetchTokenByCustomerId() - { - $data = $this->api->customer->fetch($this->customerId)->tokens()->all(); - - $this->assertTrue(is_array($data->toArray())); - } - - /** - * Fetch token by payment ID - */ - public function testFetchTokenByPaymentId() - { - $payment = $this->api->payment->all(); - - if(!empty($payment)){ - - $data = $this->api->payment->fetch($payment['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray());; - } - } - - /** - * Create an order to charge the customer - */ - public function testCreateOrderCharge() - { - $data = $this->api->order->create(array('receipt' => '122', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('id',$data->toArray())); - } - - /** - * Create a Recurring Payment - */ - public function testCreateRecurring() - { - $order = $this->api->order->create(array("amount" => 100, "currency" => "INR","method" => "emandate", "payment_capture" => "1","customer_id" => $this->customerId ,"token" => array("auth_type" => "netbanking","max_amount" => 9999900,"expire_at" => 2147483647,"bank_account" => array("beneficiary_name" => "Gaurav Kumar","account_number" => "1121431121541121","account_type" => "savings","ifsc_code" => "HDFC0000001") - ),"receipt" => "Receipt No. 1")); - - $data = $this->api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$order->id,'customer_id'=>$this->customerId,'token'=>$this->tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar')); - - $this->assertTrue(is_array($data->toArray())); - - } -} \ No newline at end of file diff --git a/tests/settlementTest.php b/tests/settlementTest.php deleted file mode 100644 index f353cca0..00000000 --- a/tests/settlementTest.php +++ /dev/null @@ -1,103 +0,0 @@ -api->settlement->createOndemandSettlement(array("amount"=> 1221, "settle_full_balance"=> false, "description"=>"Testing","notes" => array("notes_key_1"=> "Tea, Earl Grey, Hot","notes_key_2"=> "Tea, Earl Grey… decaf."))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('settlement.ondemand',$data->toArray())); - } - - /** - * Fetch all settlements - */ - public function testAllSettlements() - { - $data = $this->api->settlement->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('collection',$data->toArray())); - } - - /** - * Fetch a settlement - */ - public function testFetchSettlement() - { - $data = $this->api->settlement->fetch($this->settlementId); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('settlement',$data->toArray())); - } - - /** - * Settlement report for a month - */ - public function testReports() - { - $data = $this->api->settlement->reports(array("year"=>2021,"month"=>9)); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Settlement recon - */ - public function testSettlementRecon() - { - $data = $this->api->settlement->settlementRecon(array('year' => 2021, 'month' => 9)); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('items',$data); - } - - /** - * Fetch all on-demand settlements - */ - public function TestFetchAllOndemandSettlement() - { - $data = $api->settlement->fetchAllOndemandSettlement(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } - - /** - * Fetch on-demand settlement by ID - */ - public function TestFetchAllOndemandSettlementById() - { - $data = $api->settlement->fetch($this->settlementId)->TestFetchAllOndemandSettlementById(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(is_array($data['items'])); - } -} \ No newline at end of file diff --git a/tests/signatureVerificationTest.php b/tests/signatureVerificationTest.php deleted file mode 100644 index 5a3e86f0..00000000 --- a/tests/signatureVerificationTest.php +++ /dev/null @@ -1,67 +0,0 @@ -assertTrue(true,$this->api->utility->verifyPaymentSignature(array( - 'razorpay_order_id' => $orderId, - 'razorpay_payment_id' => $paymentId, - 'razorpay_signature' => $signature - ))); - } - - /** - * Verify PaymentLink verification - */ - public function testPaymentLinkVerification() - { - $paymentLinkId = 'plink_IH3cNucfVEgV68'; - $paymentId = 'pay_IH3d0ara9bSsjQ'; - $paymentLinkReferenceId = 'TSsd1989'; - $paymentLinkStatus = 'paid'; - $signature = '07ae18789e35093e51d0a491eb9922646f3f82773547e5b0f67ee3f2d3bf7d5b'; - - $this->assertTrue(true,$this->api->utility->verifyPaymentSignature(array( - 'razorpay_payment_link_id' => $paymentLinkId, - 'razorpay_payment_link_reference_id' => $paymentLinkReferenceId, - 'razorpay_payment_link_status' => $paymentLinkStatus, - 'razorpay_payment_id' => $paymentId, - 'razorpay_signature' => $signature - ))); - } - - /** - * Verify Subscription verification - */ - public function testSubscriptionVerification() - { - $subscriptionId = 'sub_ID6MOhgkcoHj9I'; - $paymentId = 'pay_IDZNwZZFtnjyym'; - $signature = '601f383334975c714c91a7d97dd723eb56520318355863dcf3821c0d07a17693'; - - $this->assertTrue(true,$this->api->utility->verifyPaymentSignature(array( - 'razorpay_subscription_id' => $subscriptionId, - 'razorpay_payment_id' => $paymentId, - 'razorpay_signature' => $signature - ))); - } -} \ No newline at end of file diff --git a/tests/virtualAccountTest.php b/tests/virtualAccountTest.php deleted file mode 100644 index bf891e46..00000000 --- a/tests/virtualAccountTest.php +++ /dev/null @@ -1,103 +0,0 @@ -api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => 1681615838,'notes' => array('project_name' => 'Banking Software'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('customer_id',$data->toArray()); - } - - /** - * Create a virtual account with TPV - */ - public function testCreateVirtualAccountTpv() - { - $data = $this->api->virtualAccount->create(array('receivers' => array('types'=> array('bank_account')),'allowed_payers' => array(array('type'=>'bank_account','bank_account'=>array('ifsc'=>'RATN0VAAPIS','account_number'=>'2223330027558515'))),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId, 'notes' => array('project_name' => 'Banking Software'))); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('customer_id',$data->toArray()); - } - - /** - * Fetch all virtual account - */ - public function testFetchAllVirtualAccounts() - { - $data = $this->api->virtualAccount->all(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertTrue(in_array('collection',$data->toArray())); - } - - /** - * Fetch payments for a virtual account - */ - public function testFetchPayment() - { - $data = $this->api->virtualAccount->fetch($this->virtualAccountId)->payments(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('items',$data->toArray()); - } - - /** - * Refund payments made to a virtual account - */ - public function testFetchRefund() - { - $payment = $this->api->payment->all(); - - $data = $this->api->payment->fetch($this->paymentId)->refunds(); - - $this->assertTrue(is_array($data->toArray())); - - } - - /** - * Close virtual account - */ - public function testCloseVirtualAccount() - { - $payment = $this->api->virtualAccount->all(); - - if($payment['count'] !== 0){ - - $data = $this->api->virtualAccount->fetch($payment['items'][0]['id'])->close(); - - $this->assertTrue(is_array($data->toArray())); - - $this->assertArrayHasKey('id',$data->toArray()); - } - } -} \ No newline at end of file From ebe90ae4d211b3aef5c66f4fc8adc4465da32a38 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 28 Apr 2022 16:43:46 +0530 Subject: [PATCH 05/11] fixed under variable & git issue --- Deprecated.php | 2 +- Razorpay.php | 2 +- tests/EmandateTest.php | 2 +- tests/PaymentTest.php | 31 ++++++++++++++++--------------- tests/QrCodeTest.php | 2 +- tests/TestCase.php | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Deprecated.php b/Deprecated.php index b8144d74..9ce35374 100644 --- a/Deprecated.php +++ b/Deprecated.php @@ -16,5 +16,5 @@ if (class_exists('WpOrg\Requests\Autoload') === false) { require_once dirname(__DIR__) . '/src/Autoload.php'; } - +print_r(WpOrg\Requests\Autoload::register()); WpOrg\Requests\Autoload::register(); \ No newline at end of file diff --git a/Razorpay.php b/Razorpay.php index 966d7458..a819fabf 100644 --- a/Razorpay.php +++ b/Razorpay.php @@ -1,7 +1,7 @@ api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'7000569565'),'type'=>'link','amount'=>100,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'card','max_amount'=>'500','expire_at'=> strtotime("+1 month") ),'receipt'=>'Receipt No. '.time(),'email_notify'=>1,'sms_notify'=>1,'expire_by'=>strtotime("+1 month"),'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); + $data = $this->api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9999999999'),'type'=>'link','amount'=>100,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'card','max_amount'=>'500','expire_at'=> strtotime("+1 month") ),'receipt'=>'Receipt No. '.time(),'email_notify'=>1,'sms_notify'=>1,'expire_by'=>strtotime("+1 month"),'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.'))); $this->assertTrue(is_array($data->toArray())); diff --git a/tests/PaymentTest.php b/tests/PaymentTest.php index 1f92bc28..b4dbb81b 100644 --- a/tests/PaymentTest.php +++ b/tests/PaymentTest.php @@ -31,16 +31,16 @@ public function testFetchAllPayment() $this->assertTrue(is_array($data['items'])); } - + /** * Fetch a payment */ public function testFetchPayment() { $payment = $this->api->payment->all(); - + if($payment['count'] !== 0){ - + $data = $this->api->payment->fetch($payment['items'][0]['id']); $this->assertTrue(is_array($data->toArray())); @@ -48,7 +48,7 @@ public function testFetchPayment() $this->assertTrue(in_array('payment',$data->toArray())); } } - + /** * Fetch a payment */ @@ -57,7 +57,7 @@ public function testFetchOrderPayment() $data = $this->api->order->fetch($this->orderId)->payments(); $this->assertTrue(is_array($data->toArray())); - + $this->assertTrue(is_array($data['items'])); } @@ -69,7 +69,7 @@ public function testUpdatePayment() $data = $this->api->payment->fetch($this->paymentId)->edit(array('notes'=> array('key_1'=> 'value1','key_2'=> 'value2'))); $this->assertTrue(is_array($data->toArray())); - + $this->assertTrue(in_array('payment',$data->toArray())); } @@ -79,9 +79,9 @@ public function testUpdatePayment() public function testFetchCardWithPaymentId() { $data = $this->api->payment->fetch($this->paymentId)->fetchCardDetails(); - + $this->assertTrue(is_array($data->toArray())); - + $this->assertTrue(in_array('card',$data->toArray())); } @@ -93,7 +93,7 @@ public function testfetchPaymentDowntime() $data = $this->api->payment->fetchPaymentDowntime(); $this->assertTrue(is_array($data->toArray())); - + $this->assertArrayHasKey('count',$data->toArray()); } @@ -103,11 +103,12 @@ public function testfetchPaymentDowntime() public function testfetchPaymentDowntimeById() { $downtime = $this->api->payment->fetchPaymentDowntime(); - - $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); - - $this->assertTrue(is_array($data->toArray())); - + if(count($downtime['items'])>0){ + $data = $this->api->payment->fetchPaymentDowntimeById($downtime['items'][0]['id']); + $this->assertTrue(is_array($data->toArray())); + }else{ + $this->assertArrayHasKey('count',$downtime->toArray()); + } } -} +} \ No newline at end of file diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php index cc509dd6..e4f08233 100644 --- a/tests/QrCodeTest.php +++ b/tests/QrCodeTest.php @@ -83,7 +83,7 @@ public function testFetchQrCodePaymentById() */ public function testCloseQrCode() { - $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customer['items'][0]['id'], "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 16ea9d5c..affe7483 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,8 +11,8 @@ class TestCase extends PhpUnitTest public function setUp(): void { - $apiKey = "rzp_test_1DP5mmOlF5G5ag"; - $apiSecret = "thisissupersecret"; + $apiKey = ""; + $apiSecret = ""; $this->api = new Api( $apiKey, $apiSecret); } From 458c1ec50af76c2fe1f680a18bbed3ab98a4520d Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 28 Apr 2022 18:03:55 +0530 Subject: [PATCH 06/11] git action fixing --- Deprecated.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Deprecated.php b/Deprecated.php index 9ce35374..1d87f7df 100644 --- a/Deprecated.php +++ b/Deprecated.php @@ -11,10 +11,10 @@ * * @deprecated 2.0.0 Use the PSR-4 class names instead. */ -const REQUESTS_SILENCE_PSR0_DEPRECATIONS = true; +define("REQUESTS_SILENCE_PSR0_DEPRECATIONS",true); if (class_exists('WpOrg\Requests\Autoload') === false) { - require_once dirname(__DIR__) . '/src/Autoload.php'; + require_once __DIR__. 'libs/Requests-2.0.0/src/Autoload.php'; } -print_r(WpOrg\Requests\Autoload::register()); + WpOrg\Requests\Autoload::register(); \ No newline at end of file From 230fb911a3b477132df4da8ac0ef598aa52636b3 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 29 Apr 2022 13:14:30 +0530 Subject: [PATCH 07/11] doc correction --- documents/addon.md | 6 ++++++ documents/card.md | 4 ++-- documents/customer.md | 2 ++ documents/emandate.md | 8 +++++--- documents/fund.md | 2 +- documents/invoice.md | 17 ++++++++++++++++- documents/item.md | 8 ++------ documents/order.md | 3 ++- documents/papernach.md | 4 ++-- documents/payment.md | 17 ++++++++++++++++- documents/plan.md | 2 +- documents/registeremandate.md | 10 ++++++---- documents/registernach.md | 1 + documents/transfer.md | 16 ++++++++++------ documents/upi.md | 4 ++-- documents/virtualaccount.md | 8 +++++--- 16 files changed, 79 insertions(+), 33 deletions(-) diff --git a/documents/addon.md b/documents/addon.md index 49729a03..9d88bc7b 100644 --- a/documents/addon.md +++ b/documents/addon.md @@ -146,6 +146,12 @@ $api->addon->fetch($addonId); ```php $api->addon->fetch($addonId)->delete(); + +**Parameters:** + +| Name | Type | Description | +|-----------------|---------|------------------------------------------------------------------------------| +| addonId* | string | addon id to be fetched ``` **Parameters:** diff --git a/documents/card.md b/documents/card.md index 443b4d59..8dc64269 100644 --- a/documents/card.md +++ b/documents/card.md @@ -47,7 +47,7 @@ $api->order->create(array('amount' => 100, 'currency' => 'INR', 'receipt' => '1 | currency* | string | The currency of the payment (defaults to INR) | | customerId* | string | The id of the customer to be fetched | | receipt | string | Your system order reference id. | -| method* | string | Payment method used to make the registration transaction. Possible value is `card`. | +| method | string | Payment method used to make the registration transaction. Possible value is `card`. | | token | array | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/cards/authorization-transaction/#112-create-an-order) are supported | | notes | array | A key-value pair | @@ -175,7 +175,7 @@ $api->order->create(array('amount' => '100', 'currency' => 'INR', 'customer_id'= | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) | | currency* | string | The currency of the payment (defaults to INR) | | customerId* | string | The id of the customer to be fetched | -| method* | string | Payment method used to make the registration transaction. Possible value is `card`. | +| method | string | Payment method used to make the registration transaction. Possible value is `card`. | | receipt | string | Your system order reference id. | | token | array | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/cards/subsequent-payments/#31-create-an-order-to-charge-the-customer) are supported | | notes | array | A key-value pair | diff --git a/documents/customer.md b/documents/customer.md index bcb8ab80..e653e15b 100644 --- a/documents/customer.md +++ b/documents/customer.md @@ -12,6 +12,8 @@ $api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@raz | name* | string | Name of the customer | | email | string | Email of the customer | | contact | string | Contact number of the customer | +| fail_existing | string | If a customer with the same details already exists, the request throws an exception by default. Possible value is `0` or `1`| +| gstin | string | Customer's GST number, if available. For example, 29XAbbA4369J1PA | | notes | array | A key-value pair | **Response:** diff --git a/documents/emandate.md b/documents/emandate.md index 9f78a9ab..4d4e2cc3 100644 --- a/documents/emandate.md +++ b/documents/emandate.md @@ -11,6 +11,7 @@ $api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@raz |---------------|-------------|---------------------------------------------| | name* | string | Name of the customer | | email | string | Email of the customer | +| fail_existing | string | If a customer with the same details already exists, the request throws an exception by default. Possible value is `0` or `1`| | contact | string | Contact number of the customer | | notes | array | A key-value pair | @@ -311,7 +312,8 @@ $api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'IN | amount* | integer | Amount of the order to be paid | | currency* | string | Currency of the order. Currently only `INR` is supported. | | receipt | string | Your system order reference id. | -| notes | array | A key-value pair | +| notes | array | A key-value pair | +| payment_capture | boolean | Indicates whether payment status should be changed to captured automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically. | **Response:** ```json @@ -353,8 +355,8 @@ $api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contac | customer_id* | string | The `customer_id` for the customer you want to charge. | | token* | string | The `token_id` generated when the customer successfully completes the authorization payment. Different payment instruments for the same customer have different `token_id`.| | recurring* | string | Determines if recurring payment is enabled or not. Possible values:
* `1` - Recurring is enabled.* `0` - Recurring is not enabled.| -| description* | string | A user-entered description for the payment.| -| notes* | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | +| description | string | A user-entered description for the payment.| +| notes | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | **Response:** ```json diff --git a/documents/fund.md b/documents/fund.md index 89ffc0f2..0d65d802 100644 --- a/documents/fund.md +++ b/documents/fund.md @@ -11,7 +11,7 @@ $api->fundAccount->create(array('customer_id'=>$customerId,'account_type'=>'bank |---------------|-------------|---------------------------------------------| | customerId* | string | The id of the customer to be fetched | | account_type* | string | The bank_account to be linked to the customer ID | -| bank_account* | array | A key-value pair | +| bank_account* | array | All keys listed [here](https://razorpay.com/docs/payments/customers/customer-fund-account-api/#create-a-fund-account) are supported | **Response:** ```json diff --git a/documents/invoice.md b/documents/invoice.md index 9829baa4..a71ca359 100644 --- a/documents/invoice.md +++ b/documents/invoice.md @@ -5,8 +5,23 @@ Request #1 In this example, an invoice is created using the customer and item details. Here, the customer and item are created while creating the invoice. ```php -$api->order->create(array ('type' => 'invoice','description' => 'Invoice for the month of January 2020','partial_payment' => true,'customer' =>array ('name' => 'Gaurav Kumar','contact' => 9999999999,'email' => 'gaurav.kumar@example.com','billing_address' => array ('line1' => 'Ground & 1st Floor, SJR Cyber Laskar','line2' => 'Hosur Road','zipcode' => '560068','city' => 'Bengaluru','state' => 'Karnataka','country' => 'in'),'shipping_address' => array ('line1' => 'Ground & 1st Floor, SJR Cyber Laskar','line2' => 'Hosur Road','zipcode' => '560068','city' => 'Bengaluru','state' => 'Karnataka','country' => 'in')),'line_items' => array (array ('name' => 'Master Cloud Computing in 30 Days','description' => 'Book by Ravena Ravenclaw','amount' => 399,'currency' => 'USD','quantity' => 1)),'sms_notify' => 1,'email_notify' => 1,'currency' => 'USD','expire_by' => 1589765167)); +$api->invoice->create(array ('type' => 'invoice','description' => 'Invoice for the month of January 2020','partial_payment' => true,'customer' =>array ('name' => 'Gaurav Kumar','contact' => 9999999999,'email' => 'gaurav.kumar@example.com','billing_address' => array ('line1' => 'Ground & 1st Floor, SJR Cyber Laskar','line2' => 'Hosur Road','zipcode' => '560068','city' => 'Bengaluru','state' => 'Karnataka','country' => 'in'),'shipping_address' => array ('line1' => 'Ground & 1st Floor, SJR Cyber Laskar','line2' => 'Hosur Road','zipcode' => '560068','city' => 'Bengaluru','state' => 'Karnataka','country' => 'in')),'line_items' => array (array ('name' => 'Master Cloud Computing in 30 Days','description' => 'Book by Ravena Ravenclaw','amount' => 399,'currency' => 'USD','quantity' => 1)),'sms_notify' => 1,'email_notify' => 1,'currency' => 'USD','expire_by' => 1589765167)); ``` +**Parameters:** + +| Name | Type | Description | +|-----------------|---------|------------------------------------------------------------------------------| +|type* | string | entity type (here its invoice) | +|description | string | A brief description of the invoice. | +|customer_id | string | customer id for which invoice need be raised | +|customer | array | customer details in a array format | +|line_items* | array | Details of the line item that is billed in the invoice. | +|expire_by | array | Details of the line item that is billed in the invoice. | +|sms_notify | array | Details of the line item that is billed in the invoice. | +|email_notify | array | Details of the line item that is billed in the invoice. | +|partial_payment | boolean | Indicates whether customers can make partial payments on the invoice . Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. | +| currency* | string | The currency of the payment (defaults to INR) | + Request #2 In this example, an invoice is created using existing `customer_id` and `item_id` diff --git a/documents/item.md b/documents/item.md index 33ad45b0..37b3c54a 100644 --- a/documents/item.md +++ b/documents/item.md @@ -12,8 +12,8 @@ $api->Item->create(array("name" => "Book / English August","description" => "An |-----------------|---------|------------------------------------------------------------------------------| | name* | string | Name of the item. | | description | string | A brief description of the item. | -| amount | integer | Amount of the order to be paid | -| currency | string | Currency of the order. Currently only `INR` is supported. | +| amount* | integer | Amount of the order to be paid | +| currency* | string | Currency of the order. Currently only `INR` is supported. | **Response:** ```json @@ -42,10 +42,6 @@ $api->Item->all($options); | to | timestamp | timestamp before which the item were created | | count | integer | number of item to fetch (default: 10) | | skip | integer | number of item to be skipped (default: 0) | -| name | string | Name of the item. | -| description | string | A brief description of the item. | -| amount | integer | Amount of the order to be paid | -| currency | string | Currency of the order. Currently only `INR` is supported. | | active | boolean | Possible values is `0` or `1` | **Response:** diff --git a/documents/order.md b/documents/order.md index 9d5d192c..95e7f229 100644 --- a/documents/order.md +++ b/documents/order.md @@ -13,7 +13,8 @@ $api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'IN | amount* | integer | Amount of the order to be paid | | currency* | string | Currency of the order. Currently only `INR` is supported. | | receipt | string | Your system order reference id. | -| notes | array | A key-value pair | +| notes | array | A key-value pair | +|partial_payment | boolean | Indicates whether customers can make partial payments on the invoice . Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. | **Response:** diff --git a/documents/papernach.md b/documents/papernach.md index 3d5fff26..8fa8fff0 100644 --- a/documents/papernach.md +++ b/documents/papernach.md @@ -560,8 +560,8 @@ $api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contac | customer_id* | string | The `customer_id` for the customer you want to charge. | | token* | string | The `token_id` generated when the customer successfully completes the authorization payment. Different payment instruments for the same customer have different `token_id`.| | recurring* | string | Determines if recurring payment is enabled or not. Possible values:
* `1` - Recurring is enabled.* `0` - Recurring is not enabled.| -| description* | string | A user-entered description for the payment.| -| notes* | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | +| description | string | A user-entered description for the payment.| +| notes | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | **Response:** ```json diff --git a/documents/payment.md b/documents/payment.md index 3d7980d3..38d55fef 100644 --- a/documents/payment.md +++ b/documents/payment.md @@ -359,7 +359,7 @@ $api->order->create(array('amount' => 50000,'currency' => 'INR','receipt' => 'rc | amount* | integer | Amount of the order to be paid | | currency* | string | Currency of the order. Currently only `INR` is supported. | | receipt | string | Your system order reference id. | -| payment | array | please refer this [doc](https://razorpay.com/docs/payments/payments/capture-settings/api/) for params | +| payment | array | please refer this [doc](https://razorpay.com/docs/payments/payments/capture-settings/api/) for params | **Response:**
```json @@ -386,6 +386,21 @@ $api->payment->createPaymentJson(array('amount' => 100,'currency' => 'INR','emai ``` **Parameters:** +| Name | Type | Description | +|-------------|---------|--------------------------------------| +| amount* | integer | Amount of the order to be paid | +| currency* | string | The currency of the payment (defaults to INR) | +| order_id* | string | The unique identifier of the order created. | +| email* | string | Email of the customer | +| contact* | string | Contact number of the customer | +| method* | string | Possible value is `card`, `netbanking`, `wallet`,`emi`, `upi`, `cardless_emi`, `paylater`. | +| card | array | All keys listed [here](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/#supported-payment-fields) are supported | +| bank | string | Bank code of the bank used for the payment. Required if the method is `netbanking`.| +| bank_account | array | All keys listed [here](https://razorpay.com/docs/payments/customers/customer-fund-account-api/#create-a-fund-account) are supported | +| vpa | string | Virtual payment address of the customer. Required if the method is `upi`. | +| wallet | string | Wallet code for the wallet used for the payment. Required if the method is `wallet`. | +| notes | array | A key-value pair | + please refer this [doc](https://razorpay.com/docs/payment-gateway/s2s-integration/payment-methods/) for params **Response:**
diff --git a/documents/plan.md b/documents/plan.md index cf6f42a6..f290808d 100644 --- a/documents/plan.md +++ b/documents/plan.md @@ -116,7 +116,7 @@ $api->plan->fetch($planId); | Name | Type | Description | |-------|-----------|--------------------------------------------------| -| planId | string | The id of the plan to be fetched | +| planId* | string | The id of the plan to be fetched | **Response:** ```json diff --git a/documents/registeremandate.md b/documents/registeremandate.md index 4f8b3788..e79b596b 100644 --- a/documents/registeremandate.md +++ b/documents/registeremandate.md @@ -46,7 +46,8 @@ $api->order->create(array('amount' => 100, 'currency' => 'INR', 'method'=>'emand | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) | | currency* | string | The currency of the payment (defaults to INR) | | customerId* | string | The id of the customer to be fetched | -| method* | string | Payment method used to make the registration transaction. Possible value is `emandate`. | +| payment_capture* | boolean | Indicates whether payment status should be changed to `captured` automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically.| +| method* | string | Payment method used to make the registration transaction. Possible value is `emandate`. | | receipt | string | Your system order reference id. | | token | array | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order) are supported | | notes | array | A key-value pair | @@ -72,7 +73,7 @@ $api->subscription->createSubscriptionRegistration(array('customer'=>array('name | Name | Type | Description | |-----------------|---------|---------------------------------------------------------------| -| customer | array | Details of the customer to whom the registration link will be sent. | +| customer | array | Details of the customer to whom the registration link will be sent. | | type* | array | the value is `link`. | | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) | | currency* | string | The currency of the payment (defaults to INR) | @@ -99,7 +100,8 @@ $api->order->create(array('amount' => '100', 'currency' => 'INR', 'receipt' => |-----------------|---------|------------------------------------------------------------------------------| | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) | | currency* | string | The currency of the payment (defaults to INR) | -| receipt | string | Your system order reference id. | +| receipt | string | Your system order reference id. | +| payment_capture* | boolean | Indicates whether payment status should be changed to `captured` automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically.| | notes | array | A key-value pair | **Response:** @@ -140,7 +142,7 @@ $api->payment->createRecurring(['email'=>'gaurav.kumar@example.com','contact'=>' | orderId* | string | The id of the order to be fetched | | customerId* | string | The id of the customer to be fetched | | tokenId* | string | The id of the token to be fetched | -| recurring* | boolean | Possible values is `0` or `1` | +| recurring* | boolean | Possible values is `0` or `1` | | description | string | A brief description of the payment. | | notes | array | A key-value pair | diff --git a/documents/registernach.md b/documents/registernach.md index 8dde9a87..67ba060e 100644 --- a/documents/registernach.md +++ b/documents/registernach.md @@ -241,6 +241,7 @@ $api->order->create(array('amount' => '100', 'currency' => 'INR', 'receipt' => | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) | | currency* | string | The currency of the payment (defaults to INR) | | receipt | string | Your system order reference id. | +| payment_capture | boolean | Indicates whether payment status should be changed to captured automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically. | | notes | array | A key-value pair | **Response:** diff --git a/documents/transfer.md b/documents/transfer.md index e682a7f8..9bb02a3f 100644 --- a/documents/transfer.md +++ b/documents/transfer.md @@ -3,7 +3,7 @@ ### Create transfers from payment ```php -$api->payment->fetch($paymentId)->transfer(array('transfers' => array('account'=> $accountId, 'amount'=> '1000', 'currency'=>'INR', 'notes'=> array('name'=>'Gaurav Kumar', 'roll_no'=>'IEC2011025'), 'linked_account_notes'=>array('branch'), 'on_hold'=>'1', 'on_hold_until'=>'1671222870'))); +$api->payment->fetch($paymentId)->transfer(array('transfers' => array(array('account' => 'acc_I0QRP7PpvaHhpB','amount' => 100,'currency' => 'INR','notes' => array ('name' => 'Gaurav Kumar','roll_no' => 'IEC2011025',),'linked_account_notes' => array ('roll_no'),'on_hold' => true,'on_hold_until' => 1671222870)))); ``` **Parameters:** @@ -411,7 +411,10 @@ $api->payment->fetch($paymentId)->refund(array('amount'=> '100','reverse_all'=>' ### Fetch payments of a linked account ```php -$api->payment->all(array('X-Razorpay-Account'=> $linkedAccountId)); + +$api->setHeader('X-Razorpay-Account', 'acc_IRQWUleX4BqvYn'); + +$api->payment->all(); ``` **Parameters:** @@ -490,7 +493,7 @@ $api->transfer->fetch($transferId)->reverse(array('amount'=>'100')); ### Hold settlements for transfers ```php -$api->payment->fetch($paymentId)->transfer(array('account' => $accountId, 'amount' => 500, 'currency' => 'INR','on_hold'=>'1')); +$api->payment->fetch($paymentId)->transfer(array('transfers' => array(array('account' => 'acc_I0QRP7PpvaHhpB','amount' => 100,'currency' => 'INR','on_hold' => true)))); ``` **Parameters:** @@ -531,15 +534,16 @@ $api->payment->fetch($paymentId)->transfer(array('account' => $accountId, 'amoun ### Modify settlement hold for transfers ```php -$api->transfer->fetch($paymentId)->edit(array('on_hold' => '1', 'on_hold_until' => '1679691505')); +$api->transfer->fetch($transferId)->edit(array('on_hold' => '1', 'on_hold_until' => '1679691505')); ``` **Parameters:** | Name | Type | Description | |---------------|-------------|---------------------------------------------| -| paymentId* | string | The id of the payment to be fetched | -| transfers | array | All parameters listed here https://razorpay.com/docs/api/route/#hold-settlements-for-transfers are supported | +| transferId* | string | The id of the transfer to be fetched | +| on_hold* | boolean | Possible values is `0` or `1` | +| on_hold_until | integer | Timestamp, in Unix, that indicates until when the settlement of the transfer must be put on hold | **Response:** ```json diff --git a/documents/upi.md b/documents/upi.md index d0d9ce94..5117f0d5 100644 --- a/documents/upi.md +++ b/documents/upi.md @@ -428,8 +428,8 @@ $api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contac | customer_id* | string | The `customer_id` for the customer you want to charge. | | token* | string | The `token_id` generated when the customer successfully completes the authorization payment. Different payment instruments for the same customer have different `token_id`.| | recurring* | string | Determines if recurring payment is enabled or not. Possible values:
* `1` - Recurring is enabled.* `0` - Recurring is not enabled.| -| description* | string | A user-entered description for the payment.| -| notes* | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | +| description | string | A user-entered description for the payment.| +| notes | array | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. | **Response:** ```json diff --git a/documents/virtualaccount.md b/documents/virtualaccount.md index 93fa20db..dc58d24e 100644 --- a/documents/virtualaccount.md +++ b/documents/virtualaccount.md @@ -113,7 +113,7 @@ $api->virtualAccount->create(array('receivers' => array('types'=> array('bank_ac ### Create static/dynamic qr ```php -$api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'amount_expected' => 100, 'notes' => array('receiver_key' => 'receiver_value'))); +$api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code','customer_id'=> 'cust_IOyIY3JvbVny9o', 'amount_expected' => 100, 'notes' => array('receiver_key' => 'receiver_value'))); ``` **Parameters:** @@ -123,7 +123,8 @@ $api->virtualAccount->create(array('receivers' => array('types' => array('qr_cod | receivers* | array | Array that defines what receivers are available for this Virtual Account | | description | string | A brief description of the payment. | | amount_expected | integer | The maximum amount you expect to receive in this virtual account. Pass `69999` for ₹699.99. | -| notes | array | All keys listed [here](https://razorpay.com/docs/payments/payments/payment-methods/bharatqr/api/#create) are supported | +| customer_id | string | Unique identifier of the customer to whom the virtual account must be tagged. | +| notes | object | All keys listed [here](https://razorpay.com/docs/payments/payments/payment-methods/bharatqr/api/#create) are supported | **Response:** ```json @@ -389,7 +390,7 @@ For add receiver to an existing virtual account response please click [here](htt ### Add an Allowed Payer Account ```php -$api->virtualAccount->fetch($virtualId)->addAllowedPayer(array('types' => 'bank_account','bank_account' => array('ifsc'=>'UTIB0000013','account_number'=>'914010012345679'))); +$api->virtualAccount->fetch($virtualId)->addAllowedPayer(array('type' => 'bank_account','bank_account' => array('ifsc'=>'UTIB0000013','account_number'=>'914010012345679'))); ``` **Parameters:** @@ -397,6 +398,7 @@ $api->virtualAccount->fetch($virtualId)->addAllowedPayer(array('types' => 'bank_ | Name | Type | Description | |-------|-----------|--------------------------------------------------| | virtualId* | string | The id of the virtual to be updated | +| type* | string | Possible value is `bank_account` | | bank_account* | array | Indicates the bank account details such as `ifsc` and `account_number` | **Response:** From dabdf8b40996ef8944af8a472c6a56604e36c410 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 29 Apr 2022 16:15:33 +0530 Subject: [PATCH 08/11] update changelog & readme --- CHANGELOG.md | 6 ++++++ README.md | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60205fb4..0681d3a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachange ## Unreleased +## [2.9.0] - 2022-04-29 +- PHP v8.1 is officially supported +- Update [Request] (https://github.com/WordPress/Requests/tree/v2.0.0) library to v2.0 +- Improve documentation +- Add PHPUnit v9 + ## [2.8.2] - 2022-03-08 - Change name convention to standard in Unit test diff --git a/README.md b/README.md index 1c939123..c905ea11 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # razorpay-php -[![Build Status](https://travis-ci.org/razorpay/razorpay-php.svg?branch=master)](https://travis-ci.org/razorpay/razorpay-php) [![Latest Stable Version](https://poser.pugx.org/razorpay/razorpay/v/stable.svg)](https://packagist.org/packages/razorpay/razorpay) [![License](https://poser.pugx.org/razorpay/razorpay/license.svg)](https://packagist.org/packages/razorpay/razorpay) +[![Build Status](https://travis-ci.org/razorpay/razorpay-php.svg?branch=master)](https://travis-ci.org/razorpay/razorpay-php) [![Stable](https://img.shields.io/badge/stable-v2.8.0-blue.svg)](https://packagist.org/packages/razorpay/razorpay#2.8.0) [![License](https://poser.pugx.org/razorpay/razorpay/license.svg)](https://packagist.org/packages/razorpay/razorpay) Official PHP library for [Razorpay API](https://docs.razorpay.com/docs/payments). Read up here for getting started and understanding the payment flow with Razorpay: ### Prerequisites -- A minimum of PHP 5.3 is required +- A minimum of PHP 7.3 upto 8.1 ## Installation @@ -59,12 +59,13 @@ The resources can be accessed via the `$api` object. All the methods invocations - [Settlements](documents/settlement.md) - [Refunds](documents/refund.md) - [Invoice](documents/invoice.md) +- [Plan](documents/plan.md) - [Item](documents/item.md) - [Subscriptions](documents/subscription.md) - [Add-on](documents/addon.md) - [Payment Links](documents/paymentLink.md) - [Smart Collect](documents/virtualaccount.md) -- [Route](documents/transfer.md) +- [Transfer](documents/transfer.md) - [QR Code](documents/qrcode.md) - [Emandate](documents/emandate.md) - [Cards](documents/card.md) From 11dbfe7a6d693a312ec63b909c17dfedec6b21d7 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 29 Apr 2022 16:27:20 +0530 Subject: [PATCH 09/11] version change --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0681d3a5..c0918ae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachange ## Unreleased -## [2.9.0] - 2022-04-29 +## [2.8.3] - 2022-04-29 - PHP v8.1 is officially supported - Update [Request] (https://github.com/WordPress/Requests/tree/v2.0.0) library to v2.0 - Improve documentation From 773c21b3d123297d66c6273b54f307284b9a68c5 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 29 Apr 2022 16:33:05 +0530 Subject: [PATCH 10/11] fix changelog comment --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0918ae8..877b28d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachange ## Unreleased ## [2.8.3] - 2022-04-29 + - PHP v8.1 is officially supported -- Update [Request] (https://github.com/WordPress/Requests/tree/v2.0.0) library to v2.0 +- Update [Request](https://github.com/WordPress/Requests/tree/v2.0.0) library to v2.0 - Improve documentation - Add PHPUnit v9 From cd97171f68a46067559d1a83e0b4478b33abbc97 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 29 Apr 2022 16:36:06 +0530 Subject: [PATCH 11/11] version bump --- src/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index cc0ca018..d62172c9 100644 --- a/src/Api.php +++ b/src/Api.php @@ -16,7 +16,7 @@ class Api */ public static $appsDetails = array(); - const VERSION = '2.8.2'; + const VERSION = '2.8.3'; /** * @param string $key