Skip to content

Commit

Permalink
Merge pull request #289 from razorpay/new_version
Browse files Browse the repository at this point in the history
new version update
  • Loading branch information
ankitdas13 authored Apr 29, 2022
2 parents f36ad5e + cd97171 commit 1ae60f9
Show file tree
Hide file tree
Showing 48 changed files with 271 additions and 193 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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
- Improve documentation
- Add PHPUnit v9

## [2.8.2] - 2022-03-08

- Change name convention to standard in Unit test
Expand Down
20 changes: 20 additions & 0 deletions Deprecated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Backwards compatibility layer for Requests.
*
* Allows for Composer to autoload the old PSR-0 classes via the custom autoloader.
* This prevents issues with _extending final classes_ (which was the previous solution).
*
* Please see the Changelog for the 2.0.0 release for upgrade notes.
*
* @package Requests
*
* @deprecated 2.0.0 Use the PSR-4 class names instead.
*/
define("REQUESTS_SILENCE_PSR0_DEPRECATIONS",true);

if (class_exists('WpOrg\Requests\Autoload') === false) {
require_once __DIR__. 'libs/Requests-2.0.0/src/Autoload.php';
}

WpOrg\Requests\Autoload::register();
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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: <https://docs.razorpay.com/docs/getting-started>

### Prerequisites
- A minimum of PHP 5.3 is required
- A minimum of PHP 7.3 upto 8.1


## Installation
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions Razorpay.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

// Include Requests only if not already defined
const REQUESTS_SILENCE_PSR0_DEPRECATIONS = true;

if (class_exists('Requests') === false)
{
require_once __DIR__.'/libs/Requests-1.8.0/library/Requests.php';
require_once __DIR__.'/libs/Requests-2.0.0/src/Autoload.php';
}

try
{
Requests::register_autoloader();
WpOrg\Requests\Autoload::register();

if (version_compare(Requests::VERSION, '1.6.0') === -1)
{
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
"license": "MIT",
"require": {
"php": ">=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"]
}
}
6 changes: 6 additions & 0 deletions documents/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
4 changes: 2 additions & 2 deletions documents/card.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions documents/customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
8 changes: 5 additions & 3 deletions documents/emandate.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -353,8 +355,8 @@ $api->payment->createRecurring(array('email'=>'[email protected]','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:<br>* `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
Expand Down
2 changes: 1 addition & 1 deletion documents/fund.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion documents/invoice.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]','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' => '[email protected]','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`
Expand Down
8 changes: 2 additions & 6 deletions documents/item.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:**
Expand Down
3 changes: 2 additions & 1 deletion documents/order.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
4 changes: 2 additions & 2 deletions documents/papernach.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ $api->payment->createRecurring(array('email'=>'[email protected]','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:<br>* `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
Expand Down
17 changes: 16 additions & 1 deletion documents/payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:** <br>
```json
Expand All @@ -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:** <br>
Expand Down
2 changes: 1 addition & 1 deletion documents/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 1ae60f9

Please sign in to comment.