Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 210 additions & 0 deletions razorpay-php/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# Change Log

Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachangelog.com/en/1.0.0/) for formatting.

## Unreleased

## [2.8.1] - 2021-11-08

### Added

- Added Item Api
- Added Unit Tests

## [2.8.0][2.8.0] - 2021-10-07

### Added
- QR code end point API [[#235](https://github.com/razorpay/razorpay-php/pull/235)]
- Update, cancel, create subscription link,fetch details of a Pending Update,cancel, pause and resume subscription API[[#236](https://github.com/razorpay/razorpay-php/pull/236)]
- Smart Collect(Virtual Account) TPV API's [[#238](https://github.com/razorpay/razorpay-php/pull/238)]
- Add/Delete TPV Bank Account [[#239](https://github.com/razorpay/razorpay-php/pull/239)]
- Card end point api [[#240](https://github.com/razorpay/razorpay-php/pull/240)]
- Route end point api [[#241](https://github.com/razorpay/razorpay-php/pull/241)]
- Register emandate and charge first payment together [[#245](https://github.com/razorpay/razorpay-php/pull/245)]
- PaperNACH/Register NACH and charge first payment together [[#246](https://github.com/razorpay/razorpay-php/pull/246)]
- Added payment and Settlements methods [[#247](https://github.com/razorpay/razorpay-php/pull/247)]
- Added edit and notify API's for payment links [[#248](https://github.com/razorpay/razorpay-php/pull/248)]
- Added fetch, fetch multiple refund,edit and notify API's for refunds [[#250](https://github.com/razorpay/razorpay-php/pull/250)]
- Added edit order API [[#251](https://github.com/razorpay/razorpay-php/pull/251)]
- Fund API's end point [[#252](https://github.com/razorpay/razorpay-php/pull/252)]
- UPI [[#253](https://github.com/razorpay/razorpay-php/pull/253)]
- Added payment link paymentverification [[#255](https://github.com/razorpay/razorpay-php/pull/255)]
- Update readme file [[#254](https://github.com/razorpay/razorpay-php/pull/254)]

## [2.7.1][2.7.1] - 2021-09-16

### Added

- Added Payment Link end point API [[#233](https://github.com/razorpay/razorpay-php/pull/233)]

## [2.7.0][2.7.0] - 2021-05-07

### Added

- Adds support for payment page enity API [[#224](https://github.com/razorpay/razorpay-php/pull/224)]

## [2.6.1][2.6.1] - 2021-04-30

### Changed

- Upgrades [requests](https://github.com/rmccue/Requests/) to v1.8. [[#221](https://github.com/razorpay/razorpay-php/pull/221)]

## [2.6.0][2.6.0] - 2021-04-05

### Added

- Adds support for webhook enity API [[#212](https://github.com/razorpay/razorpay-php/pull/212)]

## [2.4.0-beta][2.4.0-beta] - 2018-11-28

### Changed

- Upgrades [requests](https://github.com/rmccue/Requests/) to v1.7. [[#89](https://github.com/razorpay/razorpay-php/pull/89)]
- Enforces TLS1.1+ for all requests. Workaround for a bug in RHEL 6. [[#76](https://github.com/razorpay/razorpay-php/pull/76)]

## [2.3.0][2.3.0] - 2018-09-15

### Added

- Add parameters to Subscription Cancel API
- Support for fetching Settlements

## [2.2.1][2.2.1] - 2018-05-28

### Added

- Support for fetching all customer entities

## [2.2.0][2.2.0] - 2017-10-23

### Added

- Support for VirtualAccount entity
- Support for Subscriptions

## [2.1.0][2.1.0] - 2017-10-10

### Added

- Support for new actions(cancel, notifyBy, edit, issue, delete) on invoices
- Removes PHP 5.3 from list of versions to test build against

## [2.0.2][2.0.2] - 2017-08-03

### Added

- Support for creating and fetching Transfers
- Support for creating Reversals on transfers

## [2.0.1][2.0.1] - 2017-07-31

### Fixed

- Webhook signature verification
- Conditional require of Request class

## [2.0.0][2.0.0] - 2017-03-07

### Added

- Support for custom Application header
- Support for card entity
- Support for Webhook and Order Signature verification
- Support for direct refund creation via Razorpay\Api\Refund::create()
- Support for Utility functions via Razorpay\Api\Utility::verifyPaymentSignature and Razorpay\Api\Utility::verifyWebhookSignature
- Support for case insensitive error codes
- Support for 2xx HTTP status codes

### Changed

- Razorpay\Api\Payment::refunds() now returns a Razorpay\Api\Collection object instead of Razorpay\Api\Refund object
- Razorpay\Api\Api::$baseUrl, Razorpay\Api\Api::$key and Razorpay\Api\Api::$secret are now `protected` instead of `public`

## [1.2.9][1.2.9] - 2017-01-03

### Added

- Support for creating and fetching Invoices

## [1.2.8][1.2.8] - 2016-10-12

### Added

- Support for Customer and Token entities

## [1.2.7][1.2.7] - 2016-09-21

### Added

- Increases the request timeout to 30 seconds for all requests.

## [1.2.6][1.2.6] - 2016-03-28

### Added

- Adds better tracing when client is not able to recognize server response.

## [1.2.5][1.2.5] - 2016-03-28

### Added

- Add support for overriding request headers via setHeader

## [1.2.3][1.2.3] - 2016-02-24

### Added

- Add support for Orders

## [1.2.2][1.2.2] - 2016-02-17

### Changed

- Razorpay\Api\Request::checkErrors is now `protected` instead of `private`
- The final build is now leaner and includes just requests, instead of entire vendor directory

## [1.2.1][1.2.1] - 2016-01-21

### Added

- Add version.txt in release with current git tag
- This changelog file
- `Api\Request::getHeaders()` method

## [1.2.0][1.2.0] - 2015-10-23

### Added

- Add version string to User Agent

### Changed

- New release process that pushes pre-packaged zip files to GitHub

## 1.0.0 - 2015-01-18

### Added

- Initial Release

[unreleased]: https://github.com/razorpay/razorpay-php/compare/2.5.0...HEAD
[1.2.1]: https://github.com/razorpay/razorpay-php/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/razorpay/razorpay-php/compare/1.1.0...1.2.0
[1.2.2]: https://github.com/razorpay/razorpay-php/compare/1.2.1...1.2.2
[1.2.3]: https://github.com/razorpay/razorpay-php/compare/1.2.2...1.2.3
[1.2.4]: https://github.com/razorpay/razorpay-php/compare/1.2.3...1.2.4
[1.2.5]: https://github.com/razorpay/razorpay-php/compare/1.2.4...1.2.5
[1.2.6]: https://github.com/razorpay/razorpay-php/compare/1.2.5...1.2.6
[1.2.7]: https://github.com/razorpay/razorpay-php/compare/1.2.6...1.2.7
[1.2.8]: https://github.com/razorpay/razorpay-php/compare/1.2.7...1.2.8
[1.2.9]: https://github.com/razorpay/razorpay-php/compare/1.2.8...1.2.9
[2.0.0]: https://github.com/razorpay/razorpay-php/compare/1.2.9...2.0.0
[2.0.1]: https://github.com/razorpay/razorpay-php/compare/2.0.0...2.0.1
[2.0.2]: https://github.com/razorpay/razorpay-php/compare/2.0.1...2.0.2
[2.1.0]: https://github.com/razorpay/razorpay-php/compare/2.0.2...2.1.0
[2.2.0]: https://github.com/razorpay/razorpay-php/compare/2.1.0...2.2.0
[2.2.1]: https://github.com/razorpay/razorpay-php/compare/2.2.0...2.2.1
[2.3.0]: https://github.com/razorpay/razorpay-php/compare/2.2.1...2.3.0
[2.4.0-beta]: https://github.com/razorpay/razorpay-php/compare/2.3.0...2.4.0-beta
[2.5.0]: https://github.com/razorpay/razorpay-php/compare/2.4.0-beta...2.5.0
[2.8.0]: https://github.com/razorpay/razorpay-php/compare/2.7.1...2.8.0
110 changes: 67 additions & 43 deletions razorpay-php/README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,95 @@

[![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)

Razorpay client PHP Api. The api follows the following practices:
Official PHP library for [Razorpay API](https://docs.razorpay.com/docs/payments).

- namespaced under Razorpay\Api
- call $api->class->function() to access the api
- api throws exceptions instead of returning errors
- options are passed as an array instead of multiple arguments wherever possible
- All request and responses are communicated over JSON
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

# Installation

- If your project uses composer, add following to composer.json
```json
{
"require": {
"razorpay/razorpay": "1.*"
}
}
## Installation

- If your project using composer, run the below command

```
composer require razorpay/razorpay:2.*
```

- If you are not using composer, download the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases).
**You should download the `razorpay-php.zip` file**.
After that, include `Razorpay.php` in your application and you can use the API as usual.

Then, run `composer update`. If you are not using composer, download
the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases).
**You should download the `razorpay-php.zip` file**.
##Note:
This PHP library follows the following practices:

After that include `Razorpay.php` in your application and you can use the
API as usual.
- Namespaced under `Razorpay\Api`
- API throws exceptions instead of returning errors
- Options are passed as an array instead of multiple arguments wherever possible
- All requests and responses are communicated over JSON

# Usage
## Documentation

Documentation of Razorpay's API and their usage is available at <https://docs.razorpay.com>

## Basic Usage

Instantiate the razorpay php instance with `key_id` & `key_secret`. You can obtain the keys from the dashboard app ([https://dashboard.razorpay.com/#/app/keys](https://dashboard.razorpay.com/#/app/keys))

```php
use Razorpay\Api\Api;

$api = new Api($api_key, $api_secret);
$api->payment->all($options); // Returns array of payment objects
$payment = $api->payment->fetch($id); // Returns a particular payment
$api->payment->fetch($id)->capture(array('amount'=>$amount)); // Captures a payment
$api->payment->fetch($id)->refund(); // Refunds a payment
$api->payment->fetch($id)->refund(array('amount'=>$refundAmount)); // Partially refunds a payment

// To get the payment details
echo $payment->amount;
echo $payment->currency;
// And so on for other attributes
```

For further help, see our documentation on <https://docs.razorpay.com>.

[composer-install]: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
The resources can be accessed via the `$api` object. All the methods invocations follows the following pattern

## Developing
```php
// $api->class->function() to access the API
//Example
$api->payment->fetch($paymentId);
```
## Supported Resources
- [Customer](documents/customer.md)
- [Token](documents/token.md)
- [Order](documents/order.md)
- [Payments](documents/payment.md)
- [Settlements](documents/settlement.md)
- [Refunds](documents/refund.md)
- [Invoice](documents/invoice.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)
- [QR Code](documents/qrcode.md)
- [Emandate](documents/emandate.md)
- [Cards](documents/card.md)
- [Paper NACH](documents/papernach.md)
- [UPI](documents/upi.md)
- [Register Emandate and Charge First Payment Together](documents/registeremandate.md)
- [Register NACH and Charge First Payment Together](documents/registernach.md)
- [Payment Verification](documents/paymentVerfication.md)

## Development

See the [doc.md](doc.md) file for getting started with development.

## License

The Razorpay PHP SDK is released under the MIT License.

## Release

Steps to follow for a release:

0. Merge the branch with the new code to master.
1. Bump the Version in `src/Api.php`.
2. Rename Unreleased to the new tag in `CHANGELOG`
3. Fix links at bottom in `CHANGELOG`
4. Commit
5. Tag the release and push to GitHub
6. Create a release on GitHub using the website with more details about the release
2. Rename Unreleased to the new tag in `CHANGELOG.md`
3. Add a new empty "Unreleased" section at the top of `CHANGELOG.md`
4. Fix links at bottom in `CHANGELOG.md`
5. Commit
6. Tag the release and push to GitHub
7. A release should automatically be created once the travis build passes. Edit the release to add some description.

## License

The Razorpay PHP SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details.
22 changes: 18 additions & 4 deletions razorpay-php/Razorpay.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
<?php

// Include Requests
require_once __DIR__.'/libs/Requests-1.6.1/library/Requests.php';
// Include Requests only if not already defined
if (class_exists('Requests') === false)
{
require_once __DIR__.'/libs/Requests-1.8.0/library/Requests.php';
}

try
{
Requests::register_autoloader();

// Register requests autoloader
Requests::register_autoloader();
if (version_compare(Requests::VERSION, '1.6.0') === -1)
{
throw new Exception('Requests class found but did not match');
}
}
catch (\Exception $e)
{
throw new Exception('Requests class found but did not match');
}

spl_autoload_register(function ($class)
{
Expand Down
Loading