Subiendo proyecto completo sin restricciones de git ignore

This commit is contained in:
Jose Sanchez
2023-08-17 11:44:02 -04:00
parent a0d4f5ba3b
commit 20f1c60600
19921 changed files with 2509159 additions and 45 deletions

14
vendor/razorpay/razorpay/.editorconfig vendored Normal file
View File

@@ -0,0 +1,14 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[**.php]
indent_style = space
indent_size = 4

View File

@@ -0,0 +1,39 @@
name: feature.md
description: Submit a proposal for a new feature
title: '[Feature]: '
labels: [':rocket: Feature Request']
body:
- type: markdown
attributes:
value: |
### Thank you for taking the time to suggest a new feature!
We kindly ask that you search to see if an issue [already exists](https://github.com/razorpay/razorpay-php/issues?q=is%3Aissue+sort%3Acreated-desc+) for your feature.
We are also happy to accept contributions from our users.
- type: textarea
id: description
attributes:
label: '🚀 Feature Proposal'
description:
validations:
required: true
- type: textarea
id: solution
attributes:
label: Suggested Solution
description:
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives
description:
validations:
required: false
- type: textarea
id: extra
attributes:
label: Additional Information
description:
validations:
required: true

View File

@@ -0,0 +1,62 @@
name: issue.md
description: Create a report to help us improve
labels: ["issue"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this issue report!
- type: textarea
id: repro-steps
attributes:
label: Steps to reproduce the behavior
description:
placeholder: |
1. Fetch a '...'
2. Update the '....'
3. See error
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: actual-behavior
attributes:
label: Actual behavior
description: A clear and concise description of what actually happen.
validations:
required: true
- type: textarea
id: code-snippets
attributes:
label: Code snippets
description: If applicable, add code snippets to help explain your problem.
render: Php
validations:
required: false
- type: input
id: language-version
attributes:
label: Php version
placeholder: Php v7.4
validations:
required: true
- type: input
id: lib-version
attributes:
label: Library version
placeholder: razorpay-php v2.8.4
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional Information
description: Add any other information about the problem here.
validations:
required: false

View File

@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
timezone: Asia/Calcutta

View File

@@ -0,0 +1,8 @@
## Note :- Please follow the below points while attaching test cases document link below:
### - If label `Tested` is added then test cases document URL is mandatory.
### - Link added should be a valid URL and accessible throughout the org.
### - If the branch name contains hotfix / revert by default the BVT workflow check will pass.
| Test Case Document URL |
|-----------------------------------------------|
| Please paste test case document link here.... |

View File

@@ -0,0 +1,37 @@
name: CI
on:
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up php 8.0
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: 'Create env file'
run: |
touch ${{ github.workspace }}/tests/.env
echo RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }} >> ${{ github.workspace }}/tests/.env
echo RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }} >> ${{ github.workspace }}/tests/.env
cat ${{ github.workspace }}/tests/.env
- name: Install dependencies
run: composer self-update && composer install && composer require vlucas/phpdotenv && composer dump-autoload
- name: Run tests and collect coverage
run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml .
env:
RAZORPAY_API_KEY: ${{ secrets.RAZORPAY_API_KEY }}
RAZORPAY_API_SECRET: ${{ secrets.RAZORPAY_API_SECRET }}
RAZORPAY_PARTNER_API_KEY: ${{ secrets.RAZORPAY_PARTNER_API_KEY }}
RAZORPAY_PARTNER_API_SECRET: ${{ secrets.RAZORPAY_PARTNER_API_SECRET }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

View File

@@ -0,0 +1,51 @@
name: SecurityChecks
on:
pull_request: {}
push:
branches: ["master"]
schedule:
- cron: '30 20 * * *'
jobs:
semgrep:
name: Scan
runs-on: [ubuntu-latest] # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner
steps:
- uses: actions/checkout@v2
- uses: returntocorp/semgrep-action@v1
with:
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
publishDeployment: 339
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
workflow_status:
runs-on: [ ubuntu-latest ] # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner
name: Update Status Check
needs: [ semgrep ]
if: always()
env:
githubCommit: ${{ github.event.pull_request.head.sha }}
steps:
- name: Set github commit id
run: |
if [ "${{ github.event_name }}" = "push" ] || [ "${{ github.event_name }}" = "schedule" ]; then
echo "githubCommit=${{ github.sha }}" >> $GITHUB_ENV
fi
exit 0
- name: Failed
id: failed
if: (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && github.ref != 'refs/heads/master'
run: |
echo 'Failing the workflow for github security status check.'
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
-d '{ "state" : "failure" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
exit 1
- name: Success
if: steps.failed.conclusion == 'skipped' || github.ref != 'refs/heads/master'
run: |
echo 'Status check has passed!'
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
-d '{ "state" : "success" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
exit 0

5
vendor/razorpay/razorpay/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
composer.lock
phpunit.xml
vendor/
reports/
**/.DS_Store

View File

45
vendor/razorpay/razorpay/.travis.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
dist: precise
language: php
php:
- 7.3
- 7.4
- 8.0
- 8.1
install: composer install
before_script:
- cp phpunit.xml.dist phpunit.xml
# These two are required in the build step for non-composer-tests
- mkdir -p libs
- cd libs && wget https://github.com/rmccue/Requests/archive/v2.0.4.zip -O requests.zip && unzip requests.zip && rm requests.zip && cd ..
- rm -rf libs/Requests-2.0.4/examples libs/Requests-2.0.4/docs libs/Requests-2.0.4/bin libs/Requests-2.0.4/tests
script:
# Run a syntax validation check on all PHP files
- find . -path ./vendor -prune -o -iname '*.php' |xargs -n1 php -l
- ./vendor/bin/phpunit
notifications:
slack:
secure: fLT1x7BCXi8+sP1Qk1lP74+60JIBCw2clUTSOmB0OuoQGWYIJ4qelKcGH5FFsADGuC1GX2pf0fKRiLdavVrGpBkD4MGFPpyYKPYb0S/FyArN3PjdaNvAqE1VgQCtKkbugP5bHH9bp631+lo2EGQVLWTjlwiijWbCEyDu3L0YVMY=
# We are doing the releases for non-composer folks
# So this includes the vendor directory
before_deploy:
- echo $TRAVIS_TAG > version.txt
- cat release.txt |zip -r@ "razorpay-php.zip"
deploy:
provider: releases
# Otherwise, we lose the vendor/ directory
skip_cleanup: true
api_key:
secure: bHcu1jUASH6aVSD1LmzXdjQC4hc0o8EBbVs9X8e5j+/OC7+UuBBRu+jh6gQje/XWu9Nj1W2LkWhv0IKX1tJbcs0uRstggx+xC0ZayRzkscsqErqeM4WeyJjxe5ewb2eeGujtl9+WWFB3wpUQJtxXaaPuGYtroYGGYuI23wzKN4A=
# travis doesn't support multi file deployes yet, not that we need them
file: razorpay-php.zip
on:
# Only do the release for one build every tag
php: 7.3
# GitHub refuses to accept releases that are not tagged
tags: true
# Allow builds for non-master branches as well
all_branches: true
# Only do the releases if the repo is not a fork
repo: razorpay/razorpay-php

243
vendor/razorpay/razorpay/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,243 @@
# Change Log
Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachangelog.com/en/1.0.0/) for formatting.
## Unreleased
## [2.8.6] - 2023-06-16
[#348](https://github.com/razorpay/razorpay-php/pull/348) [`68b2028`](https://github.com/razorpay/razorpay-php/commit/68b2028bafda49af970a098d6d11aa8e5a575d40) feat: Added new API endpoints
* Added account onboarding API (create, fetch, edit, delete)
* Added stakeholders API (create, fetch, fetchAll, edit)
* Added product configuration API (requestProductConfiguration, fetch, edit, fetchTnc)
* Added webhooks API (create, fetch, fetchAll, edit, delete)
* Added token sharing API (create, fetch, delete, processPaymentOnAlternatePAorPG)
## [2.8.5] - 2022-10-19
### Added
- Update [Request](https://github.com/WordPress/Requests/tree/v2.0.4) library to v2.0.4
## [2.8.4] - 2022-06-28
- New APIs for Third party validation (createUpi, validateVpa, fetchPaymentMethods)
- Update documentation
## [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
- Removed test api key due to security concern from test cases
## [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
[2.8.1]: https://github.com/razorpay/razorpay-php/compare/2.8.0...2.8.1
[2.8.2]: https://github.com/razorpay/razorpay-php/compare/2.8.0...2.8.2

20
vendor/razorpay/razorpay/Deprecated.php vendored Normal file
View File

@@ -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.4 release for upgrade notes.
*
* @package Requests
*
* @deprecated 2.0.4 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.4/src/Autoload.php';
}
WpOrg\Requests\Autoload::register();

7
vendor/razorpay/razorpay/LICENSE vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2019 Razorpay
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

102
vendor/razorpay/razorpay/README.md vendored Normal file
View File

@@ -0,0 +1,102 @@
# razorpay-php
[![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 7.3 upto 8.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.
##Note:
This PHP library follows the following practices:
- 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
## 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);
```
The resources can be accessed via the `$api` object. All the methods invocations follows the following pattern
```php
// $api->class->function() to access the API
//Example
$api->payment->fetch($paymentId);
```
## Supported Resources
- [Account](documents/account.md)
- [Customer](documents/customer.md)
- [Token](documents/token.md)
- [Order](documents/order.md)
- [Payments](documents/payment.md)
- [Settlements](documents/settlement.md)
- [Refunds](documents/refund.md)
- [Fund](documents/fund.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)
- [Product Configuration](documents/productConfiguration.md)
- [Smart Collect](documents/virtualaccount.md)
- [Stakeholder](documents/stakeholder.md)
- [Transfer](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)
- [Webhook](documents/webhook.md)
## Development
See the [doc.md](doc.md) file for getting started with development.
## 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.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.

60
vendor/razorpay/razorpay/Razorpay.php vendored Normal file
View File

@@ -0,0 +1,60 @@
<?php
// Include Requests only if not already defined
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS'))
{
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
}
if (class_exists('WpOrg\Requests\Autoload') === false)
{
require_once __DIR__.'/libs/Requests-2.0.4/src/Autoload.php';
}
try
{
WpOrg\Requests\Autoload::register();
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)
{
// project-specific namespace prefix
$prefix = 'Razorpay\Api';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0)
{
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
//
// replace the namespace prefix with the base directory,
// replace namespace separators with directory separators
// in the relative class name, append with .php
//
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file))
{
require $file;
}
});

41
vendor/razorpay/razorpay/composer.json vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "razorpay/razorpay",
"description": "Razorpay PHP Client Library",
"keywords": ["razorpay", "api", "php", "client"],
"authors": [
{
"name": "Abhay Rana",
"email": "nemo@razorpay.com",
"homepage": "https://captnemo.in",
"role": "Developer"
},
{
"name": "Shashank Kumar",
"email": "shashank@razorpay.com",
"role": "Developer"
}
],
"support": {
"email": "contact@razorpay.com",
"issues": "https://github.com/Razorpay/razorpay-php/issues",
"source": "https://github.com/Razorpay/razorpay-php"
},
"homepage": "https://docs.razorpay.com",
"license": "MIT",
"require": {
"php": ">=7.3",
"rmccue/requests": "^2.0",
"ext-json": "*"
},
"require-dev": {
"raveren/kint": "1.*",
"phpunit/phpunit": "^9"
},
"autoload": {
"psr-4": {
"Razorpay\\Api\\": "src/",
"Razorpay\\Tests\\": "tests/"
},
"files" : ["Deprecated.php"]
}
}

48
vendor/razorpay/razorpay/doc.md vendored Normal file
View File

@@ -0,0 +1,48 @@
This document talks about the implementation of the code for the Api.
Everything comes under namespace Razorpay\Api\.
Namespaces put a requirement of PHP 5.3 minimum
```php
namespace Razorpay\
class Api
{
// Contains a __get function that returns the appropriate
// class object when one tries to access them.
}
namespace Razorpay\
class Client
{
// Handles request and response
// Uses Composer:Requests internally
}
class Payment
{
public function get($id)
{
}
public function fetch($options)
{
}
public function capture($id)
{
}
public function refund($id)
{
}
}
```

View File

@@ -0,0 +1,387 @@
## Account
### Create an Account
```php
$api->account->create(array(
"email" => "gauriagain.kumar@example.org",
"phone" => "9000090000",
"legal_business_name" => "Acme Corp",
"business_type" => "partnership",
"customer_facing_business_name" => "Example",
"profile" => array(
"category" => "healthcare",
"subcategory" => "clinic",
"description" => "Healthcare E-commerce platform",
"addresses" => array(
"operation" => array(
"street1" => "507, Koramangala 6th block",
"street2" => "Kormanagala",
"city" => "Bengaluru",
"state" => "Karnataka",
"postal_code" => 560047,
"country" => "IN"
),
"registered" => array(
"street1" => "507, Koramangala 1st block",
"street2" => "MG Road",
"city" => "Bengaluru",
"state" => "Karnataka",
"postal_code" => 560034,
"country" => "IN"
)
),
"business_model" => "Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes."
),
"legal_info" => array(
"pan" => "AAACL1234C",
"gst" => "18AABCU9603R1ZM"
),
"brand" => array(
"color" => "FFFFFF"
),
"notes" => array(
"internal_ref_id" => "123123"
),
"contact_name" => "Gaurav Kumar",
"contact_info" => array(
"chargeback" => array(
"email" => "cb@example.org"
),
"refund" => array(
"email" => "cb@example.org"
),
"support" => array(
"email" => "support@example.org",
"phone" => "9999999998",
"policy_url" => "https://www.google.com"
)
),
"apps" => array(
"websites" => array(
"https://www.example.org"
),
"android" => array(
array(
"url" => "playstore.example.org",
"name" => "Example"
)
),
"ios" => array(
array(
"url" => "appstore.example.org",
"name" => "Example"
)
)
)
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| email* | string | The sub-merchant's business email address. |
| phone* | integer | The sub-merchant's business phone number. The minimum length is 8 characters and the maximum length is 15. |
| legal_business_name* | string | The name of the sub-merchant's business. For example, Acme Corp. The minimum length is 4 characters and the maximum length is 200. |
| customer_facing_business_name | string | The sub-merchant billing label as it appears on the Razorpay Dashboard. The minimum length is 1 character and the maximum length is 255. |
| business_type | string | The type of business operated by the sub-merchant.Possible value is `proprietorship`, `partnership`, `private_limited`, `public_limited`, `llp`, `ngo`, `trust`, `society`, `not_yet_registered`, `huf` |
| reference_id | string | Partner's external account reference id. The minimum length is 1 character and the maximum length is 512. |
| profile | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#create-an-account) are supported |
| legal_info | object | All keys listed [here](hhttps://razorpay.com/docs/api/partners/account-onboarding/#create-an-account) are supported |
| brand | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#create-an-account) are supported |
| notes | object | A key-value pair |
| contact_name* | string | The name of the contact. The minimum length is 4 and the maximum length is 255 characters. |
| contact_info | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#create-an-account) are supported |
| apps | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#create-an-account) are supported |
**Response:**
```json
{
"id": "acc_GRWKk7qQsLnDjX",
"type": "standard",
"status": "created",
"email": "gauriagain.kumar@example.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road",
"city": "Bengaluru",
"state": "KARNATAKA",
"postal_code": 560034,
"country": "IN"
},
"operation": {
"street1": "507, Koramangala 6th block",
"street2": "Kormanagalo",
"city": "Bengaluru",
"state": "KARNATAKA",
"country": "IN",
"postal_code": 560047
}
},
"business_model": "Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes."
},
"notes": {
"internal_ref_id": "123123"
},
"created_at": 1611136837,
"phone": "9000090000",
"business_type": "partnership",
"legal_business_name": "Acme Corp",
"customer_facing_business_name": "Example",
"legal_info": {
"pan": "AAACL1234C",
"gst": "18AABCU9603R1ZM"
},
"apps": {
"websites": [
"https://www.example.org"
],
"android": [
{
"url": "playstore.example.org",
"name": "Example"
}
],
"ios": [
{
"url": "appstore.example.org",
"name": "Example"
}
]
},
"brand": {
"color": "#FFFFFF"
},
"contact_info": {
"chargeback": {
"email": "cb@example.org",
"phone": null,
"policy_url": null
},
"refund": {
"email": "cb@example.org",
"phone": null,
"policy_url": null
},
"support": {
"email": "support@example.org",
"phone": "9999999998",
"policy_url": "https://www.google.com"
}
}
}
```
-------------------------------------------------------------------------------------------------------
### Edit Account
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->edit($accountId,array(
"customer_facing_business_name" => "ABCD Ltd"
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| phone | integer | The sub-merchant's business phone number. The minimum length is 8 characters and the maximum length is 15. |
| legal_business_name | string | The name of the sub-merchant's business. For example, Acme Corp. The minimum length is 4 characters and the maximum length is 200. |
| customer_facing_business_name | string | The sub-merchant billing label as it appears on the Razorpay Dashboard. The minimum length is 1 character and the maximum length is 255. |
| profile | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#update-an-account) are supported |
| legal_info | object | All keys listed [here](hhttps://razorpay.com/docs/api/partners/account-onboarding/#update-an-account) are supported |
| brand | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#update-an-account) are supported |
| notes | object | A key-value pair |
| contact_name* | string | The name of the contact. The minimum length is 4 and the maximum length is 255 characters. |
| contact_info | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#update-an-account) are supported |
| apps | object | All keys listed [here](https://razorpay.com/docs/api/partners/account-onboarding/#update-an-account) are supported |
**Response:**
```json
{
"id": "acc_GP4lfNA0iIMn5B",
"type": "standard",
"status": "created",
"email": "gauri@example.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road-1",
"city": "Bengalore",
"state": "KARNATAKA",
"postal_code": "560034",
"country": "IN"
}
}
},
"notes": [],
"created_at": 1610603081,
"phone": "9000090000",
"reference_id": "randomId",
"business_type": "partnership",
"legal_business_name": "Acme Corp",
"customer_facing_business_name": "ABCD Ltd"
}
```
-------------------------------------------------------------------------------------------------------
### Delete an account
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->delete($accountId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account that must be deleted. |
**Response:**
```json
{
"id": "acc_GXQAkO2MrvBYg4",
"type": "standard",
"status": "suspended",
"email": "gaurav.kumar@acme.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road",
"city": "Bengaluru",
"state": "KARNATAKA",
"postal_code": "560034",
"country": "IN"
},
"operation": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road",
"city": "Bengaluru",
"state": "KARNATAKA",
"country": "IN",
"postal_code": "560034"
}
},
"business_model": "Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes."
},
"notes": {
"internal_ref_id": "123123"
},
"created_at": 1612425180,
"suspended_at": 1612425235,
"phone": "9000090000",
"reference_id": "account_COdeRandom",
"business_type": "partnership",
"legal_business_name": "Acme Corp Pvt Ltd",
"customer_facing_business_name": "Acme",
"legal_info": {
"pan": "AAACL1234C",
"gst": "18AABCU9603R1ZM"
},
"apps": {
"websites": [
"https://www.acme.org"
],
"android": [
{
"url": "playstore.acme.org",
"name": "Acme"
}
],
"ios": [
{
"url": "appstore.acme.org",
"name": "Acme"
}
]
},
"brand": {
"color": "#FFFFFF"
},
"contact_name": "Gaurav Kumar",
"contact_info": {
"chargeback": {
"email": "cb@acme.org",
"phone": "9000090000",
"policy_url": "https://www.google.com"
},
"refund": {
"email": "cb@acme.org",
"phone": "9898989898",
"policy_url": "https://www.google.com"
},
"support": {
"email": "support@acme.org",
"phone": "9898989898",
"policy_url": "https://www.google.com"
}
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch an account
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch($accountId);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
**Response:**
```json
{
"id": "acc_GP4lfNA0iIMn5B",
"type": "standard",
"status": "created",
"email": "gauri@example.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road-1",
"city": "Bengalore",
"state": "KARNATAKA",
"postal_code": "560034",
"country": "IN"
}
}
},
"notes": [],
"created_at": 1610603081,
"phone": "9000090000",
"reference_id": "randomId",
"business_type": "partnership",
"legal_business_name": "Acme Corp",
"customer_facing_business_name": "Example Pvt. Ltd."
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/partners/account-onboarding/)**

View File

@@ -0,0 +1,167 @@
## Addons
### Create an addon
```php
$api->subscription->fetch($subscriptionId)->createAddon(array('item' => array('name' => 'Extra Chair', 'amount' => 30000, 'currency' => 'INR'), 'quantity' => 2));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | boolean | The subscription ID to which the add-on is being added. |
| items | array | All parameters listed [here](https://razorpay.com/docs/api/payments/subscriptions/#create-an-add-on) |
| quantity | integer | This specifies the number of units of the add-on to be charged to the customer. |
**Response:**
```json
{
"id":"ao_00000000000001",
"entity":"addon",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Extra appala (papadum)",
"description":"1 extra oil fried appala with meals",
"amount":30000,
"unit_amount":30000,
"currency":"INR",
"type":"addon",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1581597318,
"updated_at":1581597318
},
"quantity":2,
"created_at":1581597318,
"subscription_id":"sub_00000000000001",
"invoice_id":null
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all addons
```php
$api->addon->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the addons were created |
| to | timestamp | timestamp before which the addons were created |
| count | integer | number of addons to fetch (default: 10) |
| skip | integer | number of addons to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "ao_00000000000002",
"entity": "addon",
"item": {
"id": "item_00000000000002",
"active": true,
"name": "Extra sweet",
"description": "1 extra sweet of the day with meals",
"amount": 90000,
"unit_amount": 90000,
"currency": "INR",
"type": "addon",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1581597318,
"updated_at": 1581597318
},
"quantity": 1,
"created_at": 1581597318,
"subscription_id": "sub_00000000000001",
"invoice_id": "inv_00000000000001"
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch an addon
```php
$api->addon->fetch($addonId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| addonId* | string | addon id to be fetched |
**Response:**
```json
{
"id":"ao_00000000000001",
"entity":"addon",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Extra appala (papadum)",
"description":"1 extra oil fried appala with meals",
"amount":30000,
"unit_amount":30000,
"currency":"INR",
"type":"addon",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1581597318,
"updated_at":1581597318
},
"quantity":2,
"created_at":1581597318,
"subscription_id":"sub_00000000000001",
"invoice_id":null
}
```
-------------------------------------------------------------------------------------------------------
### Delete an addon
```php
$api->addon->fetch($addonId)->delete();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|--------------|
| addonId* | string | addon id to be deleted |
**Response:**
```json
[]
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/subscriptions/#add-ons)**

View File

@@ -0,0 +1,547 @@
## Cards
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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`|
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create Order
```php
$api->order->create(array('amount' => 100, 'currency' => 'INR', 'receipt' => '123', 'customer_id'=> $customerId, 'method'=>'card', 'token'=>array('max_amount'=>'5000', 'expire_at'=>'2709971120', 'frequency'=>'monthly'), 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 |
| receipt | string | Your system order reference id. |
| 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 |
**Response:**
```json
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":100,
"amount_paid":0,
"amount_due":100,
"currency":"INR",
"receipt":"Receipt No. 1",
"method":"card",
"description":null,
"customer_id":"cust_4xbQrmEoA5WJ01",
"token":{
"max_amount":5000,
"expire_at":2709971120,
"frequency":"monthly"
},
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1565172642
}
```
-------------------------------------------------------------------------------------------------------
### Create registration link
```php
$api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9123456780'),'type'=>'link','amount'=>100,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'card','max_amount'=>'500','expire_at'=>'1634215992'),'receipt'=>'Receipt No. 5','email_notify'=>1,'sms_notify'=>1,'expire_by'=>1634215992, 'notes'=> array('note_key 1'=> 'Beam me up Scotty','note_key 2'=> 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customer | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/cards/create-authorization-transaction/#121-create-a-registration-link) are supported |
| 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) |
| description* | string | A brief description of the payment. |
| subscription_registration | array | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/cards/authorization-transaction/#121-create-a-registration-link) are supported |
| receipt | string | Your system order reference id. |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "inv_FHrXGIpd3N17DX",
"entity": "invoice",
"receipt": "Receipt No. 24",
"invoice_number": "Receipt No. 24",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrXGJNngJyEAe",
"line_items": [],
"payment_id": null,
"status": "issued",
"expire_by": 4102444799,
"issued_at": 1595491014,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": "pending",
"email_status": "pending",
"date": 1595491014,
"terms": null,
"partial_payment": false,
"gross_amount": 100,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"currency_symbol": "₹",
"description": "Registration Link for Gaurav Kumar",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/VSriCfn",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491014,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
## Create an order to charge the customer
```php
$api->order->create(array('amount' => '100', 'currency' => 'INR', 'customer_id'=> $customerId, 'method'=>'card', 'receipt' => 'Receipt No. 1', 'token'=>array('max_amount'=>'5000', 'expire_at'=>'2709971120', 'frequency'=>'monthly'), 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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`. |
| 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 |
**Response:**
```json
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":100,
"amount_paid":0,
"amount_due":100,
"currency":"INR",
"receipt":"Receipt No. 1",
"method":"card",
"description":null,
"customer_id":"cust_4xbQrmEoA5WJ01",
"token":{
"max_amount":5000,
"expire_at":2709971120,
"frequency":"monthly"
},
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1565172642
}
```
-------------------------------------------------------------------------------------------------------
## Create a recurring payment
```php
$api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>$orderid,'customer_id'=>$customerId,'token'=>$tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar', 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address |
| contact* | string | The customer's phone number |
| 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) |
| 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` |
| description | string | A brief description of the payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/cards/authorization-transaction/#113-create-an-authorization-payment) for authorization payment
-------------------------------------------------------------------------------------------------------
## Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
| medium* | string | Possible values are `sms` or `email` |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
## Cancel registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
**Response:**
```json
{
"id": "inv_FHrfRupD2ouKIt",
"entity": "invoice",
"receipt": "Receipt No. 1",
"invoice_number": "Receipt No. 1",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrfRw4TZU5Q2L",
"line_items": [],
"payment_id": null,
"status": "cancelled",
"expire_by": 4102444799,
"issued_at": 1595491479,
"paid_at": null,
"cancelled_at": 1595491488,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491479,
"terms": null,
"partial_payment": false,
"gross_amount": 100,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"currency_symbol": "₹",
"description": "Registration Link for Gaurav Kumar",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/QlfexTj",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491480,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
## Fetch token by payment id
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
**Response:**
```json
{
"id": "pay_FHfqtkRzWvxky4",
"entity": "payment",
"amount": 100,
"currency": "INR",
"status": "captured",
"order_id": "order_FHfnswDdfu96HQ",
"invoice_id": null,
"international": false,
"method": "card",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": "card_F0zoXUp4IPPGoI",
"bank": null,
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_FHfn3rIiM1Z8nr",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"auth_code": "541898"
},
"created_at": 1595449871
}
```
-------------------------------------------------------------------------------------------------------
## Fetch tokens by customer id
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"token_HouA2OQR5Z2jTL",
"entity":"token",
"token":"2JPRk664pZHUWG",
"bank":null,
"wallet":null,
"method":"card",
"card":{
"entity":"card",
"name":"Gaurav Kumar",
"last4":"8950",
"network":"Visa",
"type":"credit",
"issuer":"STCB",
"international":false,
"emi":false,
"sub_type":"consumer",
"expiry_month":12,
"expiry_year":2021,
"flows":{
"otp":true,
"recurring":true
}
},
"recurring":true,
"recurring_details":{
"status":"confirmed",
"failure_reason":null
},
"auth_type":null,
"mrn":null,
"used_at":1629779657,
"created_at":1629779657,
"expired_at":1640975399,
"dcc_enabled":false,
"billing_address":null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch card
```php
$api->card->fetch($cardId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| cardId* | string | card id to be fetched |
```json
{
"id": "card_JXPULjlKqC5j0i",
"entity": "card",
"name": "Gaurav",
"last4": "4366",
"network": "Visa",
"type": "credit",
"issuer": "UTIB",
"international": false,
"emi": true,
"sub_type": "consumer",
"token_iin": null
}
```
-------------------------------------------------------------------------------------------------------
## Delete tokens
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
## Using Card Number/ Tokenised Card Number
```php
$api->card->requestCardReference(array("number" =>"4854980604708430"));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|------------------------------------------------------------------------------|
| number* | string | The card number whose PAR or network reference id should be retrieved. |
| tokenised | string | Determines if the card is saved as a token. Possible value is `true` or `false` |
**Response:**
```json
{
"network": "Visa",
"payment_account_reference": "V0010013819231376539033235990",
"network_reference_id": null
}
```
-------------------------------------------------------------------------------------------------------
## Using Razporpay token
```php
$api->card->requestCardReference(array("token" =>"token_4lsdksD31GaZ09"));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|------------------------------------------------------------------------------|
| token* | string | The token whose PAR or network reference id should be retrieved.|
**Response:**
```json
{
"network": "Visa",
"payment_account_reference": "V0010013819231376539033235990",
"network_reference_id": null
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/cards/authorization-transaction/)**

View File

@@ -0,0 +1,137 @@
## Customer
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780','notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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:**
```json
{
"id" : "cust_1Aa00000000004",
"entity": "customer",
"name" : "Gaurav Kumar",
"email" : "gaurav.kumar@example.com",
"contact" : "9123456780",
"gstin": "29XAbbA4369J1PA",
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at ": 1234567890
}
```
-------------------------------------------------------------------------------------------------------
### Edit customer
```php
$api->customer->fetch($customerId)->edit(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com', 'contact' => '9999999999'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be updated |
| email | string | Email of the customer |
| contact | string | Contact number of the customer |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all customer
```php
$api->customer->all($options);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"cust_1Aa00000000001",
"entity":"customer",
"name":"Gaurav Kumar",
"email":"gaurav.kumar@example.com",
"contact":"9876543210",
"gstin":"29XAbbA4369J1PA",
"notes":{
"note_key_1":"September",
"note_key_2":"Make it so."
},
"created_at ":1234567890
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a customer
```php
$api->customer->fetch($customerId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"id" : "cust_1Aa00000000001",
"entity": "customer",
"name" : "Saurav Kumar",
"email" : "Saurav.kumar@example.com",
"contact" : "+919000000000",
"gstin":"29XAbbA4369J1PA",
"notes" : [],
"created_at ": 1234567890
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/customers/)**

View File

@@ -0,0 +1,381 @@
## Emandates
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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 |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create order
```php
$api->order->create(array('amount' => 0,'currency' => 'INR','method' => 'emandate','payment_capture' => true, 'customer_id' => 'cust_JdumbHq5F3kKu6','receipt' => 'Receipt No. #19','notes' => array('notes_key_1' => 'Beam me up Scotty','notes_key_2' => 'Engage'),'token' => array('auth_type' => 'netbanking','max_amount' => 9999900,'expire_at' => 4102444799,'notes' => array('notes_key_1' => 'Tea, Earl Grey, Hot','notes_key_2' => 'Tea, Earl Grey… decaf.'),'bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '1121431121541121','account_type' => 'savings','ifsc_code' => 'HDFC0000001'))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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`. |
| 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. |
| token | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/create-authorization-transaction/#112-create-an-order) are supported|
| notes | object | A key-value pair |
**Response:**
Create order response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/authorization-transaction/#112-create-an-order)
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/emandate/authorization-transaction/#113-create-an-authorization-payment) for authorization payment
-------------------------------------------------------------------------------------------------------
### Create registration link
```php
$api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9123456780'),'type'=>'link','amount'=>0,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'emandate', 'auth_type'=>'netbanking', 'max_amount'=>'500', 'bank_account' => array('beneficiary_name' => 'Gaurav Kumar','account_number' => '1121431121541121','account_type' => 'savings','ifsc_code' => 'HDFC0001233'), 'expire_at'=>'1634215992'),'receipt'=>'Receipt No. 5','email_notify'=>1,'sms_notify'=>1,'expire_by'=>1634215992,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customer* | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/create-authorization-transaction/#121-create-a-registration-link) are supported |
| type* | string | In this case, the value is `link`. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| amount* | integer | The payment amount in the smallest currency sub-unit. |
| description* | string | A description that appears on the hosted page. For example, `12:30 p.m. Thali meals (Gaurav Kumar`). |
| subscription_registration | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/create-authorization-transaction/#121-create-a-registration-link) are supported |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| receipt | string | Your system order reference id. |
| notes | array | A key-value pair |
**Response:**
Create registration link response please click [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/create-authorization-transaction/#121-create-a-registration-link)
-------------------------------------------------------------------------------------------------------
### Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be notified |
| medium* | string | `sms`/`email`, Medium through which notification should be sent. |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
### Cancel a registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be cancelled |
**Response:**
```json
{
"id": "inv_FHrfRupD2ouKIt",
"entity": "invoice",
"receipt": "Receipt No. 1",
"invoice_number": "Receipt No. 1",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrfRw4TZU5Q2L",
"line_items": [],
"payment_id": null,
"status": "cancelled",
"expire_by": 4102444799,
"issued_at": 1595491479,
"paid_at": null,
"cancelled_at": 1595491488,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491479,
"terms": null,
"partial_payment": false,
"gross_amount": 100,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"currency_symbol": "₹",
"description": "Registration Link for Gaurav Kumar",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/QlfexTj",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491480,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
### Fetch token by payment ID
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| paymentId* | string | Id of the payment to be retrieved |
**Response:**
```json
{
"id": "pay_FHf9a7AO0iXM9I",
"entity": "payment",
"amount": 0,
"currency": "INR",
"status": "captured",
"order_id": "order_FHf9OwSeyetnKC",
"invoice_id": "inv_FHf9P2hhXEti7i",
"international": false,
"method": "emandate",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": null,
"bank": "HDFC",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_FHf9aAZR9hWJkq",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {},
"created_at": 1595447410
}
```
-------------------------------------------------------------------------------------------------------
### Fetch tokens by customer ID
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_FHf94Uym9tdYFJ",
"entity": "token",
"token": "2wDPM7VAlXtjAR",
"bank": "HDFC",
"wallet": null,
"method": "emandate",
"vpa": null,
"recurring": true,
"recurring_details": {
"status": "confirmed",
"failure_reason": null
},
"auth_type": "netbanking",
"mrn": null,
"used_at": 1595447381,
"created_at": 1595447381,
"bank_details": {
"beneficiary_name": "Gaurav Kumar",
"account_number": "1121431121541121",
"ifsc": "HDFC0000001",
"account_type": "savings"
},
"max_amount": 9999900,
"expired_at": 1689971140,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Delete token
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
### Create an order to charge the customer
```php
$api->order->create(array('amount' => 1000,'currency' => 'INR','payment_capture' => true,'receipt' => 'Receipt No. 1','notes'=> array('notes_key_1' => 'Tea, Earl Grey, Hot', 'notes_key_2' => 'Tea, Earl Grey… decaf.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 |
| 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
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":1000,
"amount_paid":0,
"amount_due":1000,
"currency":"INR",
"receipt":"Receipt No. 1",
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1579782776
}
```
-------------------------------------------------------------------------------------------------------
### Create a Recurring Payment
```php
$api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>'order_1Aa00000000002','customer_id'=>'cust_1Aa00000000001','token'=>'token_1Aa00000000001','recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar'));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address. |
| contact* | string | The customer's phone number. |
| amount* | integer | The amount you want to charge your customer. This should be the same as the amount in the order. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| order_id* | string | The unique identifier of the order created. |
| 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. |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/emandate/authorization-transaction/)**

View File

@@ -0,0 +1,79 @@
## Funds
### Create a fund account
```php
$api->fundAccount->create(array('customer_id'=>$customerId,'account_type'=>'bank_account','bank_account'=>array('name'=>'Gaurav Kumar', 'account_number'=>'11214311215411', 'ifsc'=>'HDFC0000053')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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 | All keys listed [here](https://razorpay.com/docs/payments/customers/customer-fund-account-api/#create-a-fund-account) are supported |
**Response:**
```json
{
"id": "fa_JcXaLomo4ck5IY",
"entity": "fund_account",
"customer_id": "cust_JZse2vlC5nK9AQ",
"account_type": "bank_account",
"bank_account": {
"ifsc": "HDFC0000053",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"notes": [],
"account_number": "11214311215411"
},
"batch_id": null,
"active": true,
"created_at": 1654154246
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all fund accounts
```php
$api->fundAccount->all(array('customer_id'=>$customerIds));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "fa_JcXYtecLkhW74k",
"entity": "fund_account",
"customer_id": "cust_JZse2vlC5nK9AQ",
"account_type": "bank_account",
"bank_account": {
"ifsc": "HDFC0000053",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"notes": [],
"account_number": "11214311215411"
},
"batch_id": null,
"active": true,
"created_at": 1654154163
}
]
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/payments/customers/customer-fund-account-api/)**

View File

@@ -0,0 +1,540 @@
## Invoices
### Create Invoice
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->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 |
|draft | string | Invoice is created in draft state when value is set to `1` |
| customer* | array | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
| line_items | array | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
|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`
```php
$api->invoice->create(array ('type' => 'invoice','date' => 1589994898, 'customer_id'=> 'cust_E7q0trFqXgExmT', 'line_items'=>array(array('item_id'=>'item_DRt61i2NnL8oy6'))));
```
**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 | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
| line_items | array | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| currency* (conditionally mandatory) | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
**Response:**
For create invoice response please click [here](https://razorpay.com/docs/api/invoices/#create-an-invoice)
-------------------------------------------------------------------------------------------------------
### Fetch all invoices
```php
$api->invoice->all();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|type | string | entity type (here its invoice) |
|payment_id | string | The unique identifier of the payment made by the customer against the invoice. |
|customer_id | string | The unique identifier of the customer. |
|receipt | string | The unique receipt number that you entered for internal purposes. |
**Response:**
For fetch all invoice response please click [here](https://razorpay.com/docs/api/invoices/#fetch-multiple-invoices)
-------------------------------------------------------------------------------------------------------
### Fetch invoice
```php
$api->invoice->fetch($invoiceId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
**Response:**
```json
{
"amount": 1000,
"amount_due": 1000,
"amount_paid": 0,
"billing_end": null,
"billing_start": null,
"cancelled_at": null,
"comment": null,
"created_at": 1653596202,
"currency": "INR",
"currency_symbol": "₹",
"customer_details": {
"billing_address": null,
"contact": "99991111999",
"customer_contact": "99991111999",
"customer_email": "gauraa.kumar@example.com",
"customer_name": "Gauravss Kumar",
"email": "gauraa.kumar@example.com",
"gstin": null,
"id": "cust_JDdNazagOgg9Ig",
"name": "Gauravss Kumar",
"shipping_address": null
},
"customer_id": "cust_JDdNazagOgg9Ig",
"date": 1589994898,
"description": null,
"email_status": "sent",
"entity": "invoice",
"expire_by": null,
"expired_at": null,
"first_payment_min_amount": null,
"gross_amount": 1000,
"group_taxes_discounts": false,
"id": "inv_JZz7g9hSZS9IsG",
"idempotency_key": null,
"invoice_number": null,
"issued_at": 1653596202,
"line_items": [
{
"amount": 1000,
"currency": "INR",
"description": null,
"gross_amount": 1000,
"hsn_code": null,
"id": "li_JZz7gAI2W3Arg2",
"item_id": "item_J7lZCyxMVeEtYB",
"name": "Test item",
"net_amount": 1000,
"quantity": 1,
"ref_id": null,
"ref_type": null,
"sac_code": null,
"tax_amount": 0,
"tax_inclusive": false,
"tax_rate": null,
"taxable_amount": 1000,
"taxes": [],
"type": "invoice",
"unit": null,
"unit_amount": 1000
}
],
"notes": [],
"order_id": "order_JZz7gBTZjtUgBO",
"paid_at": null,
"partial_payment": false,
"payment_id": null,
"receipt": null,
"reminder_status": null,
"short_url": "https://rzp.io/i/DGpanoT",
"sms_status": "pending",
"status": "issued",
"subscription_status": null,
"supply_state_code": null,
"tax_amount": 0,
"taxable_amount": 1000,
"terms": null,
"type": "invoice",
"user_id": null,
"view_less": true
}
```
-------------------------------------------------------------------------------------------------------
### Update invoice
```php
$api->invoice->fetch($invoiceId)->edit(array('line_items' => array(array('id' => 'li_DAweOizsysoJU6','name' => 'Book / English August - Updated name and quantity','quantity' => 1),array('name' => 'Book / A Wild Sheep Chase','amount' => 200,'currency' => 'INR','quantity' => 1)),'notes' => array('updated-key' => 'An updated note.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
| line_items | array | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#update-an-invoice) are supported |
| notes | array | key value pair |
**Response:**
```json
{
"id": "inv_DAweOiQ7amIUVd",
"entity": "invoice",
"receipt": "#0961",
"invoice_number": "#0961",
"customer_id": "cust_DAtUWmvpktokrT",
"customer_details": {
"id": "cust_DAtUWmvpktokrT",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9977886633",
"gstin": null,
"billing_address": {
"id": "addr_DAtUWoxgu91obl",
"type": "billing_address",
"primary": true,
"line1": "318 C-Wing, Suyog Co. Housing Society Ltd.",
"line2": "T.P.S Road, Vazira, Borivali",
"zipcode": "400092",
"city": "Mumbai",
"state": "Maharashtra",
"country": "in"
},
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9977886633"
},
"order_id": null,
"line_items": [
{
"id": "li_DAweOizsysoJU6",
"item_id": null,
"name": "Book / English August - Updated name and quantity",
"description": "150 points in Quidditch",
"amount": 400,
"unit_amount": 400,
"gross_amount": 400,
"tax_amount": 0,
"taxable_amount": 400,
"net_amount": 400,
"currency": "INR",
"type": "invoice",
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"unit": null,
"quantity": 1,
"taxes": []
}
],
"payment_id": null,
"status": "draft",
"expire_by": 1567103399,
"issued_at": null,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": null,
"email_status": null,
"date": 1566891149,
"terms": null,
"partial_payment": false,
"gross_amount": 600,
"tax_amount": 0,
"taxable_amount": 600,
"amount": 600,
"amount_paid": null,
"amount_due": null,
"currency": "INR",
"currency_symbol": "₹",
"description": "This is a test invoice.",
"notes": {
"updated-key": "An updated note."
},
"comment": null,
"short_url": null,
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "invoice",
"group_taxes_discounts": false,
"created_at": 1566906474,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
### Issue an invoice
Only an invoice in the `draft` state can be issued.
```php
$api->invoice->fetch($invoiceId)->issue();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be issued |
**Response:**
```json
{
"id": "inv_DAweOiQ7amIUVd",
"entity": "invoice",
"receipt": "#0961",
"invoice_number": "#0961",
"customer_id": "cust_DAtUWmvpktokrT",
"customer_details": {
"id": "cust_DAtUWmvpktokrT",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9977886633",
"gstin": null,
"billing_address": {
"id": "addr_DAtUWoxgu91obl",
"type": "billing_address",
"primary": true,
"line1": "318 C-Wing, Suyog Co. Housing Society Ltd.",
"line2": "T.P.S Road, Vazira, Borivali",
"zipcode": "400092",
"city": "Mumbai",
"state": "Maharashtra",
"country": "in"
},
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9977886633"
},
"order_id": "order_DBG3P8ZgDd1dsG",
"line_items": [
{
"id": "li_DAweOizsysoJU6",
"item_id": null,
"name": "Book / English August - Updated name and quantity",
"description": "150 points in Quidditch",
"amount": 400,
"unit_amount": 400,
"gross_amount": 400,
"tax_amount": 0,
"taxable_amount": 400,
"net_amount": 400,
"currency": "INR",
"type": "invoice",
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"unit": null,
"quantity": 1,
"taxes": []
},
{
"id": "li_DAwjWQUo07lnjF",
"item_id": null,
"name": "Book / A Wild Sheep Chase",
"description": null,
"amount": 200,
"unit_amount": 200,
"gross_amount": 200,
"tax_amount": 0,
"taxable_amount": 200,
"net_amount": 200,
"currency": "INR",
"type": "invoice",
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"unit": null,
"quantity": 1,
"taxes": []
}
],
"payment_id": null,
"status": "issued",
"expire_by": 1567103399,
"issued_at": 1566974805,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": null,
"email_status": null,
"date": 1566891149,
"terms": null,
"partial_payment": false,
"gross_amount": 600,
"tax_amount": 0,
"taxable_amount": 600,
"amount": 600,
"amount_paid": 0,
"amount_due": 600,
"currency": "INR",
"currency_symbol": "₹",
"description": "This is a test invoice.",
"notes": {
"updated-key": "An updated note."
},
"comment": null,
"short_url": "https://rzp.io/i/K8Zg72C",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "invoice",
"group_taxes_discounts": false,
"created_at": 1566906474,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
### Delete an invoice
```php
$api->invoice->fetch($invoiceId)->delete();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be deleted |
**Response:**
```
[]
```
-------------------------------------------------------------------------------------------------------
### Cancel an invoice
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be cancelled |
**Response:**
```json
{
"amount": 1000,
"amount_due": 1000,
"amount_paid": 0,
"billing_end": null,
"billing_start": null,
"cancelled_at": 1654159207,
"comment": null,
"created_at": 1653596202,
"currency": "INR",
"currency_symbol": "₹",
"customer_details": {
"billing_address": null,
"contact": "99991111999",
"customer_contact": "99991111999",
"customer_email": "gauraa.kumar@example.com",
"customer_name": "Gauravss Kumar",
"email": "gauraa.kumar@example.com",
"gstin": null,
"id": "cust_JDdNazagOgg9Ig",
"name": "Gauravss Kumar",
"shipping_address": null
},
"customer_id": "cust_JDdNazagOgg9Ig",
"date": 1589994898,
"description": null,
"email_status": "sent",
"entity": "invoice",
"expire_by": null,
"expired_at": null,
"first_payment_min_amount": null,
"gross_amount": 1000,
"group_taxes_discounts": false,
"id": "inv_JZz7g9hSZS9IsG",
"idempotency_key": null,
"invoice_number": null,
"issued_at": 1653596202,
"line_items": [
{
"amount": 1000,
"currency": "INR",
"description": null,
"gross_amount": 1000,
"hsn_code": null,
"id": "li_JZz7gAI2W3Arg2",
"item_id": "item_J7lZCyxMVeEtYB",
"name": "Test item",
"net_amount": 1000,
"quantity": 1,
"ref_id": null,
"ref_type": null,
"sac_code": null,
"tax_amount": 0,
"tax_inclusive": false,
"tax_rate": null,
"taxable_amount": 1000,
"taxes": [],
"type": "invoice",
"unit": null,
"unit_amount": 1000
}
],
"notes": [],
"order_id": "order_JZz7gBTZjtUgBO",
"paid_at": null,
"partial_payment": false,
"payment_id": null,
"receipt": null,
"reminder_status": null,
"short_url": "https://rzp.io/i/DGpanoT",
"sms_status": "pending",
"status": "cancelled",
"subscription_status": null,
"supply_state_code": null,
"tax_amount": 0,
"taxable_amount": 1000,
"terms": null,
"type": "invoice",
"user_id": null,
"view_less": true
}
```
-------------------------------------------------------------------------------------------------------
### Send notification
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be notified |
| medium* | string | `sms`/`email`, Medium through which notification should be sent. |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/invoices)**

View File

@@ -0,0 +1,197 @@
## items
### Create item
```php
$api->Item->create(array("name" => "Book / English August","description" => "An indian story, Booker prize winner.","amount" => 20000,"currency" => "INR"));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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. |
**Response:**
```json
{
"id": "item_JInaSLODeDUQiQ",
"active": true,
"name": "Book / English August",
"description": "An indian story, Booker prize winner.",
"amount": 20000,
"unit_amount": 20000,
"currency": "INR",
"type": "invoice",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1649843796
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all items
```php
$api->Item->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the item were created |
| 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) |
| active | boolean | Possible values is `0` or `1` |
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "item_JInaSLODeDUQiQ",
"active": true,
"name": "Book / English August",
"description": "An indian story, Booker prize winner.",
"amount": 20000,
"unit_amount": 20000,
"currency": "INR",
"type": "invoice",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1649843796
},
{
"id": "item_JIPSg5L06yhHie",
"active": false,
"name": "Book / Ignited Minds - Updated name!",
"description": "New descirption too. :).",
"amount": 20000,
"unit_amount": 20000,
"currency": "INR",
"type": "invoice",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1649758835
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular item
```php
$api->Item->fetch($itemId);
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| itemId* | string | The id of the item to be fetched |
**Response:**
```json
{
"id": "item_JInaSLODeDUQiQ",
"active": true,
"name": "Book / English August",
"description": "An indian story, Booker prize winner.",
"amount": 20000,
"unit_amount": 20000,
"currency": "INR",
"type": "invoice",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1649843796
}
```
-------------------------------------------------------------------------------------------------------
### Update item
```php
$api->Item->fetch($itemId)->edit(array("name" => "Book / Ignited Minds - Updated name!","description" => "New descirption too. :).","amount" => 20000,"currency" => "INR","active" => true
));
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| itemId* | string | The id of the item to be fetched |
| 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:**
```json
{
"id": "item_JInaSLODeDUQiQ",
"active": true,
"name": "Book / Ignited Minds - Updated name!",
"description": "New descirption too. :).",
"amount": 20000,
"unit_amount": 20000,
"currency": "INR",
"type": "invoice",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1649843796
}
```
-------------------------------------------------------------------------------------------------------
### Delete item
```php
$api->Item->fetch($itemId)->delete();
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| itemId* | string | The id of the item to be fetched |
**Response:**
```json
[]
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/items)**

View File

@@ -0,0 +1,243 @@
## Orders
### Create order
```php
$api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 |
|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:**
```json
{
"id": "order_EKwxwAgItmmXdp",
"entity": "order",
"amount": 50000,
"amount_paid": 0,
"amount_due": 50000,
"currency": "INR",
"receipt": "receipt#1",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1582628071
}
```
-------------------------------------------------------------------------------------------------------
### Create order (Third party validation)
```php
$api->order->create(array('amount' => 500, 'receipt' => 'BILL13375649', 'method' => 'netbanking', 'currency' => 'INR', 'bank_account'=> array('account_number'=> '765432123456789','name'=> 'Gaurav Kumar','ifsc'=>'HDFC0000053')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| amount* | integer | Amount of the order to be paid |
| method | string | The payment method used to make the payment. If this parameter is not passed, customers will be able to make payments using both netbanking and UPI payment methods. Possible values is `netbanking` or `upi`|
| notes | array | A key-value pair |
| currency* | string | Currency of the order. Currently only `INR` is supported. |
| receipt | string | Your system order reference id. |
| notes | array | A key-value pair |
|bank_account | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/#step-2-create-an-order) are supported |
**Response:**
```json
{
"id": "order_GAWN9beXgaqRyO",
"entity": "order",
"amount": 500,
"amount_paid": 0,
"amount_due": 500,
"currency": "INR",
"receipt": "BILL13375649",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1573044247
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all orders
```php
$api->order->all($options);
```
**Parameters**
| Name | Type | Description |
|------------|-----------|--------------------------------------------------------------|
| from | timestamp | timestamp after which the orders were created |
| to | timestamp | timestamp before which the orders were created |
| count | integer | number of orders to fetch (default: 10) |
| skip | integer | number of orders to be skipped (default: 0) |
| authorized | boolean | Orders for which orders are currently in authorized state. |
| receipt | string | Orders with the provided value for receipt. |
| expand[] | string | Used to retrieve additional information about the payment. Possible value is `payments`,`payments.card`,`transfers` or `virtual_account` |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "order_EKzX2WiEWbMxmx",
"entity": "order",
"amount": 1234,
"amount_paid": 0,
"amount_due": 1234,
"currency": "INR",
"receipt": "Receipt No. 1",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1582637108
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular order
```php
$api->order->fetch($orderId);
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| orderId* | string | The id of the order to be fetched |
**Response:**
```json
{
"id": "order_IXnOAMw6SSqKvN",
"entity": "order",
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"receipt": "Receipt no. 1",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1639581113
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payments for an order
```php
$api->order->fetch($orderId)->payments();
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| orderId* | string | The id of the order to be retrieve payment info |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"pay_DaaSOvhgcOfzgR",
"entity":"payment",
"amount":2200,
"currency":"INR",
"status":"captured",
"order_id":"order_DaaS6LOUAASb7Y",
"invoice_id":null,
"international":false,
"method":"card",
"amount_refunded":0,
"refund_status":null,
"captured":true,
"description":"Beans in every imaginable flavour",
"card_id":"card_DZon6fd8J3IcA2",
"bank":null,
"wallet":null,
"vpa":null,
"email":"gaurav.kumar@example.com",
"contact":"+919999999988",
"notes":[],
"fee":44,
"tax":0,
"error_code":null,
"error_description":null,
"created_at":1572505160
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Update order
```php
$api->order->fetch($orderId)->edit(array('notes'=> array('notes_key_1'=>'Beam me up Scotty. 1', 'notes_key_2'=>'Engage')));
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| orderId* | string | The id of the order to be retrieve payment info |
| notes* | array | A key-value pair |
**Response:**
```json
{
"id":"order_DaaS6LOUAASb7Y",
"entity":"order",
"amount":2200,
"amount_paid":0,
"amount_due":2200,
"currency":"INR",
"receipt":"Receipt #211",
"offer_id":null,
"status":"attempted",
"attempts":1,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1572505143
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/orders/)**

View File

@@ -0,0 +1,603 @@
## Paper NACH
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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`|
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create order
```php
$api->order->create(array('amount' => 0,'currency' => 'INR','method' => 'nach','customer_id' => 'cust_1Aa00000000001','receipt' => 'Receipt No. 1', 'notes' => array('notes_key_1' => 'Beam me up Scotty','notes_key_2' => 'Engage'),'token' => array('auth_type' => 'physical','max_amount' => 10000000,'expire_at' => 2709971120,'notes' => array('notes_key_1' => 'Tea, Earl Grey, Hot','notes_key_2' => 'Tea, Earl Grey… decaf.'),'bank_account' => array('account_number' => '11214311215411','ifsc_code' => 'HDFC0000001','beneficiary_name' => 'Gaurav Kumar','account_type' => 'savings'),'nach' => array('form_reference1' => 'Recurring Payment for Gaurav Kumar','form_reference2' => 'Method Paper NACH','description' => 'Paper NACH Gaurav Kumar'))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 `nach`. |
| receipt | string | Your system order reference id. |
| token | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/create-authorization-transaction/#112-create-an-order) are supported |
| notes | object | A key-value pair |
**Response:**
```json
{
"id":"order_1Aa00000000001",
"entity":"order",
"amount":0,
"amount_paid":0,
"amount_due":0,
"currency":"INR",
"receipt":"rcptid #10",
"offer_id":null,
"offers":{
"entity":"collection",
"count":0,
"items":[
]
},
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Beam me up Scotty",
"notes_key_2":"Engage"
},
"created_at":1579775420,
"token":{
"method":"nach",
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"recurring_status":null,
"failure_reason":null,
"currency":"INR",
"max_amount":10000000,
"auth_type":"physical",
"expire_at":1580480689,
"nach":{
"create_form":true,
"form_reference1":"Recurring Payment for Gaurav Kumar",
"form_reference2":"Method Paper NACH",
"prefilled_form":"https://rzp.io/i/bitw",
"upload_form_url":"https://rzp.io/i/gts",
"description":"Paper NACH Gaurav Kumar"
},
"bank_account":{
"ifsc":"HDFC0000001",
"bank_name":"HDFC Bank",
"name":"Gaurav Kumar",
"account_number":"11214311215411",
"account_type":"savings",
"beneficiary_email":"gaurav.kumar@example.com",
"beneficiary_mobile":"9876543210"
},
"first_payment_amount":0
}
}
```
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/paper-nach/authorization-transaction/#113-create-an-authorization-payment) for authorization payment
-------------------------------------------------------------------------------------------------------
### Create registration link
```php
$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' => 1947483647,'max_amount' => 50000),'receipt' => 'Receipt No. 1','sms_notify' => 1,'email_notify' => 1,'expire_by' => 1647483647,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customer | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/create-authorization-transaction/#121-create-a-registration-link) |
| type* | string | In this case, the value is `link`. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| amount* | integer | The payment amount in the smallest currency sub-unit. |
| description* | string | A description that appears on the hosted page. For example, `12:30 p.m. Thali meals (Gaurav Kumar`). |
| subscription_registration | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/create-authorization-transaction/#121-create-a-registration-link) |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| receipt | string | Your system order reference id. |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "inv_FHrZiAubEzDdaq",
"entity": "invoice",
"receipt": "Receipt No. 27",
"invoice_number": "Receipt No. 27",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrZiBOkWHZPOp",
"line_items": [],
"payment_id": null,
"status": "issued",
"expire_by": 1647483647,
"issued_at": 1595491154,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491154,
"terms": null,
"partial_payment": false,
"gross_amount": 0,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 0,
"amount_paid": 0,
"amount_due": 0,
"currency": "INR",
"currency_symbol": "₹",
"description": "12 p.m. Meals",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/bzDYbNg",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491154,
"idempotency_key": null,
"token": {
"method": "nach",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"recurring_status": null,
"failure_reason": null,
"currency": "INR",
"max_amount": 50000,
"auth_type": "physical",
"expire_at": 1947483647,
"nach": {
"create_form": true,
"form_reference1": "Recurring Payment for Gaurav Kumar",
"form_reference2": "Method Paper NACH",
"prefilled_form": "https://rzp.io/i/exdIzYN",
"upload_form_url": "https://rzp.io/i/bzDYbNg",
"description": "12 p.m. Meals"
},
"bank_account": {
"ifsc": "HDFC0001233",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"account_number": "11214311215411",
"account_type": "savings",
"beneficiary_email": "gaurav.kumar@example.com",
"beneficiary_mobile": "9123456780"
},
"first_payment_amount": 0
},
"nach_form_url": "https://rzp.io/i/exdIzYN"
}
```
-------------------------------------------------------------------------------------------------------
### Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be notified |
| medium* | string | `sms`/`email`, Medium through which notification should be sent. |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
### Cancel a registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be cancelled |
**Response:**
```json
{
"id": "inv_FHrZiAubEzDdaq",
"entity": "invoice",
"receipt": "Receipt No. 27",
"invoice_number": "Receipt No. 27",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrZiBOkWHZPOp",
"line_items": [],
"payment_id": null,
"status": "cancelled",
"expire_by": 1647483647,
"issued_at": 1595491154,
"paid_at": null,
"cancelled_at": 1595491339,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491154,
"terms": null,
"partial_payment": false,
"gross_amount": 0,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 0,
"amount_paid": 0,
"amount_due": 0,
"currency": "INR",
"currency_symbol": "₹",
"description": "12 p.m. Meals",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/bzDYbNg",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491154,
"idempotency_key": null,
"token": {
"method": "nach",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"recurring_status": null,
"failure_reason": null,
"currency": "INR",
"max_amount": 50000,
"auth_type": "physical",
"expire_at": 1947483647,
"nach": {
"create_form": true,
"form_reference1": "Recurring Payment for Gaurav Kumar",
"form_reference2": "Method Paper NACH",
"prefilled_form": "https://rzp.io/i/tSYd5aV",
"upload_form_url": "https://rzp.io/i/bzDYbNg",
"description": "12 p.m. Meals"
},
"bank_account": {
"ifsc": "HDFC0001233",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"account_number": "11214311215411",
"account_type": "savings",
"beneficiary_email": "gaurav.kumar@example.com",
"beneficiary_mobile": "9123456780"
},
"first_payment_amount": 0
},
"nach_form_url": "https://rzp.io/i/tSYd5aV"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch Payment ID using Order ID
```php
$api->order->fetch($orderId)->payments();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| orderId* | string | Order id for which payment id need to be fetched |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"pay_1Aa00000000003",
"entity":"payment",
"amount":0,
"currency":"INR",
"status":"captured",
"order_id":"order_1Aa00000000003",
"invoice_id":"inv_1Aa00000000003",
"international":false,
"method":"nach",
"amount_refunded":0,
"refund_status":null,
"captured":true,
"description":"12 p.m. Meals",
"card_id":null,
"bank":"HDFC",
"wallet":null,
"vpa":null,
"email":"gaurav.kumar@example.com",
"contact":"99876543210",
"customer_id":"cust_1Aa00000000002",
"token_id":"token_1Aa00000000003",
"notes":{
"note_key 1":"Beam me up Scotty",
"note_key 2":"Tea. Earl Gray. Hot."
},
"fee":0,
"tax":0,
"error_code":null,
"error_description":null,
"created_at":1580109147
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch token by payment ID
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| paymentId* | string | Id of the payment to be retrieved |
**Response:**
```json
{
"id": "pay_EnLNTjINiPkMEZ",
"entity": "payment",
"amount": 0,
"currency": "INR",
"status": "captured",
"order_id": "order_EnLLfglmKksr4K",
"invoice_id": "inv_EnLLfgCzRfcMuh",
"international": false,
"method": "nach",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Invoice #inv_EnLLfgCzRfcMuh",
"card_id": null,
"bank": "UTIB",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_EnLNTnn7uyRg5V",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {},
"created_at": 1588827564
}
```
-------------------------------------------------------------------------------------------------------
### Fetch tokens by customer ID
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_EhYgIE3pOyMQpD",
"entity": "token",
"token": "3mQ5Czc6APNppI",
"bank": "HDFC",
"wallet": null,
"method": "nach",
"vpa": null,
"recurring": true,
"recurring_details": {
"status": "confirmed",
"failure_reason": null
},
"auth_type": "physical",
"mrn": null,
"used_at": 1587564373,
"created_at": 1587564373,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Delete token
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
### Create an order to charge the customer
```php
$api->order->create(array('amount' => 1000,'currency' => 'INR','payment_capture' => true,'receipt' => 'Receipt No. 1','notes'=> array('notes_key_1' => 'Tea, Earl Grey, Hot', 'notes_key_2' => 'Tea, Earl Grey… decaf.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| amount* | integer | Amount of the order to be paid |
| currency* | string | Currency of the order. Currently only `INR` is supported. |
| 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. |
| receipt | string | Your system order reference id. |
| notes | array | A key-value pair |
**Response:**
```json
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":1000,
"amount_paid":0,
"amount_due":1000,
"currency":"INR",
"receipt":"Receipt No. 1",
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1579782776
}
```
-------------------------------------------------------------------------------------------------------
### Create a Recurring Payment
```php
$api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>'order_1Aa00000000002','customer_id'=>'cust_1Aa00000000001','token'=>'token_1Aa00000000001','recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar'));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address. |
| contact* | string | The customer's phone number. |
| amount* | integer | The amount you want to charge your customer. This should be the same as the amount in the order. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| order_id* | string | The unique identifier of the order created. |
| 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. |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/paper-nach/authorization-transaction/)**

View File

@@ -0,0 +1,705 @@
## Payments
### Capture payment
```php
$api->payment->fetch($paymentId)->capture(array('amount'=>$amount,'currency' => 'INR'));
```
**Parameters:**
| Name | Type | Description |
|-----------|---------|--------------------------------------------------------------------------------|
| paymentId* | string | Id of the payment to capture |
| 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) |
**Response:**
```json
{
"id": "pay_G8VQzjPLoAvm6D",
"entity": "payment",
"amount": 1000,
"currency": "INR",
"status": "captured",
"order_id": "order_G8VPOayFxWEU28",
"invoice_id": null,
"international": false,
"method": "upi",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Purchase Shoes",
"card_id": null,
"bank": null,
"wallet": null,
"vpa": "gaurav.kumar@exampleupi",
"email": "gaurav.kumar@example.com",
"contact": "+919999999999",
"customer_id": "cust_DitrYCFtCIokBO",
"notes": [],
"fee": 24,
"tax": 4,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"rrn": "033814379298"
},
"created_at": 1606985209
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all payments
```php
$api->payment->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
| expand[] | string | Used to retrieve additional information about the payment. Possible value is `cards` or `emi`|
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "pay_G8VaL2Z68LRtDs",
"entity": "payment",
"amount": 900,
"currency": "INR",
"status": "captured",
"order_id": "order_G8VXfKDWDEOHHd",
"invoice_id": null,
"international": false,
"method": "netbanking",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Purchase Shoes",
"card_id": null,
"bank": "KKBK",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919999999999",
"customer_id": "cust_DitrYCFtCIokBO",
"notes": [],
"fee": 22,
"tax": 4,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"bank_transaction_id": "0125836177"
},
"created_at": 1606985740
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a payment
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| paymentId* | string | Id of the payment to be retrieved |
**Response:**
```json
{
"id": "pay_G8VQzjPLoAvm6D",
"entity": "payment",
"amount": 1000,
"currency": "INR",
"status": "captured",
"order_id": "order_G8VPOayFxWEU28",
"invoice_id": null,
"international": false,
"method": "upi",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Purchase Shoes",
"card_id": null,
"bank": null,
"wallet": null,
"vpa": "gaurav.kumar@exampleupi",
"email": "gaurav.kumar@example.com",
"contact": "+919999999999",
"customer_id": "cust_DitrYCFtCIokBO",
"notes": [],
"fee": 24,
"tax": 4,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"rrn": "033814379298"
},
"created_at": 1606985209
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payments for an order
```php
$api->order->fetch($orderId)->payments();
```
**Parameters**
| Name | Type | Description |
|----------|--------|-------------------------------------|
| orderId* | string | The id of the order to be retrieve payment info |
**Response:**
```json
{
"count": 1,
"entity": "collection",
"items": [
{
"id": "pay_DovGQXOkPBJjjU",
"entity": "payment",
"amount": 600,
"currency": "INR",
"status": "captured",
"order_id": "order_DovFx48wjYEr2I",
"method": "netbanking",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "A Wild Sheep Chase is a novel by Japanese author Haruki Murakami",
"card_id": null,
"bank": "SBIN",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "9364591752",
"fee": 70,
"tax": 10,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"notes": [],
"acquirer_data": {
"bank_transaction_id": "0125836177"
},
"created_at": 1400826750
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Update a payment
```php
$api->payment->fetch($paymentId)->edit(array('notes'=> array('key_1'=> 'value1','key_2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| paymentId* | string | Id of the payment to update |
| notes* | array | A key-value pair |
**Response:**
```json
{
"id": "pay_CBYy6tLmJTzn3Q",
"entity": "payment",
"amount": 1000,
"currency": "INR",
"status": "authorized",
"order_id": null,
"invoice_id": null,
"international": false,
"method": "netbanking",
"amount_refunded": 0,
"refund_status": null,
"captured": false,
"description": null,
"card_id": null,
"bank": "UTIB",
"wallet": null,
"vpa": null,
"email": "testme@acme.com",
"customer_id": "cust_JR4BVKjKyJ7enk",
"notes": {
"key1": "value1",
"key2": "value2"
},
"fee": null,
"tax": null,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"bank_transaction_id": "0125836177"
},
"created_at": 1553504328
}
```
-------------------------------------------------------------------------------------------------------
### Fetch expanded card or emi details for payments
Request #1: Card
```php
$api->payment->all(array('expand[]'=>'card'));
```
Request #2: EMI
```php
$api->payment->all(array('expand[]'=>'emi'));
```
**Response:**<br>
For expanded card or emi details for payments response please click [here](https://razorpay.com/docs/api/payments/#fetch-expanded-card-or-emi-details-for-payments)
-------------------------------------------------------------------------------------------------------
### Fetch card details with paymentId
```php
$api->payment->fetch($paymentId)->fetchCardDetails();
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| paymentId* | string | Id of the payment to update |
**Response:**
```json
{
"id": "card_6krZ6bcjoeqyV9",
"entity": "card",
"name": "Gaurav",
"last4": "3335",
"network": "Visa",
"type": "debit",
"issuer": "SBIN",
"international": false,
"emi": null,
"sub_type": "business"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch Payment Downtime Details
```php
$api->payment->fetchPaymentDowntime();
```
**Response:** <br>
For payment downtime response please click [here](https://razorpay.com/docs/api/payments/downtime/#fetch-payment-downtime-details)
-------------------------------------------------------------------------------------------------------
### Fetch Payment Downtime
```php
$api->payment->fetchPaymentDowntimeById($downtimeId);
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| downtimeId* | string | Id to fetch payment downtime |
**Response:** <br>
For payment downtime by id response please click [here](https://razorpay.com/docs/api/payments/downtime/#fetch-payment-downtime-details-by-id)
-------------------------------------------------------------------------------------------------------
### Payment capture settings API
```php
$api->order->create(array('amount' => 50000,'currency' => 'INR','receipt' => 'rcptid_11','payment' => array('capture' => 'automatic','capture_options' => array('automatic_expiry_period' => 12,'manual_expiry_period' => 7200,'refund_speed' => 'optimum'))));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| 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 |
**Response:** <br>
```json
{
"id": "order_DBJOWzybf0sJbb",
"entity": "order",
"amount": 50000,
"amount_paid": 0,
"amount_due": 50000,
"currency": "INR",
"receipt": "rcptid_11",
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1566986570
}
```
-------------------------------------------------------------------------------------------------------
### Create Payment Json
```php
$api->payment->createPaymentJson(array('amount' => 100,'currency' => 'INR','email' => 'gaurav.kumar@example.com','contact' => '9123456789','order_id' => 'order_I6LVPRQ6upW3uh','method' => 'card','card' => array('number' => '4854980604708430','cvv' => '123','expiry_month' => '12','expiry_year' => '21','name' => 'Gaurav Kumar')));
```
**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>
```json
{
"razorpay_payment_id": "pay_FVmAstJWfsD3SO",
"next": [
{
"action": "redirect",
"url": "https://api.razorpay.com/v1/payments/FVmAtLUe9XZSGM/authorize"
},
{
"action": "otp_generate",
"url": "https://api.razorpay.com/v1/payments/pay_FVmAstJWfsD3SO/otp_generate?track_id=FVmAtLUe9XZSGM&key_id=<YOUR_KEY_ID>"
}
]
}
```
-------------------------------------------------------------------------------------------------------
### OTP Generate
```php
$api = new Api("key",""); // Use Only razorpay key
$api->payment->otpGenerate($paymentId);
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| paymentId* | integer | Unique identifier of the payment |
**Response:** <br>
```json
{
"razorpay_payment_id": "pay_FVmAstJWfsD3SO",
"next": [
{
"action": "otp_submit",
"url": "https://api.razorpay.com/v1/payments/pay_FVmAstJWfsD3SO/otp_submit/ac2d415a8be7595de09a24b41661729fd9028fdc?key_id=<YOUR_KEY_ID>"
},
{
"action": "otp_resend",
"url": "https://api.razorpay.com/v1/payments/pay_FVmAstJWfsD3SO/otp_resend/json?key_id=<YOUR_KEY_ID>"
}
],
"metadata": {
"issuer": "HDFC",
"network": "MC",
"last4": "1111",
"iin": "411111"
}
}
```
-------------------------------------------------------------------------------------------------------
### OTP Submit
```php
$api->payment->fetch($paymentId)->otpSubmit(array('otp'=> '12345'));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| paymentId* | integer | Unique identifier of the payment |
| otp* | string | The customer receives the OTP using their preferred notification medium - SMS or email |
**Response:** <br>
Success
```json
{
"razorpay_payment_id": "pay_D5jmY2H6vC7Cy3",
"razorpay_order_id": "order_9A33XWu170gUtm",
"razorpay_signature": "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
Failure
```json
{
"error": {
"code" : "BAD_REQUEST_ERROR",
"description": "payment processing failed because of incorrect otp"
},
"next": ["otp_submit", "otp_resend"]
}
```
-------------------------------------------------------------------------------------------------------
### Create Payment Json (Third party validation)
```php
$api->payment->createPaymentJson(array('amount' => 100,'currency' => 'INR','email' => 'gaurav.kumar@example.com','contact' => '9123456789','order_id' => 'order_I6LVPRQ6upW3uh','method' => 'netbanking', 'bank'=>'HDFC'));
```
**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 `netbanking` |
| bank* | string | The customer's bank code.For example, `HDFC`.|
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/netbanking#step-3-create-a-payment) for params
**Response:** <br>
```json
{
"razorpay_payment_id": "pay_GAWOYqPlvrtPSi",
"next": [
{
"action": "redirect",
"url": "https://api.razorpay.com/v1/payments/pay_GAWOYqPlvrtPSi/authorize"
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Create Payment UPI s2s / VPA token (Third party validation)
```php
$api->payment->createUpi(array("amount" => 200,"currency" => "INR","order_id" => "order_Jhgp4wIVHQrg5H","email" => "gaurav.kumar@example.com","contact" => "9123456789","method" => "upi","customer_id" => "cust_EIW4T2etiweBmG","save" => 1,"ip" => "192.168.0.103","referer" => "http","user_agent" => "Mozilla/5.0","description" => "Test flow","notes" => array("note_key" => "value1"),"upi" => array("flow" => "collect","vpa" => "gauravkumar@exampleupi","expiry_time" => 5)));
```
**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 |
| customer_id* | string | The id of the customer to be fetched |
| contact* | string | Contact number of the customer |
| notes | array | A key-value pair |
| description | string | Descriptive text of the payment. |
| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` |
| callback_url | string | URL where Razorpay will submit the final payment status. |
| ip* | string | The client's browser IP address. For example `117.217.74.98` |
| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` |
| user_agent* | string | Value of `user_agent` header passed by the client's browser. For example, `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36` |
| upi* (for Upi only) | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect#step-14-initiate-a-payment) are supported |
**Response:** <br>
```json
{
"razorpay_payment_id": "pay_EAm09NKReXi2e0"
}
```
-------------------------------------------------------------------------------------------------------
### Create Payment UPI s2s / VPA token (Third party validation)
```php
$api->payment->createUpi(array("amount" => 200,"currency" => "INR","order_id" => "order_Jhgp4wIVHQrg5H","email" => "gaurav.kumar@example.com","contact" => "9123456789","method" => "upi","customer_id" => "cust_EIW4T2etiweBmG","ip" => "192.168.0.103","referer" => "http","user_agent" => "Mozilla/5.0","description" => "Test flow","notes" => array("note_key" => "value1"),"upi" => array("flow" => "intent")));
```
**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 |
| customer_id* | string | The id of the customer to be fetched |
| contact* | string | Contact number of the customer |
| notes | array | A key-value pair |
| description | string | Descriptive text of the payment. |
| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` |
| callback_url | string | URL where Razorpay will submit the final payment status. |
| ip* | string | The client's browser IP address. For example `117.217.74.98` |
| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` |
| user_agent* | string | Value of `user_agent` header passed by the client's browser. For example, `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36` |
| upi* (for Upi only) | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/intent/#step-2-initiate-a-payment) are supported |
**Response:** <br>
```json
{
"razorpay_payment_id": "pay_CMeM6XvOPGFiF",
"link": "upi://pay?pa=success@razorpay&pn=xyz&tr=xxxxxxxxxxx&tn=gourav&am=1&cu=INR&mc=xyzw"
}
```
-------------------------------------------------------------------------------------------------------
### Valid VPA (Third party validation)
```php
$api->payment->validateVpa(array('vpa'=>'gauravkumar@exampleupi'));
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| vpa* | string | The virtual payment address (VPA) you want to validate. For example, `gauravkumar@exampleupi` |
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect#step-13-validate-the-vpa) for params
**Response:** <br>
```json
{
"vpa": "gauravkumar@exampleupi",
"success": true,
"customer_name": "Gaurav Kumar"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payment methods (Third party validation)
```php
$api = new Api("key",""); // // Use Only razorpay key
$api->payment->fetchPaymentMethods();
```
**Response:** <br>
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/methods-api/#fetch-payment-methods) for response
-------------------------------------------------------------------------------------------------------
### OTP Resend
```php
$api->payment->fetch($paymentId)->otpResend();
```
**Parameters:**
| Name | Type | Description |
|-------------|---------|--------------------------------------|
| paymentId* | integer | Unique identifier of the payment |
Doc reference [doc](https://razorpay.com/docs/payments/payment-methods/cards/authentication/native-otp/#otp-resend)
**Response:** <br>
```json
{
"next": [
"otp_submit",
"otp_resend"
],
"razorpay_payment_id": "pay_JWaNvYmrx75sXo"
}
```
-------------------------------------------------------------------------------------------------------
### Token IIN API
```php
$tokenIin = "412345";
$api->iin->fetch($tokenIin);
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| tokenIin* | string | The token IIN. |
**Response:**
```json
{
"iin": "412345",
"entity": "iin",
"network": "Visa",
"type": "credit",
"sub_type": "business",
"issuer_code": "HDFC",
"issuer_name": "HDFC Bank Ltd",
"international": false,
"is_tokenized": true,
"card_iin": "411111",
"emi":{
"available": true
},
"recurring": {
"available": true
},
"authentication_types": [
{
"type":"3ds"
},
{
"type":"otp"
}
]
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/payments/)**

View File

@@ -0,0 +1,679 @@
## Payment Links
### Create payment link
Request #1
Standard Payment Link
```php
$api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true,
'first_min_partial_amount'=>100,'expire_by' => 1691097057, 'reference_id' => 'TS1989', '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'));
```
Request #2
UPI Payment Link
```php
$api->paymentLink->create(array('upi_link'=>true,'amount'=>500, 'currency'=>'INR', 'expire_by' => 1691097057, 'reference_id' => 'TS1989','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')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|upi_link* | boolean | boolean Must be set to true // to creating UPI Payment Link only |
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. // UPI Payment Link is not supported partial payment |
|description | string | A brief description of the Payment Link |
|first_min_partial_amount | integer |Minimum amount, in currency subunits, that must be paid by the customer as the first partial payment. // UPI Payment Link is not supported partial payment |
|reference_id | string | AReference number tagged to a Payment Link. |
|customer | array | name, email, contact |
|expire_by | integer | Timestamp, in Unix, at which the Payment Link will expire. By default, a Payment Link will be valid for six months from the date of creation. |
|notify | object | sms or email (boolean) |
|notes | json object | Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty” |
**Response:**
For create payment link response please click [here](https://razorpay.com/docs/api/payment-links/#create-payment-link)
-------------------------------------------------------------------------------------------------------
### Fetch all payment link
```php
$api->paymentLink->all();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|payment_id | string | Unique identifier of the payment associated with the Payment Link. |
|reference_id | string | The unique reference number entered by you while creating the Payment Link. |
**Response:**
For fetch all payment link response please click [here](https://razorpay.com/docs/api/payment-links/#all-payment-links)
-------------------------------------------------------------------------------------------------------
### Fetch specific payment link
```php
$api->paymentLink->fetch($paymentLinkId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentLinkId* | string | Unique identifier of the Payment Link. |
**Response:**
For fetch specific payment link response please click [here](https://razorpay.com/docs/api/payment-links/#specific-payment-links-by-id)
-------------------------------------------------------------------------------------------------------
### Update payment link
```php
$api->paymentLink->fetch($paymentLinkId)->edit(array("reference_id"=>"TS42", "expire_by"=>"1640270451" , "reminder_enable"=>0, "notes"=>["policy_name"=>"Jeevan Saral 2"]));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentLinkId* | string | The unique identifier of the Payment Link that needs to be updated. |
| accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. |
| reference_id | string | Adds a unique reference number to an existing link. |
| expire_by | integer | Timestamp, in Unix format, when the payment links should expire. |
| notes | string | object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”. |
**Response:**
For updating payment link response please click [here](https://razorpay.com/docs/api/payment-links/#update-payment-link)
-------------------------------------------------------------------------------------------------------
### Cancel a payment link
```php
$api->paymentLink->fetch($paymentLinkId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentLinkId* | string | Unique identifier of the Payment Link. |
**Response:**
For canceling payment link response please click [here](https://razorpay.com/docs/api/payment-links/#cancel-payment-link)
-------------------------------------------------------------------------------------------------------
### Send notification
```php
$api->paymentLink->fetch($paymentLinkId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentLinkId* | string | Unique identifier of the Payment Link that should be resent. |
| medium* | string | `sms`/`email`,Medium through which the Payment Link must be resent. Allowed values are: |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
### Transfer payments received using payment links
```php
$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')))))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|options* | array | Options to configure the transfer in the Payment Link. Parent parameter under which the order child parameter must be passed. |
**Response:**
```json
{
"accept_partial": false,
"amount": 1500,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596526969,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"deleted_at": 0,
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 0,
"id": "plink_FMbhpT6nqDjDei",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#aasasw8",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/ORor1MT",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596526969,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Offers on payment links
```php
$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'=>false , 'options'=>array('order'=>array('offers'=>array('offer_I0PqexIiTmMRnA')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|description | string | A brief description of the Payment Link |
|reference_id | string | AReference number tagged to a Payment Link. |
|customer | array | name, email, contact |
|expire_by | integer | Timestamp, in Unix, at which the Payment Link will expire. By default, a Payment Link will be valid for six months from the date of creation. |
|notify | object | sms or email (boolean) |
|options* | array | Options to associate the offer_id with the Payment Link. Parent parameter under which the order child parameter must be passed. |
**Response:**
```json
{
"accept_partial": false,
"amount": 3400,
"amount_paid": 0,
"cancelled_at": 0,
"created_at": 1600183040,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 0,
"id": "plink_FdLt0WBldRyE5t",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#425",
"reminder_enable": false,
"reminders": [],
"short_url": "https://rzp.io/i/CM5ohDC",
"status": "created",
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Managing reminders for payment links
```php
$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));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|expire_by | integer | Timestamp, in Unix, at which the Payment Link will expire. By default, a Payment Link will be valid for six months from the date of creation. |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
**Response:**
```json
{
"amount": 340000,
"amount_due": 340000,
"amount_paid": 0,
"billing_end": null,
"billing_start": null,
"cancelled_at": null,
"comment": null,
"created_at": 1592579126,
"currency": "INR",
"currency_symbol": "₹",
"customer_details": {
"billing_address": null,
"contact": "9900990099",
"customer_contact": "9900990099",
"customer_email": "gaurav.kumar@example.com",
"customer_name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"gstin": null,
"id": "cust_F4WNtqj1xb0Duv",
"name": "Gaurav Kumar",
"shipping_address": null
},
"customer_id": "cust_F4WNtqj1xb0Duv",
"date": 1592579126,
"description": "Salon at Home Service",
"email_status": null,
"entity": "invoice",
"expire_by": 1608390326,
"expired_at": null,
"first_payment_min_amount": 0,
"gross_amount": 340000,
"group_taxes_discounts": false,
"id": "inv_F4WfpZLk1ct35b",
"invoice_number": null,
"issued_at": 1592579126,
"line_items": [],
"notes": [],
"order_id": "order_F4WfpxUzWmYOTl",
"paid_at": null,
"partial_payment": false,
"payment_id": null,
"receipt": "5757",
"reminder_enable": false,
"short_url": "https://rzp.io/i/vitLptM",
"sms_status": null,
"status": "issued",
"tax_amount": 0,
"taxable_amount": 0,
"terms": null,
"type": "link",
"user_id": "",
"view_less": true
}
```
-------------------------------------------------------------------------------------------------------
### Rename labels in checkout section
```php
$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')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|expire_by | integer | Timestamp, in Unix, at which the Payment Link will expire. By default, a Payment Link will be valid for six months from the date of creation. |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Options to rename the labels for partial payment fields in the checkout form. Parent parameter under which the checkout and partial_payment child parameters must be passed. |
**Response:**
```json
{
"accept_partial": true,
"amount": 1000,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596193199,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"deleted_at": 0,
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 100,
"id": "plink_FL4vbXVKfW7PAz",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#42321",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/F4GC9z1",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596193199,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Change Business name
```php
$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'))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Option to customize the business name. Parent parameter under which the checkout child parameter must be passed.|
**Response:**
```json
{
"accept_partial": true,
"amount": 1000,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596187657,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 100,
"id": "plink_FL3M2gJFs1Jkma",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#2234542",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/at2OOsR",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596187657,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Prefill checkout fields
```php
$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('prefill'=>array('method'=>'card', 'card[name]'=>'Gaurav Kumar', 'card[number]'=>'4111111111111111', 'card[expiry]'=>'12/21', 'card[cvv]'=>'123')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Options to customize Checkout. Parent parameter under which the checkout and prefill child parameters must be passed.|
**Response:**
For prefill checkout fields response please click [here](https://razorpay.com/docs/payment-links/api/new/advanced-options/customize/prefill/)
-------------------------------------------------------------------------------------------------------
### Customize payment methods
```php
$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')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Options to display or hide payment methods on the Checkout section. Parent parameter under which the checkout and method child parameters must be passed.|
**Response:**
```json
{
"accept_partial": true,
"amount": 1000,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596188371,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"deleted_at": 0,
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 100,
"id": "plink_FL3YbdvN2Cj6gh",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#543422",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/wKiXKud",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596188371,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Set checkout fields as read-only
```php
$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('readonly'=>array('email'=>'1','contact'=>'1')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Options to set contact and email as read-only fields on Checkout. Parent parameter under which the checkout and readonly child parameters must be passed.|
**Response:**
```json
{
"accept_partial": true,
"amount": 1000,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596190845,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"deleted_at": 0,
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 100,
"id": "plink_FL4GA1t6FBcaVR",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#19129",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/QVwUglR",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596190845,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Implement thematic changes in payment links checkout section
```php
$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('theme'=>array('hide_topbar'=>'true')))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Options to show or hide the top bar. Parent parameter under which the checkout and theme child parameters must be passed.|
**Response:**
```json
{
"accept_partial": true,
"amount": 1000,
"amount_paid": 0,
"callback_method": "",
"callback_url": "",
"cancelled_at": 0,
"created_at": 1596187814,
"currency": "INR",
"customer": {
"contact": "+919999999999",
"email": "gaurav.kumar@example.com",
"name": "Gaurav Kumar"
},
"description": "Payment for policy no #23456",
"expire_by": 0,
"expired_at": 0,
"first_min_partial_amount": 100,
"id": "plink_FL3Oncr7XxXFf6",
"notes": null,
"notify": {
"email": true,
"sms": true
},
"payments": null,
"reference_id": "#423212",
"reminder_enable": true,
"reminders": [],
"short_url": "https://rzp.io/i/j45EmLE",
"source": "",
"source_id": "",
"status": "created",
"updated_at": 1596187814,
"user_id": ""
}
```
-------------------------------------------------------------------------------------------------------
### Rename labels in payment details section
```php
$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.', '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)))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
|amount* | integer | Amount to be paid using the Payment Link. |
|currency | string | A three-letter ISO code for the currency in which you want to accept the payment. For example, INR. |
|accept_partial | boolean | Indicates whether customers can make partial payments using the Payment Link. Possible values:true - Customer can make partial payments.false (default) - Customer cannot make partial payments. |
|first_min_partial_amount | integer | |
|description | string | A brief description of the Payment Link |
|customer | array | name, email, contact |
|notify | object | sms or email (boolean) |
|reminder_enable | boolean | To disable reminders for a Payment Link, pass reminder_enable as false |
|options* | array | Parent parameter under which the hosted_page and label child parameters must be passed.|
**Response:**
For rename labels in payment details section response please click [here](https://razorpay.com/docs/payment-links/api/new/advanced-options/customize/rename-payment-details-labels/)
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/payment-links/)**

View File

@@ -0,0 +1,68 @@
## payment verification
### Verify payment verification
```php
$api->utility->verifyPaymentSignature(array('razorpay_order_id' => $razorpayOrderId, 'razorpay_payment_id' => $razorpayPaymentId, 'razorpay_signature' => $razorpaySignature));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| orderId* | string | The id of the order to be fetched |
| paymentId* | string | The id of the payment to be fetched |
| signature* | string | Signature returned by the Checkout. This is used to verify the payment. |
-------------------------------------------------------------------------------------------------------
### Verify subscription verification
```php
$api->utility->verifyPaymentSignature(array('razorpay_subscription_id' => $razorpaySubscriptionId, 'razorpay_payment_id' => $razorpayPaymentId, 'razorpay_signature' => $razorpaySignature));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be fetched |
| paymentId* | string | The id of the payment to be fetched |
| signature* | string | Signature returned by the Checkout. This is used to verify the payment. |
-------------------------------------------------------------------------------------------------------
### Verify paymentlink verification
```php
$api->utility->verifyPaymentSignature(array('razorpay_payment_link_id' => $razorpayPaymentlinkId, 'razorpay_payment_id' => $razorpayPaymentId, 'razorpay_payment_link_reference_id' => $razorpayPaymentLinkReferenceId, 'razorpay_payment_link_status' => $razorpayPaymentLinkStatus, 'razorpay_signature' => $razorpayPaymentLinkSignature));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| razorpayPaymentlinkId* | string | The id of the paymentlink to be fetched |
| razorpayPaymentId* | string | The id of the payment to be fetched |
| razorpayPaymentLinkReferenceId* | string | A reference number tagged to a Payment Link |
| razorpayPaymentLinkStatus* | string | Current status of the link |
| razorpayPaymentLinkSignature* | string | Signature returned by the Checkout. This is used to verify the payment. |
-------------------------------------------------------------------------------------------------------
### Verify webhook signature
```php
$webhookBody = '{"entity":"event","account_id":"acc_Hn1ukn2d32Fqww","event":"payment.authorized","contains":["payment"],"payload":{"payment":{"entity":{"id":"pay_JTVtDcN1uRYb5n","entity":"payment","amount":22345,"currency":"INR","status":"authorized","order_id":"order_JTVsulofMPyzBY","invoice_id":null,"international":false,"method":"card","amount_refunded":0,"refund_status":null,"captured":false,"description":"#JT8o1jsTyzrywc","card_id":"card_JTVtDjPwZbFbTM","card":{"id":"card_JTVtDjPwZbFbTM","entity":"card","name":"gaurav","last4":"4366","network":"Visa","type":"credit","issuer":"UTIB","international":false,"emi":true,"sub_type":"consumer","token_iin":null},"bank":null,"wallet":null,"vpa":null,"email":"you@example.com","contact":"+917000569565","notes":{"policy_name":"Jeevan Saral"},"fee":null,"tax":null,"error_code":null,"error_description":null,"error_source":null,"error_step":null,"error_reason":null,"acquirer_data":{"auth_code":"472379"},"created_at":1652183214}}},"created_at":1652183218}';
$webhookSignature = "27209ba357bf7b7b461a4c1d7f54d5a8bb6b0b4b2f5fa4aebf1f1c861a05d18a";
$webhookSecret = "test";
$api->utility->verifyWebhookSignature($webhookBody, $webhookSignature, $webhookSecret);
```
**PN: * indicates mandatory fields**
<br>
<br>

View File

@@ -0,0 +1,159 @@
## Plans
### Create plan
```php
$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')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| period* | string | Used together with `interval` to define how often the customer should be charged.Possible values:<br>1.`daily` <br>2.`weekly`<br>3.`monthly` <br>4.`yearly` |
| interval* | string | Used together with `period` to define how often the customer should be charged |
| items* | array | Details of the plan. For more details please refer [here](https://razorpay.com/docs/api/subscriptions/#create-a-plan) |
| notes | array | Notes you can enter for the contact for future reference. |
**Response:**
```json
{
"id":"plan_00000000000001",
"entity":"plan",
"interval":1,
"period":"weekly",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Test plan - Weekly",
"description":"Description for the test plan - Weekly",
"amount":69900,
"unit_amount":69900,
"currency":"INR",
"type":"plan",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1580219935,
"updated_at":1580219935
},
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1580219935
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all plans
```php
$api->plan->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "plan_00000000000001",
"entity": "plan",
"interval": 1,
"period": "weekly",
"item": {
"id": "item_00000000000001",
"active": true,
"name": "Test plan - Weekly",
"description": "Description for the test plan - Weekly",
"amount": 69900,
"unit_amount": 69900,
"currency": "INR",
"type": "plan",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1580220492,
"updated_at": 1580220492
},
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1580220492
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular plan
```php
$api->plan->fetch($planId);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| planId* | string | The id of the plan to be fetched |
**Response:**
```json
{
"id":"plan_00000000000001",
"entity":"plan",
"interval":1,
"period":"weekly",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Test plan - Weekly",
"description":"Description for the test plan - Weekly",
"amount":69900,
"unit_amount":69900,
"currency":"INR",
"type":"plan",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1580220492,
"updated_at":1580220492
},
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1580220492
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/subscriptions/#plans)**

View File

@@ -0,0 +1,604 @@
## Product Configuration
### Request a Product Configuration
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch($accountId)->products()->requestProductConfiguration(array(
"product_name" => "payment_gateway",
"tnc_accepted" => true,
"ip" => "233.233.233.234"
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| product_name* | string | The product(s) to be configured. Possible value is `payment_gateway`, `payment_links` |
| tnc_accepted | boolean | Pass this parameter to accept terms and conditions. Send this parameter along with the ip parameter when the tnc is accepted. Possible values is `true` |
| ip | integer | The IP address of the merchant while accepting the terms and conditions. Send this parameter along with the `tnc_accepted` parameter when the `tnc` is accepted. |
**Response:**
```json
{
"requested_configuration": {
"payment_methods": []
},
"active_configuration": {
"payment_capture": {
"mode": "automatic",
"refund_speed": "normal",
"automatic_expiry_period": 7200
},
"settlements": {
"account_number": null,
"ifsc_code": null,
"beneficiary_name": null
},
"checkout": {
"theme_color": "#FFFFFF",
"flash_checkout": true,
"logo": "https://example.com/your_logo"
},
"refund": {
"default_refund_speed": "normal"
},
"notifications": {
"whatsapp": true,
"sms": false,
"email": [
"b963e252-1201-45b0-9c39-c53eceb0cfd6_load@gmail.com"
]
},
"payment_methods": {
"netbanking": {
"enabled": true,
"instrument": [
{
"type": "retail",
"bank": [
"hdfc",
"sbin",
"utib",
"icic",
"scbl",
"yesb"
]
}
]
},
"wallet": {
"enabled": true,
"instrument": [
"airtelmoney",
"freecharge",
"jiomoney",
"olamoney",
"payzapp",
"mobikwik"
]
},
"upi": {
"enabled": true,
"instrument": [
"upi"
]
}
}
},
"requirements": [
{
"field_reference": "individual_proof_of_address",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "individual_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "business_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "settlements.beneficiary_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.account_number",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.ifsc_code",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "contact_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "customer_facing_business_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "kyc.pan",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
}
],
"tnc":{
"id": "tnc_IgohZaDBHRGjPv",
"accepted": true,
"accepted_at": 1641550798
},
"id": "acc_prd_HEgNpywUFctQ9e",
"account_id": "acc_HQVlm3bnPmccC0",
"product_name": "payment_gateway",
"activation_status": "needs_clarification",
"requested_at": 162547884
}
```
-------------------------------------------------------------------------------------------------------
### Edit a Product Configuration
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$productId = "acc_prd_HEgNpywUFctQ9e";
$api->account->fetch($accountId)->products()->edit($productId, array(
"notifications" => array(
"email" => array(
"gaurav.kumar@example.com",
"acd@gmail.com"
)
),
"checkout" => array(
"theme_color" => "#528FFF"
),
"refund" => array(
"default_refund_speed" => "optimum"
),
"settlements" => array(
"account_number" => "1234567890",
"ifsc_code" => "HDFC0000317",
"beneficiary_name" => "Gaurav Kumar"
),
"tnc_accepted" => true,
"ip" => "233.233.233.234"
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| notifications | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| checkout | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| refund | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| settlements | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| tnc_accepted | boolean | Pass this parameter to accept terms and conditions. Send this parameter along with the ip parameter when the tnc is accepted. Possible value is `true` |
| ip | string | The IP address of the merchant while accepting the terms and conditions. Send this parameter along with the tnc_accepted parameter when the `tnc` is accepted. |
| payment_methods | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| type | string | Possible value is `domestic` |
| issuer | string | The card issuer. Possible values for issuer are `amex`, `dicl`, `maestro`, `mastercard`, `rupay`, `visa`. |
| wallet | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| instrument(wallet) | string | The wallet issuer. Possible values are `airtelmoney`, `amazonpay`, `freecharge`, `jiomoney`, `mobiwik`, `mpesa`, `olamoney`, `paytm`, `payzapp`, `payumoney`, `phonepe`, `phonepeswitch`, `sbibuddy` |
| instrument(wallet) | string | The wallet issuer. Possible values are `airtelmoney`, `amazonpay`, `freecharge`, `jiomoney`, `mobiwik`, `mpesa`, `olamoney`, `paytm`, `payzapp`, `payumoney`, `phonepe`, `phonepeswitch`, `sbibuddy` |
| upi | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| instrument(upi) | string | The UPI service provider. Possible values are `google_pay`, `upi`|
| paylater | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
| instrument(emi) | string | The Paylater service provider. Possible values are `epaylater`, `getsimpl`|
| emi | object | All keys listed [here](https://razorpay.com/docs/api/partners/product-configuration/#update-a-product-configuration) are supported |
**Response:**
```json
{
"id": "acc_GP4lfNA0iIMn5B",
"type": "standard",
"status": "created",
"email": "gauri@example.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road-1",
"city": "Bengalore",
"state": "KARNATAKA",
"postal_code": "560034",
"country": "IN"
}
}
},
"notes": [],
"created_at": 1610603081,
"phone": "9000090000",
"reference_id": "randomId",
"business_type": "partnership",
"legal_business_name": "Acme Corp",
"customer_facing_business_name": "ABCD Ltd"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a product configuration
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$productId = "acc_prd_HEgNpywUFctQ9e";
$api->account->fetch($accountId)->products()->fetch($productId);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| productId* | string | The unique identifier of a product generated by Razorpay. |
**Response:**
```json
{
"requested_configuration": {
"payment_methods": []
},
"active_configuration": {
"payment_capture": {
"mode": "automatic",
"refund_speed": "normal",
"automatic_expiry_period": 7200
},
"settlements": {
"account_number": null,
"ifsc_code": null,
"beneficiary_name": null
},
"checkout": {
"theme_color": "#FFFFFF",
"flash_checkout": true
},
"refund": {
"default_refund_speed": "normal"
},
"notifications": {
"whatsapp": true,
"sms": false,
"email": [
"b963e252-1201-45b0-9c39-c53eceb0cfd6_load@gmail.com"
]
},
"payment_methods": {
"netbanking": {
"enabled": true,
"instrument": [
{
"type": "retail",
"bank": [
"hdfc",
"sbin",
"utib",
"icic",
"scbl",
"yesb"
]
}
]
},
"wallet": {
"enabled": true,
"instrument": [
"airtelmoney",
"freecharge",
"jiomoney",
"olamoney",
"payzapp",
"mobikwik"
]
},
"upi": {
"enabled": true,
"instrument": [
"upi"
]
}
}
},
"requirements": [
{
"field_reference": "individual_proof_of_address",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "individual_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "business_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "settlements.beneficiary_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.account_number",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.ifsc_code",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "contact_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "customer_facing_business_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "kyc.pan",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
}
],
"tnc":{
"id": "tnc_IgohZaDBHRGjPv",
"accepted": true,
"accepted_at": 1641550798
},
"id": "acc_prd_HEgNpywUFctQ9e",
"account_id": "acc_HQVlm3bnPmccC0",
"product_name": "payment_gateway",
"activation_status": "needs_clarification",
"requested_at": 1625478849
}
```
-------------------------------------------------------------------------------------------------------
### Fetch Terms and Conditions for a Sub-Merchant
```php
$productName = "payments";
$api->product->fetchTnc($productName);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| productName* | string | The product family for which the relevant product to be requested for the sub-merchant. Possible value is `payments` |
**Response:**
```json
{
"entity": "tnc_map",
"product_name": "payments",
"id": "tnc_map_HjOVhIdpVDZ0FB",
"tnc": {
"terms": "https://razorpay.com/terms",
"privacy": "https://razorpay.com/privacy",
"agreement": "https://razorpay.com/agreement"
},
"last_published_at": 1640589653
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a product configuration
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$productId = "acc_prd_HEgNpywUFctQ9e";
$api->account->fetch($accountId)->products()->fetch($productId);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| productId* | string | The unique identifier of a product generated by Razorpay. |
**Response:**
```json
{
"requested_configuration": {
"payment_methods": []
},
"active_configuration": {
"payment_capture": {
"mode": "automatic",
"refund_speed": "normal",
"automatic_expiry_period": 7200
},
"settlements": {
"account_number": null,
"ifsc_code": null,
"beneficiary_name": null
},
"checkout": {
"theme_color": "#FFFFFF",
"flash_checkout": true
},
"refund": {
"default_refund_speed": "normal"
},
"notifications": {
"whatsapp": true,
"sms": false,
"email": [
"b963e252-1201-45b0-9c39-c53eceb0cfd6_load@gmail.com"
]
},
"payment_methods": {
"netbanking": {
"enabled": true,
"instrument": [
{
"type": "retail",
"bank": [
"hdfc",
"sbin",
"utib",
"icic",
"scbl",
"yesb"
]
}
]
},
"wallet": {
"enabled": true,
"instrument": [
"airtelmoney",
"freecharge",
"jiomoney",
"olamoney",
"payzapp",
"mobikwik"
]
},
"upi": {
"enabled": true,
"instrument": [
"upi"
]
}
}
},
"requirements": [
{
"field_reference": "individual_proof_of_address",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "individual_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders/{stakeholderId}/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "business_proof_of_identification",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/documents",
"status": "required",
"reason_code": "document_missing"
},
{
"field_reference": "settlements.beneficiary_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.account_number",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "settlements.ifsc_code",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/products/acc_prd_HEgNpywUFctQ9e",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "contact_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "customer_facing_business_name",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0",
"status": "required",
"reason_code": "field_missing"
},
{
"field_reference": "kyc.pan",
"resolution_url": "/accounts/acc_HQVlm3bnPmccC0/stakeholders",
"status": "required",
"reason_code": "field_missing"
}
],
"tnc":{
"id": "tnc_IgohZaDBHRGjPv",
"accepted": true,
"accepted_at": 1641550798
},
"id": "acc_prd_HEgNpywUFctQ9e",
"account_id": "acc_HQVlm3bnPmccC0",
"product_name": "payment_gateway",
"activation_status": "needs_clarification",
"requested_at": 1625478849
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/partners/product-configuration/)**

View File

@@ -0,0 +1,418 @@
## Qr Codes
### Create Qr code
```php
$api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => "cust_HKsR5se84c5LTO","description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes")));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| type* | string | The type of QR code i.e, `upi_qr`/`bharat_qr` |
| name | string | Label entered to identify the QR code. |
| usage* | string | Indicates if the QR code should be allowed to accept single payment or multiple payments i.e, `single_use`/`multiple_use` |
| fixed_amount | boolean | Indicates if the QR should accept payments of specific amounts or any amount. |
| payment_amount(* mandatory if fixed_amount is true) | integer | Indicates if the QR should accept payments of specific amounts or any amount. |
| customer_id | string | Unique identifier of the customer the QR code is linked with |
| description | string | A brief description about the QR code. |
| close_by | integer | UNIX timestamp at which the QR code is scheduled to be automatically closed. The time must be at least 15 minutes after the current time. |
| notes | array | Key-value pair that can be used to store additional information about the QR code. Maximum 15 key-value pairs, 256 characters (maximum) each. |
**Response:**
```json
{
"id": "qr_HMsVL8HOpbMcjU",
"entity": "qr_code",
"created_at": 1623660301,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/BWcUVrLp",
"payment_amount": 300,
"status": "active",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838,
"closed_at": 1623660445,
"close_reason": "on_demand"
}
```
-------------------------------------------------------------------------------------------------------
### Create Qr code with GST
```php
$api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => "cust_HKsR5se84c5LTO","description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"),"tax_invoice" => array("number" => "INV001", "date" => 1589994898,"customer_name" => "Gaurav Kumar", "business_gstin"=> "06AABCU9605R1ZR","gst_amount" => 4000, "cess_amount" => 0, "supply_type" => "interstate")));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| type* | string | The type of QR code i.e, `upi_qr`/`bharat_qr` |
| name | string | Label entered to identify the QR code. |
| usage* | string | Indicates if the QR code should be allowed to accept single payment or multiple payments i.e, `single_use`/`multiple_use` |
| fixed_amount | boolean | Indicates if the QR should accept payments of specific amounts or any amount. |
| payment_amount(* mandatory if fixed_amount is true) | integer | Indicates if the QR should accept payments of specific amounts or any amount. |
| customer_id | string | Unique identifier of the customer the QR code is linked with |
| description | string | A brief description about the QR code. |
| close_by | integer | UNIX timestamp at which the QR code is scheduled to be automatically closed. The time must be at least 15 minutes after the current time. |
| notes | array | Key-value pair that can be used to store additional information about the QR code. Maximum 15 key-value pairs, 256 characters (maximum) each. |
| tax_invoice | array | This block contains information about the invoices. If not provided, the transaction will default to non-GST compliant UPI flow. |
**Response:**
```json
{
"id": "qr_HMsVL8HOpbMcjU",
"entity": "qr_code",
"created_at": 1623660301,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/BWcUVrLp",
"payment_amount": 300,
"status": "active",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838,
"tax_invoice": {
"number": "INV001",
"date": 1589994898,
"customer_name": "Gaurav Kumar",
"business_gstin": "06AABCU9605R1ZR",
"gst_amount": 4000,
"cess_amount": 0,
"supply_type": "interstate"
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all Qr code
```php
$api->qrCode->all($options);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "qr_HO2jGkWReVBMNu",
"entity": "qr_code",
"created_at": 1623914648,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/w2CEwYmkAu",
"payment_amount": 300,
"status": "active",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838,
"closed_at": null,
"close_reason": null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a Qr code
```php
$api->qrCode->fetch($qrCodeId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| qrCodeId | string | The id of the qr code to be fetched |
**Response:**
```json
{
"id": "qr_HO2r1MDprYtWRT",
"entity": "qr_code",
"created_at": 1623915088,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/oCswTOcCo",
"payment_amount": 300,
"status": "active",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838,
"closed_at": null,
"close_reason": null
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a Qr code for customer id
```php
$api->qrCode->all(["customer_id" => $customerId]);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to which qr code need to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "qr_HMsgvioW64f0vh",
"entity": "qr_code",
"created_at": 1623660959,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/DTa2eQR",
"payment_amount": 300,
"status": "active",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a Qr code for payment id
```php
$api->qrCode->all(["payment_id" => $paymentId]);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentID* | string | The id of the payment to which qr code need to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "qr_HMsqRoeVwKbwAF",
"entity": "qr_code",
"created_at": 1623661499,
"name": "Fresh Groceries",
"usage": "multiple_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/eI9XD54Q",
"payment_amount": null,
"status": "active",
"description": "Buy fresh groceries",
"fixed_amount": false,
"payments_amount_received": 1000,
"payments_count_received": 1,
"notes": [],
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1624472999,
"close_reason": null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch Payments for a QR Code
```php
$api->qrCode->fetch($qrCodeId)->fetchAllPayments($options);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| qrCodeID* | string | The id of the qr code to which payment where made |
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "pay_HMtDKn3TnF4D8x",
"entity": "payment",
"amount": 500,
"currency": "INR",
"status": "captured",
"order_id": null,
"invoice_id": null,
"international": false,
"method": "upi",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "QRv2 Payment",
"card_id": null,
"bank": null,
"wallet": null,
"vpa": "gauri.kumari@okhdfcbank",
"email": "gauri.kumari@example.com",
"contact": "+919999999999",
"customer_id": "cust_HKsR5se84c5LTO",
"notes": [],
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"rrn": "116514257019"
},
"created_at": 1623662800
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Close a QR Code
```php
$api->qrCode->fetch($qrCodeId)->close()
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| qrCodeID* | string | The id of the qr code to be closed |
**Response:**
```json
{
"id": "qr_HMsVL8HOpbMcjU",
"entity": "qr_code",
"created_at": 1623660301,
"name": "Store_1",
"usage": "single_use",
"type": "upi_qr",
"image_url": "https://rzp.io/i/BWcUVrLp",
"payment_amount": 300,
"status": "closed",
"description": "For Store 1",
"fixed_amount": true,
"payments_amount_received": 0,
"payments_count_received": 0,
"notes": {
"purpose": "Test UPI QR code notes"
},
"customer_id": "cust_HKsR5se84c5LTO",
"close_by": 1681615838,
"closed_at": 1623660445,
"close_reason": "on_demand"
}
```
-------------------------------------------------------------------------------------------------------
### Refund a Payment
```php
$api->payment->fetch($paymentId)->refund(array("amount"=> "100","notes"=>array("notes_key_1"=>"Beam me up Scotty.", "notes_key_2"=>"Engage")));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentId* | string | The id of the payment to be refunded |
| amount | string | Amount to be refunded |
| notes | array | Key-value pair that can be used to store additional information about the QR code. Maximum 15 key-value pairs, 256 characters (maximum) each. |
**Response:**
```json
{
"id": "rfnd_FP8QHiV938haTz",
"entity": "refund",
"amount": 500100,
"receipt": "Receipt No. 31",
"currency": "INR",
"payment_id": "pay_29QQoUBi66xm2f",
"notes": [],
"receipt": null,
"acquirer_data": {
"arn": null
},
"created_at": 1597078866,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "normal"
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/qr-codes/)**

View File

@@ -0,0 +1,278 @@
## Refunds
### Create a normal refund
```php
$api->payment->fetch($paymentId)->refund(array("amount"=> "100", "speed"=>"normal", "notes"=>array("notes_key_1"=>"Beam me up Scotty.", "notes_key_2"=>"Engage"), "receipt"=>"Receipt No. 31"));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment |
| amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) | |
| speed | string | Here, it must be normal |
| notes | array | A key-value pair |
| receipt | string | A unique identifier provided by you for your internal reference. |
**Response:**
```json
{
"id": "rfnd_FP8QHiV938haTz",
"entity": "refund",
"amount": 500100,
"receipt": "Receipt No. 31",
"currency": "INR",
"payment_id": "pay_FCXKPFtYfPXJPy",
"notes": [],
"acquirer_data": {
"arn": null
},
"created_at": 1597078866,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "normal"
}
```
-------------------------------------------------------------------------------------------------------
### Create an instant refund
```php
$api->payment->fetch($paymentId)->refund(array("amount"=> "100","speed"=>"optimum","receipt"=>"Receipt No. 31"));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment |
| amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
| speed* | string | Here, it must be optimum |
| receipt | string | A unique identifier provided by you for your internal reference. |
**Response:**
```json
{
"id": "rfnd_FP8R8EGjGbPkVb",
"entity": "refund",
"amount": 500100,
"currency": "INR",
"payment_id": "pay_FC8MmhMBZPKDHF",
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"receipt": "Receipt No. 31",
"acquirer_data": {
"arn": null
},
"created_at": 1597078914,
"batch_id": null,
"status": "processed",
"speed_requested": "optimum"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch multiple refunds for a payment
```php
$api->payment->fetch($paymentId)->fetchMultipleRefund($option);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| paymentId* | string | The id of the payment |
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Refund:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "rfnd_FP8DDKxqJif6ca",
"entity": "refund",
"amount": 300100,
"currency": "INR",
"payment_id": "pay_FIKOnlyii5QGNx",
"notes": {
"comment": "Comment for refund"
},
"receipt": null,
"acquirer_data": {
"arn": "10000000000000"
},
"created_at": 1597078124,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "optimum"
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a specific refund for a payment
```php
$api->payment->fetch($paymentId)->fetchRefund($refundId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
| refundId* | string | The id of the refund to be fetched |
**Response:**
```json
{
"id": "rfnd_FP8DDKxqJif6ca",
"entity": "refund",
"amount": 300100,
"currency": "INR",
"payment_id": "pay_FIKOnlyii5QGNx",
"notes": {
"comment": "Comment for refund"
},
"receipt": null,
"acquirer_data": {
"arn": "10000000000000"
},
"created_at": 1597078124,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "optimum"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all refunds
```php
$options = array("count" => 2);
$api->refund->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "rfnd_FFX6AnnIN3puqW",
"entity": "refund",
"amount": 88800,
"currency": "INR",
"payment_id": "pay_FFX5FdEYx8jPwA",
"notes": {
"comment": "Issuing an instant refund"
},
"receipt": null,
"acquirer_data": {},
"created_at": 1594982363,
"batch_id": null,
"status": "processed",
"speed_processed": "optimum",
"speed_requested": "optimum"
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular refund
```php
$api->refund->fetch($refundId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| refundId* | string | The id of the refund to be fetched |
**Response:**
```json
{
"id": "rfnd_EqWThTE7dd7utf",
"entity": "refund",
"amount": 6000,
"currency": "INR",
"payment_id": "pay_EpkFDYRirena0f",
"notes": {
"comment": "Issuing an instant refund"
},
"receipt": null,
"acquirer_data": {
"arn": "10000000000000"
},
"created_at": 1589521675,
"batch_id": null,
"status": "processed",
"speed_processed": "optimum",
"speed_requested": "optimum"
}
```
-------------------------------------------------------------------------------------------------------
### Update the refund
```php
$api->refund->fetch($refundId)->edit(array('notes'=> array('notes_key_1'=>'Beam me up Scotty.', 'notes_key_2'=>'Engage')));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| refundId* | string | The id of the refund to be fetched |
| notes* | array | A key-value pair |
**Response:**
```json
{
"id": "rfnd_FP8DDKxqJif6ca",
"entity": "refund",
"amount": 300100,
"currency": "INR",
"payment_id": "pay_FIKOnlyii5QGNx",
"notes": {
"notes_key_1": "Beam me up Scotty.",
"notes_key_2": "Engage"
},
"receipt": null,
"acquirer_data": {
"arn": "10000000000000"
},
"created_at": 1597078124,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "optimum"
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/refunds/)**

View File

@@ -0,0 +1,341 @@
## Register emandate and charge first payment together
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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`|
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create order
```php
$api->order->create(array('amount' => 0, 'currency' => 'INR', 'method'=>'emandate', 'customer_id'=>$customerId, 'receipt'=>'Receipt No. 5', 'notes'=> array('note_key 1'=> 'Beam me up Scotty','note_key 2'=> 'Engage'), 'token'=>array('first_payment_amount'=>100, 'auth_type'=>'netbanking' ,'max_amount'=>'9999900','expire_at'=>'4102444799', 'notes'=>array('note_key 1'=> 'Tea, Earl Grey… decaf.','note_key 2'=> 'Tea. Earl Gray. Hot.'), 'bank_account'=>array('beneficiary_name'=>'Gaurav Kumar', 'account_number'=>'11214311215411', 'account_type'=>'savings', 'ifsc_code'=>'HDFC0001233'))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 |
| 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 parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/auto-debit/#112-create-an-order) are supported |
| auth_type | string | Possible values is `netbanking`, `debitcard` or `aadhaar` |
| max_amount | integer | The maximum amount, in paise, that a customer can be charged in one transaction. The value can range from `500` - `100000000`. |
| expire_at | integer | The timestamp, in Unix format, till when you can use the token (authorization on the payment method) to charge the customer subsequent payments. |
| notes | object | A key-value pair |
**Response:**
For create order response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order)
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#113-create-an-authorization-payment) for authorization payment
-----------------------------------------------------------------------------------------------------
### Create registration link
```php
$api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9123456780'),'type'=>'link','amount'=>0,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('first_payment_amount'=>100, 'method'=>'emandate', 'auth_type'=>'netbanking' ,'max_amount'=>'50000','expire_at'=>'1634215992','bank_account'=>array('beneficiary_name'=>'Gaurav Kumar', 'account_number'=>'11214311215411', 'account_type'=>'savings', 'ifsc_code'=>'HDFC0001233')),'receipt'=>'Receipt No. 5','email_notify'=>1,'sms_notify'=>1,'expire_by'=>1634215992, 'notes'=> array('note_key 1'=> 'Beam me up Scotty','note_key 2'=> 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|---------------------------------------------------------------|
| 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) |
| description* | string | A brief description of the payment. |
| subscription_registration | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/emandate/auto-debit/#121-create-a-registration-link) are supported |
| receipt | string | Your system order reference id. |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| notes | array | A key-value pair |
**Response:**
For create registration link response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#12-using-a-registration-link)
-------------------------------------------------------------------------------------------------------
## Create an order to charge the customer
```php
$api->order->create(array('amount' => '100', 'currency' => 'INR', 'payment_capture' => true, 'receipt' => 'Receipt No. 1', 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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:**
```json
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":1000,
"amount_paid":0,
"amount_due":1000,
"currency":"INR",
"receipt":"Receipt No. 1",
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1579782776
}
```
-------------------------------------------------------------------------------------------------------
## Create a recurring payment
```php
$api->payment->createRecurring(['email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>1000,'currency'=>'INR','order_id'=>$orderid,'customer_id'=>$customerId,'token'=>$tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address |
| contact* | string | The customer's phone number |
| 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) |
| 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` |
| description | string | A brief description of the payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
## Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type |Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
| medium* | string | Possible values are `sms` or `email` |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
## Cancel registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
**Response:**
```json
{
"id": "inv_FHrfRupD2ouKIt",
"entity": "invoice",
"receipt": "Receipt No. 1",
"invoice_number": "Receipt No. 1",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrfRw4TZU5Q2L",
"line_items": [],
"payment_id": null,
"status": "cancelled",
"expire_by": 4102444799,
"issued_at": 1595491479,
"paid_at": null,
"cancelled_at": 1595491488,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491479,
"terms": null,
"partial_payment": false,
"gross_amount": 100,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"currency_symbol": "₹",
"description": "Registration Link for Gaurav Kumar",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/QlfexTj",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491480,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
## Fetch token by payment id
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
**Response:**
For fetch token by payment id response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#21-fetch-token-by-payment-id)
-------------------------------------------------------------------------------------------------------
## Fetch tokens by customer id
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_FHf94Uym9tdYFJ",
"entity": "token",
"token": "2wDPM7VAlXtjAR",
"bank": "HDFC",
"wallet": null,
"method": "emandate",
"vpa": null,
"recurring": true,
"recurring_details": {
"status": "confirmed",
"failure_reason": null
},
"auth_type": "netbanking",
"mrn": null,
"used_at": 1595447381,
"created_at": 1595447381,
"bank_details": {
"beneficiary_name": "Gaurav Kumar",
"account_number": "1121431121541121",
"ifsc": "HDFC0000001",
"account_type": "savings"
},
"max_amount": 9999900,
"expired_at": 1689971140,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
## Delete tokens
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/)**

View File

@@ -0,0 +1,538 @@
## Register nach and charge first payment together
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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`|
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create Order
```php
$api->order->create(array('amount' => 0, 'currency' => 'INR', 'method'=>'nach', 'customer_id'=>$customerId, 'receipt'=>'Receipt No. 5', 'notes'=> array('note_key 1'=> 'Beam me up Scotty','note_key 2'=> 'Tea. Earl Gray. Hot.'), 'token'=>array('first_payment_amount'=>10000, 'auth_type'=>'physical' ,'max_amount'=>'50000','expire_at'=>'1634215992', 'notes'=>array('note_key 1'=> 'Tea, Earl Grey… decaf.','note_key 2'=> 'Tea. Earl Gray. Hot.'), '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', 'description'=>'Paper NACH Gaurav Kumar'))));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 `nach`. |
| token | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/auto-debit/#112-create-an-order) are supported |
| notes | array | A key-value pair |
**Response:**
```json
{
"id":"order_1Aa00000000001",
"entity":"order",
"amount":0,
"amount_paid":0,
"amount_due":0,
"currency":"INR",
"receipt":"rcptid #10",
"offer_id":null,
"offers":{
"entity":"collection",
"count":0,
"items":[]
},
"status":"created",
"attempts":0,
"notes": {
"notes_key_1": "Beam me up Scotty",
"notes_key_2": "Engage"
},
"created_at":1579775420,
"token":{
"method":"nach",
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"recurring_status":null,
"failure_reason":null,
"currency":"INR",
"max_amount":10000000,
"auth_type":"physical",
"expire_at":1580480689,
"nach":{
"create_form":true,
"form_reference1":"Recurring Payment for Gaurav Kumar",
"form_reference2":"Method Paper NACH",
"prefilled_form":"https://rzp.io/i/bitw",
"upload_form_url":"https://rzp.io/i/gts",
"description":"Paper NACH Gaurav Kumar"
},
"bank_account":{
"ifsc":"HDFC0000001",
"bank_name":"HDFC Bank",
"name":"Gaurav Kumar",
"account_number":"11214311215411",
"account_type":"savings",
"beneficiary_email":"gaurav.kumar@example.com",
"beneficiary_mobile":"9876543210"
},
"first_payment_amount":10000
}
}
```
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/paper-nach/auto-debit/#113-create-an-authorization-payment) for authorization payment
-----------------------------------------------------------------------------------------------------
### Create registration link
```php
$api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9123456780'),'amount'=>0, 'type'=>'link','currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'nach', 'auth_type'=>'physical' ,'max_amount'=>'50000','expire_at'=>'1634215992','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')),'receipt'=>'Receipt No. 5','email_notify'=>1,'sms_notify'=>1,'expire_by'=>1634215992, 'notes'=> array('note_key 1'=> 'Beam me up Scotty','note_key 2'=> 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|---------------------------------------------------------------|
| customer | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/auto-debit/#121-create-a-registration-link) are supported |
| 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) |
| description* | string | A brief description of the payment. |
| subscription_registration | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/paper-nach/auto-debit/#121-create-a-registration-link) are supported |
| receipt | string | Your system order reference id. |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "inv_FHrZiAubEzDdaq",
"entity": "invoice",
"receipt": "Receipt No. 27",
"invoice_number": "Receipt No. 27",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrZiBOkWHZPOp",
"line_items": [],
"payment_id": null,
"status": "issued",
"expire_by": 1647483647,
"issued_at": 1595491154,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491154,
"terms": null,
"partial_payment": false,
"gross_amount": 0,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 0,
"amount_paid": 0,
"amount_due": 0,
"currency": "INR",
"currency_symbol": "₹",
"description": "12 p.m. Meals",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/bzDYbNg",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491154,
"idempotency_key": null,
"token": {
"method": "nach",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"recurring_status": null,
"failure_reason": null,
"currency": "INR",
"max_amount": 50000,
"auth_type": "physical",
"expire_at": 1947483647,
"nach": {
"create_form": true,
"form_reference1": "Recurring Payment for Gaurav Kumar",
"form_reference2": "Method Paper NACH",
"prefilled_form": "https://rzp.io/i/exdIzYN",
"upload_form_url": "https://rzp.io/i/bzDYbNg",
"description": "12 p.m. Meals"
},
"bank_account": {
"ifsc": "HDFC0001233",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"account_number": "11214311215411",
"account_type": "savings",
"beneficiary_email": "gaurav.kumar@example.com",
"beneficiary_mobile": "9123456780"
},
"first_payment_amount": 0
},
"nach_form_url": "https://rzp.io/i/exdIzYN"
}
```
-------------------------------------------------------------------------------------------------------
## Create an order to charge the customer
```php
$api->order->create(array('amount' => '100', 'currency' => 'INR', 'payment_capture' => true, 'receipt' => 'Receipt No. 1', 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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:**
```json
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":1000,
"amount_paid":0,
"amount_due":1000,
"currency":"INR",
"receipt":"Receipt No. 1",
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1579782776
}
```
-------------------------------------------------------------------------------------------------------
## Create a recurring payment
```php
$api->payment->createRecurring(['email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>1000,'currency'=>'INR','order_id'=>$orderid,'customer_id'=>$customerId,'token'=>$tokenId,'recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar', 'notes'=> array('key1'=> 'value3','key2'=> 'value2'));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address |
| contact* | string | The customer's phone number |
| 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) |
| 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` |
| description | string | A brief description of the payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
## Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type |Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
| medium* | string | Possible values are `sms` or `email` |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
## Cancel registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be fetched |
**Response:**
```json
{
"id": "inv_FHrZiAubEzDdaq",
"entity": "invoice",
"receipt": "Receipt No. 27",
"invoice_number": "Receipt No. 27",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHrZiBOkWHZPOp",
"line_items": [],
"payment_id": null,
"status": "cancelled",
"expire_by": 1647483647,
"issued_at": 1595491154,
"paid_at": null,
"cancelled_at": 1595491339,
"expired_at": null,
"sms_status": "sent",
"email_status": "sent",
"date": 1595491154,
"terms": null,
"partial_payment": false,
"gross_amount": 0,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 0,
"amount_paid": 0,
"amount_due": 0,
"currency": "INR",
"currency_symbol": "₹",
"description": "12 p.m. Meals",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/bzDYbNg",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595491154,
"idempotency_key": null,
"token": {
"method": "nach",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"recurring_status": null,
"failure_reason": null,
"currency": "INR",
"max_amount": 50000,
"auth_type": "physical",
"expire_at": 1947483647,
"nach": {
"create_form": true,
"form_reference1": "Recurring Payment for Gaurav Kumar",
"form_reference2": "Method Paper NACH",
"prefilled_form": "https://rzp.io/i/tSYd5aV",
"upload_form_url": "https://rzp.io/i/bzDYbNg",
"description": "12 p.m. Meals"
},
"bank_account": {
"ifsc": "HDFC0001233",
"bank_name": "HDFC Bank",
"name": "Gaurav Kumar",
"account_number": "11214311215411",
"account_type": "savings",
"beneficiary_email": "gaurav.kumar@example.com",
"beneficiary_mobile": "9123456780"
},
"first_payment_amount": 0
},
"nach_form_url": "https://rzp.io/i/tSYd5aV"
}
```
-------------------------------------------------------------------------------------------------------
## Fetch token by payment id
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
**Response:**
```json
{
"id": "pay_EnLNTjINiPkMEZ",
"entity": "payment",
"amount": 0,
"currency": "INR",
"status": "captured",
"order_id": "order_EnLLfglmKksr4K",
"invoice_id": "inv_EnLLfgCzRfcMuh",
"international": false,
"method": "nach",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Invoice #inv_EnLLfgCzRfcMuh",
"card_id": null,
"bank": "UTIB",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_EnLNTnn7uyRg5V",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {},
"created_at": 1588827564
}
```
-------------------------------------------------------------------------------------------------------
## Fetch tokens by customer id
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_EhYgIE3pOyMQpD",
"entity": "token",
"token": "3mQ5Czc6APNppI",
"bank": "HDFC",
"wallet": null,
"method": "nach",
"vpa": null,
"recurring": true,
"recurring_details": {
"status": "confirmed",
"failure_reason": null
},
"auth_type": "physical",
"mrn": null,
"used_at": 1587564373,
"created_at": 1587564373,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
## Delete tokens
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/paper-nach/auto-debit/)**

View File

@@ -0,0 +1,448 @@
## Settlements
### Fetch all settlements
```php
$api->settlement->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the settlement were created |
| to | timestamp | timestamp before which the settlement were created |
| count | integer | number of settlements to fetch (default: 10) |
| skip | integer | number of settlements to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "setl_DGlQ1Rj8os78Ec",
"entity": "settlement",
"amount": 9973635,
"status": "processed",
"fees": 471699,
"tax": 42070,
"utr": "1568176960vxp0rj",
"created_at": 1568176960
},
{
"id": "setl_4xbSwsPABDJ8oK",
"entity": "settlement",
"amount": 50000,
"status": "processed",
"fees": 123,
"tax": 12,
"utr": "RZRP173069230702",
"created_at": 1509622306
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a settlement
```php
$api->settlement->fetch($settlementId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| $settlementId* | string | The id of the settlement to be fetched |
**Response:**
```json
{
"id": "setl_DGlQ1Rj8os78Ec",
"entity": "settlement",
"amount": 9973635,
"status": "processed",
"fees": 471699,
"tax": 42070,
"utr": "1568176960vxp0rj",
"created_at": 1568176960
}
```
-------------------------------------------------------------------------------------------------------
### Settlement report for a month
```php
$api->settlement->reports(array("year"=>2020,"month"=>09));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| year* | integer | The year the settlement was received in the `YYYY` format. For example, `2020` |
| month* | integer | The month the settlement was received in the `MM` format. For example, `09` |
| day | integer | The date the settlement was received in the `DD` format. For example, `01` |
| count | integer | number of settlements to fetch (default: 10) |
| skip | integer | number of settlements to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 4,
"items": [
{
"entity_id": "pay_DEXrnipqTmWVGE",
"type": "payment",
"debit": 0,
"credit": 97100,
"amount": 100000,
"currency": "INR",
"fee": 2900,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1567692556,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": "Recurring Payment via Subscription",
"notes": "{}",
"payment_id": null,
"settlement_utr": "1568176960vxp0rj",
"order_id": "order_DEXrnRiR3SNDHA",
"order_receipt": null,
"method": "card",
"card_network": "MasterCard",
"card_issuer": "KARB",
"card_type": "credit",
"dispute_id": null
},
{
"entity_id": "rfnd_DGRcGzZSLyEdg1",
"type": "refund",
"debit": 242500,
"credit": 0,
"amount": 242500,
"currency": "INR",
"fee": 0,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1568107224,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": null,
"notes": "{}",
"payment_id": "pay_DEXq1pACSqFxtS",
"settlement_utr": "1568176960vxp0rj",
"order_id": "order_DEXpmZgffXNvuI",
"order_receipt": null,
"method": "card",
"card_network": "MasterCard",
"card_issuer": "KARB",
"card_type": "credit",
"dispute_id": null
},
{
"entity_id": "trf_DEUoCEtdsJgvl7",
"type": "transfer",
"debit": 100296,
"credit": 0,
"amount": 100000,
"currency": "INR",
"fee": 296,
"tax": 46,
"on_hold": false,
"settled": true,
"created_at": 1567681786,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": null,
"notes": null,
"payment_id": "pay_DEApNNTR6xmqJy",
"settlement_utr": "1568176960vxp0rj",
"order_id": null,
"order_receipt": null,
"method": null,
"card_network": null,
"card_issuer": null,
"card_type": null,
"dispute_id": null
},
{
"entity_id": "adj_EhcHONhX4ChgNC",
"type": "adjustment",
"debit": 0,
"credit": 1012,
"amount": 1012,
"currency": "INR",
"fee": 0,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1567681786,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"description": "test reason",
"notes": null,
"payment_id": null,
"settlement_utr": null,
"order_id": null,
"order_receipt": null,
"method": null,
"card_network": null,
"card_issuer": null,
"card_type": null,
"dispute_id": null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Settlement recon
```php
$api->settlement->settlementRecon(array('year' => 2018, 'month' => 2, 'day'=>11));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| year* | integer | The year the settlement was received in the `YYYY` format. For example, `2020` |
| month* | integer | The month the settlement was received in the `MM` format. For example, `09` |
| day | integer | The day the settlement was received in the `DD` format. For example, |
**Response:**
```json
{
"entity": "collection",
"count": 4,
"items": [
{
"entity_id": "pay_DEXrnipqTmWVGE",
"type": "payment",
"debit": 0,
"credit": 97100,
"amount": 100000,
"currency": "INR",
"fee": 2900,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1567692556,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": "Recurring Payment via Subscription",
"notes": "{}",
"payment_id": null,
"settlement_utr": "1568176960vxp0rj",
"order_id": "order_DEXrnRiR3SNDHA",
"order_receipt": null,
"method": "card",
"card_network": "MasterCard",
"card_issuer": "KARB",
"card_type": "credit",
"dispute_id": null
},
{
"entity_id": "rfnd_DGRcGzZSLyEdg1",
"type": "refund",
"debit": 242500,
"credit": 0,
"amount": 242500,
"currency": "INR",
"fee": 0,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1568107224,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": null,
"notes": "{}",
"payment_id": "pay_DEXq1pACSqFxtS",
"settlement_utr": "1568176960vxp0rj",
"order_id": "order_DEXpmZgffXNvuI",
"order_receipt": null,
"method": "card",
"card_network": "MasterCard",
"card_issuer": "KARB",
"card_type": "credit",
"dispute_id": null
},
{
"entity_id": "trf_DEUoCEtdsJgvl7",
"type": "transfer",
"debit": 100296,
"credit": 0,
"amount": 100000,
"currency": "INR",
"fee": 296,
"tax": 46,
"on_hold": false,
"settled": true,
"created_at": 1567681786,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"credit_type": "default",
"description": null,
"notes": null,
"payment_id": "pay_DEApNNTR6xmqJy",
"settlement_utr": "1568176960vxp0rj",
"order_id": null,
"order_receipt": null,
"method": null,
"card_network": null,
"card_issuer": null,
"card_type": null,
"dispute_id": null
},
{
"entity_id": "adj_EhcHONhX4ChgNC",
"type": "adjustment",
"debit": 0,
"credit": 1012,
"amount": 1012,
"currency": "INR",
"fee": 0,
"tax": 0,
"on_hold": false,
"settled": true,
"created_at": 1567681786,
"settled_at": 1568176960,
"settlement_id": "setl_DGlQ1Rj8os78Ec",
"posted_at": null,
"description": "test reason",
"notes": null,
"payment_id": null,
"settlement_utr": null,
"order_id": null,
"order_receipt": null,
"method": null,
"card_network": null,
"card_issuer": null,
"card_type": null,
"dispute_id": null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Create on-demand settlement
```php
$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.")));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| amount*| integer | Maximum amount that can be settled |
| settle_full_balance* | boolean | true or false |
| description | string | The description may not be greater than 30 characters |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "setlod_FNj7g2YS5J67Rz",
"entity": "settlement.ondemand",
"amount_requested": 200000,
"amount_settled": 0,
"amount_pending": 199410,
"amount_reversed": 0,
"fees": 590,
"tax": 90,
"currency": "INR",
"settle_full_balance": false,
"status": "initiated",
"description": "Need this to make vendor payments.",
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1596771429,
"ondemand_payouts": {
"entity": "collection",
"count": 1,
"items": [
{
"id": "setlodp_FNj7g2cbvw8ueO",
"entity": "settlement.ondemand_payout",
"initiated_at": null,
"processed_at": null,
"reversed_at": null,
"amount": 200000,
"amount_settled": null,
"fees": 590,
"tax": 90,
"utr": null,
"status": "created",
"created_at": 1596771429
}
]
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all on-demand settlements
```php
$api->settlement->fetchAllOndemandSettlement($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**<br>
For all on-demand settlements response please click [here](https://razorpay.com/docs/api/settlements/#fetch-all-on-demand-settlements)
-------------------------------------------------------------------------------------------------------
### Fetch on-demand settlement by ID
```php
$api->settlement->fetch($settlementId)->fetchOndemandSettlementById();
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| $settlementId* | string | Settlement Id of the On-demand settlement|
**Response:**<br>
For on-demand settlement by ID response please click [here](https://razorpay.com/docs/api/settlements/#fetch-on-demand-settlements-by-id)
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/settlements/)**

View File

@@ -0,0 +1,275 @@
## Stakeholders
### Create an Stakeholder
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch("acc_GP4lfNA0iIMn5B")->stakeholders()->create(array(
"percentage_ownership" => 10,
"name" => "Gaurav Kumar",
"email" => "gaurav.kumar@example.com",
"relationship" => array(
"director" => true,
"executive" => false
),
"phone" => array(
"primary" => "7474747474",
"secondary" => "7474747474"
),
"addresses" => array(
"residential" => array(
"street" => "506, Koramangala 1st block",
"city" => "Bengaluru",
"state" => "Karnataka",
"postal_code" => "560034",
"country" => "IN"
)
),
"kyc" => array(
"pan" => "AVOPB1111K"
),
"notes" => array(
"random_key_by_partner" => "random_value"
)
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| email | string | The sub-merchant's business email address. |
| name* | string | The stakeholder's name as per the PAN card. The maximum length is 255 characters. |
| percentage_ownership | float | The stakeholder's ownership of the business in percentage. Only two decimal places are allowed. For example, `87.55`. The maximum length is 100 characters. |
| relationship | boolean | The stakeholder's relationship with the accounts business. |
| phone | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
| addresses | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
| kyc | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
| notes | object | A key-value pair |
**Response:**
```json
{
"entity": "stakeholder",
"relationship": {
"director": true
},
"phone": {
"primary": "7474747474",
"secondary": "7474747474"
},
"notes": {
"random_key_by_partner": "random_value"
},
"kyc": {
"pan": "AVOPB1111K"
},
"id": "sth_GLGgm8fFCKc92m",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"percentage_ownership": 10,
"addresses": {
"residential": {
"street": "506, Koramangala 1st block",
"city": "Bengaluru",
"state": "Karnataka",
"postal_code": "560034",
"country": "IN"
}
}
}
```
-------------------------------------------------------------------------------------------------------
### Edit Stakeholder
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$stakeholderId = "sth_GOQ4Eftlz62TSL";
$api->account->fetch($accountId)->stakeholders()->edit($stakeholderId, array(
"percentage_ownership" => 20,
"name" => "Gauri Kumar",
"relationship" => array(
"director" => false,
"executive" => true
),
"phone" => array(
"primary" => "9898989898",
"secondary" => "9898989898"
),
"addresses" => array(
"residential" => array(
"street" => "507, Koramangala 1st block",
"city" => "Bangalore",
"state" => "Karnataka",
"postal_code" => "560035",
"country" => "IN"
)
),
"kyc" => array(
"pan" => "AVOPB1111J"
),
"notes" => array(
"random_key_by_partner" => "random_value2"
)
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
| name | string | The stakeholder's name as per the PAN card. The maximum length is 255 characters. |
| percentage_ownership | float | The stakeholder's ownership of the business in percentage. Only two decimal places are allowed. For example, `87.55`. The maximum length is 100 characters. |
| relationship | boolean | The stakeholder's relationship with the accounts business. |
| phone | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
| addresses | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
| kyc | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
| notes | object | A key-value pair |
**Response:**
```json
{
"id": "acc_GP4lfNA0iIMn5B",
"type": "standard",
"status": "created",
"email": "gauri@example.org",
"profile": {
"category": "healthcare",
"subcategory": "clinic",
"addresses": {
"registered": {
"street1": "507, Koramangala 1st block",
"street2": "MG Road-1",
"city": "Bengalore",
"state": "KARNATAKA",
"postal_code": "560034",
"country": "IN"
}
}
},
"notes": [],
"created_at": 1610603081,
"phone": "9000090000",
"reference_id": "randomId",
"business_type": "partnership",
"legal_business_name": "Acme Corp",
"customer_facing_business_name": "ABCD Ltd"
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all accounts
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch($accountId)->stakeholders()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
**Response:**
```json
{
"entity": "collection",
"items": [
{
"id": "GZ13yPHLJof9IE",
"entity": "stakeholder",
"relationship": {
"director": true
},
"phone": {
"primary": "9000090000",
"secondary": "9000090000"
},
"notes": {
"random_key_by_partner": "random_value"
},
"kyc": {
"pan": "AVOPB1111K"
},
"name": "Gaurav Kumar",
"email": "gaurav.kumar@acme.org",
"percentage_ownership": 10,
"addresses": {
"residential": {
"street": "506, Koramangala 1st block",
"city": "Bengaluru",
"state": "Karnataka",
"postal_code": "560034",
"country": "in"
}
}
}
],
"count": 1
}
```
-------------------------------------------------------------------------------------------------------
### Fetch an stakeholder
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$stakeholderId = "sth_GOQ4Eftlz62TSL";
$api->account->fetch($accountId)->stakeholders()->fetch($stakeholderId);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
**Response:**
```json
{
"entity": "stakeholder",
"relationship": {
"director": true
},
"phone": {
"primary": "9000090000",
"secondary": "9000090000"
},
"notes": {
"random_key_by_partner": "random_value2"
},
"kyc": {
"pan": "AVOPB1111J"
},
"id": "sth_GOQ4Eftlz62TSL",
"name": "Gauri Kumar",
"email": "gauri@example.com",
"percentage_ownership": 20,
"addresses": {
"residential": {
"street": "507, Koramangala 1st block",
"city": "Bangalore",
"state": "Karnataka",
"postal_code": "560035",
"country": "in"
}
}
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/partners/stakeholder)**

View File

@@ -0,0 +1,671 @@
## Subscriptions
### Create subscription
```php
$api->subscription->create(array("plan_id" => "plan_Jc7wDk5iZX88wx","total_count" => 6,"quantity" => 1,"customer_notify" => 1,"start_at" => 1580453311,"expire_by" => 1580626111,"addons" => array(array("item" => array("name" => "Delivery charges","amount" => 30000,"currency" => "INR"))),"offer_id" => "offer_JCTD1XMlUmzF6Z","notes" => array("notes_key_1" => "Tea, Earl Grey, Hot","notes_key_2" => "Tea, Earl Grey… decaf.")));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| plan_id* | string | The unique identifier for a plan that should be linked to the subscription.|
| total_count* | string | The number of billing cycles for which the customer should be charged |
| customer_notify | boolean | Indicates whether the communication to the customer would be handled by you or us |
| quantity | integer | The number of times the customer should be charged the plan amount per invoice |
| start_at | integer | The timestamp, in Unix format, for when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| addons | array | All parameters listed [here](https://razorpay.com/docs/api/payments/subscriptions/#create-a-subscription) are supported |
| notes | array | Notes you can enter for the contact for future reference. |
| offer_id | string | The unique identifier of the offer that is linked to the subscription. |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"status": "created",
"current_start": null,
"current_end": null,
"ended_at": null,
"quantity": 1,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at": 1580453311,
"start_at": 1580626111,
"end_at": 1583433000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 0,
"customer_notify": true,
"created_at": 1580280581,
"expire_by": 1580626111,
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 5
}
```
-------------------------------------------------------------------------------------------------------
### Create subscription link
```php
$api->subscription->create(array("plan_id" => "plan_Jc7wDk5iZX88wx","total_count" => 12,"quantity" => 1,"start_at" => 1561852800,"expire_by" => 1561939199,"customer_notify" => 1,"addons" => array(array("item" => array("name" => "Delivery charges","amount" => 30000,"currency" => "INR"))),"offer_id" => "offer_JCTD1XMlUmzF6Z","notes" => array("notes_key_1" => "Tea, Earl Grey, Hot","notes_key_2" => "Tea, Earl Grey… decaf."),"notify_info" => array("notify_phone" => "9123456789","notify_email" => "gaurav.kumar@example.com")));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| plan_id* | string | The unique identifier for a plan that should be linked to the subscription.|
| total_count* | string | The number of billing cycles for which the customer should be charged |
| customer_notify | boolean | Indicates whether the communication to the customer would be handled by you or us |
| quantity | integer | The number of times the customer should be charged the plan amount per invoice |
| start_at | integer | The timestamp, in Unix format, for when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| addons | array | All parameters listed [here](https://razorpay.com/docs/api/payments/subscriptions/#create-a-subscription-link) are supported |
| notes | array | Notes you can enter for the contact for future reference. |
| notify_info | array | All parameters listed [here](https://razorpay.com/docs/api/payments/subscriptions/#create-a-subscription-link) are supported |
| offer_id | string | The unique identifier of the offer that is linked to the subscription. |
**Response:**
```json
{
"id":"sub_00000000000002",
"entity":"subscription",
"plan_id":"plan_00000000000001",
"status":"created",
"current_start":null,
"current_end":null,
"ended_at":null,
"quantity":1,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at":1580453311,
"start_at":1580453311,
"end_at":1587061800,
"auth_attempts":0,
"total_count":12,
"paid_count":0,
"customer_notify":true,
"created_at":1580283117,
"expire_by":1581013800,
"short_url":"https://rzp.io/i/m0y0f",
"has_scheduled_changes":false,
"change_scheduled_at":null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count":12
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all subscriptions
```php
$api->subscription->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of subscriptions to fetch (default: 10) |
| skip | integer | number of subscriptions to be skipped (default: 0) |
| plan_id | string | The unique identifier of the plan for which you want to retrieve all the subscriptions |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"customer_id": "cust_D00000000000001",
"status": "active",
"current_start": 1577355871,
"current_end": 1582655400,
"ended_at": null,
"quantity": 1,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"charge_at": 1577385991,
"offer_id": "offer_JHD834hjbxzhd38d",
"start_at": 1577385991,
"end_at": 1603737000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 1,
"customer_notify": true,
"created_at": 1577356081,
"expire_by": 1577485991,
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"remaining_count": 5
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular subscription
```php
$api->subscription->fetch($subscriptionId);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be fetched |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"customer_id": "cust_D00000000000001",
"status": "active",
"current_start": 1577355871,
"current_end": 1582655400,
"ended_at": null,
"quantity": 1,
"notes":{
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"charge_at": 1577385991,
"start_at": 1577385991,
"end_at": 1603737000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 1,
"customer_notify": true,
"created_at": 1577356081,
"expire_by": 1577485991,
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 5
}
```
-------------------------------------------------------------------------------------------------------
### Cancel particular subscription
```php
$api->subscription->fetch($subscriptionId)->cancel($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be cancelled |
| cancel_at_cycle_end | boolean | Possible values:<br>0 (default): Cancel the subscription immediately. <br> 1: Cancel the subscription at the end of the current billing cycle. |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"customer_id": "cust_D00000000000001",
"status": "cancelled",
"current_start": 1580453311,
"current_end": 1581013800,
"ended_at": 1580288092,
"quantity": 1,
"notes":{
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"charge_at": 1580453311,
"start_at": 1577385991,
"end_at": 1603737000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 1,
"customer_notify": true,
"created_at": 1580283117,
"expire_by": 1581013800,
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 5
}
```
-------------------------------------------------------------------------------------------------------
### Update particular subscription
```php
$api->subscription->fetch($subscriptionId)->update($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be updated |
| options | array | All parameters listed [here](https://razorpay.com/docs/api/subscriptions/#update-a-subscription) for update |
**Response:**
```json
{
"id":"sub_00000000000002",
"entity":"subscription",
"plan_id":"plan_00000000000002",
"customer_id":"cust_00000000000002",
"status":"authenticated",
"current_start":null,
"current_end":null,
"ended_at":null,
"quantity":3,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at":1580453311,
"start_at":1580453311,
"end_at":1606588200,
"auth_attempts":0,
"total_count":6,
"paid_count":0,
"customer_notify":true,
"created_at":1580283807,
"expire_by":1580626111,
"short_url":"https://rzp.io/i/yeDkUKy",
"has_scheduled_changes":false,
"change_scheduled_at":null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count":6
}
```
-------------------------------------------------------------------------------------------------------
### Fetch details of pending update
```php
$api->subscription->fetch($subscriptionId)->pendingUpdate()
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to fetch pending update |
**Response:**
```json
{
"id":"sub_00000000000001",
"entity":"subscription",
"plan_id":"plan_00000000000003",
"customer_id":"cust_00000000000001",
"status":"active",
"current_start":1580284732,
"current_end":1580841000,
"ended_at":null,
"quantity":25,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at":1580841000,
"start_at":1580284732,
"end_at":1611081000,
"auth_attempts":0,
"total_count":6,
"paid_count":1,
"customer_notify":true,
"created_at":1580284702,
"expire_by":1580626111,
"short_url":"https://rzp.io/i/fFWTkbf",
"has_scheduled_changes":true,
"change_scheduled_at":1557253800,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count":5
}
```
-------------------------------------------------------------------------------------------------------
### Cancel a update
```php
$api->subscription->fetch($subscriptionId)->cancelScheduledChanges();
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be cancel an update |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000003",
"customer_id": "cust_00000000000001",
"status": "active",
"current_start": 1580284732,
"current_end": 1580841000,
"ended_at": null,
"quantity": 1,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"charge_at": 1580841000,
"start_at": 1580284732,
"end_at": 1611081000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 1,
"customer_notify": true,
"created_at": 1580284702,
"expire_by": 1580626111,
"short_url": "https://rzp.io/i/fFWTkbf",
"has_scheduled_changes": false,
"change_scheduled_at": 1527858600,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 5
}
```
-------------------------------------------------------------------------------------------------------
### Pause a subscription
```php
$api->subscription->fetch($subscriptionId)->pause(array('pause_at'=>'now'));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be paused |
| pause_at | string | To pause the subscription, possible values: `now` |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"status": "paused",
"current_start": null,
"current_end": null,
"ended_at": null,
"quantity": 1,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at": null,
"start_at": 1580626111,
"end_at": 1583433000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 0,
"customer_notify": true,
"created_at": 1580280581,
"paused_at": 1590280581,
"expire_by": 1580626111,
"pause_initiated_by": "self",
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 6
}
```
-------------------------------------------------------------------------------------------------------
### Resume a subscription
```php
$api->subscription->fetch($subscriptionId)->resume(array('resume_at'=>'now'));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to be resumed |
| resume_at | string | To resume the subscription, possible values: `now` |
**Response:**
```json
{
"id": "sub_00000000000001",
"entity": "subscription",
"plan_id": "plan_00000000000001",
"status": "active",
"current_start": null,
"current_end": null,
"ended_at": null,
"quantity": 1,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"charge_at": 1580453311,
"start_at": 1580626111,
"end_at": 1583433000,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 0,
"customer_notify": true,
"created_at": 1580280581,
"paused_at": 1590280581,
"expire_by": 1580626111,
"pause_initiated_by": null,
"short_url": "https://rzp.io/i/z3b1R61A9",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "api",
"offer_id":"offer_JHD834hjbxzhd38d",
"remaining_count": 6
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all invoices for a subscription
```php
$api->invoice->all(['subscription_id'=>$subscriptionId]);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to fetch invoices |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "inv_00000000000003",
"entity": "invoice",
"receipt": null,
"invoice_number": null,
"customer_id": "cust_00000000000001",
"customer_details": {
"id": "cust_00000000000001",
"name": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": null,
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "+919876543210"
},
"order_id": "order_00000000000002",
"subscription_id": "sub_00000000000001",
"line_items": [
{
"id": "li_00000000000003",
"item_id": null,
"ref_id": null,
"ref_type": null,
"name": "Monthly Plan",
"description": null,
"amount": 99900,
"unit_amount": 99900,
"gross_amount": 99900,
"tax_amount": 0,
"taxable_amount": 99900,
"net_amount": 99900,
"currency": "INR",
"type": "plan",
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"unit": null,
"quantity": 1,
"taxes": []
}
],
"payment_id": "pay_00000000000002",
"status": "paid",
"expire_by": null,
"issued_at": 1593344888,
"paid_at": 1593344889,
"cancelled_at": null,
"expired_at": null,
"sms_status": null,
"email_status": null,
"date": 1593344888,
"terms": null,
"partial_payment": false,
"gross_amount": 99900,
"tax_amount": 0,
"taxable_amount": 99900,
"amount": 99900,
"amount_paid": 99900,
"amount_due": 0,
"currency": "INR",
"currency_symbol": "₹",
"description": null,
"notes": [],
"comment": null,
"short_url": "https://rzp.io/i/Ys4feGqEp",
"view_less": true,
"billing_start": 1594405800,
"billing_end": 1597084200,
"type": "invoice",
"group_taxes_discounts": false,
"created_at": 1593344888,
"idempotency_key": null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Delete offer linked to a subscription
```php
$api->subscription->fetch($subscriptionId)->deleteOffer($offerId);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The id of the subscription to offer need to be deleted |
| offerId* | string | The id of the offer linked to subscription |
**Response:**
```json
{
"id": "sub_I3GGEs7Xgmnozy",
"entity": "subscription",
"plan_id": "plan_HuXrfsI0ZZ3peu",
"customer_id": "cust_I3FToKbnExwDLu",
"status": "active",
"current_start": 1632914901,
"current_end": 1635445800,
"ended_at": null,
"quantity": 1,
"notes": [],
"charge_at": 1635445800,
"start_at": 1632914901,
"end_at": 1645986600,
"auth_attempts": 0,
"total_count": 6,
"paid_count": 1,
"customer_notify": true,
"created_at": 1632914246,
"expire_by": 1635532200,
"short_url": "https://rzp.io/i/SOvRWaYP81",
"has_scheduled_changes": false,
"change_scheduled_at": null,
"source": "dashboard",
"payment_method": "card",
"offer_id": null,
"remaining_count": 5
}
```
-------------------------------------------------------------------------------------------------------
### Authentication Transaction
Please refer this [doc](https://razorpay.com/docs/api/subscriptions/#authentication-transaction) for authentication of transaction
-------------------------------------------------------------------------------------------------------
### Payment verification
```php
$api->utility->verifyPaymentSignature($options)
```
Please refer this [doc](https://razorpay.com/docs/api/subscriptions/#payment-verification) for payment verification
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/subscriptions/#subscriptions)**

View File

@@ -0,0 +1,390 @@
## Tokens
### Fetch token by payment id
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
**Response:**
```json
{
"id": "pay_FHfqtkRzWvxky4",
"entity": "payment",
"amount": 100,
"currency": "INR",
"status": "captured",
"order_id": "order_FHfnswDdfu96HQ",
"invoice_id": null,
"international": false,
"method": "card",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": "card_F0zoXUp4IPPGoI",
"bank": null,
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_FHfn3rIiM1Z8nr",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"auth_code": "541898"
},
"created_at": 1595449871
}
```
-------------------------------------------------------------------------------------------------------
### Fetch tokens by customer id
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"token_HouA2OQR5Z2jTL",
"entity":"token",
"token":"2JPRk664pZHUWG",
"bank":null,
"wallet":null,
"method":"card",
"card":{
"entity":"card",
"name":"Gaurav Kumar",
"last4":"8950",
"network":"Visa",
"type":"credit",
"issuer":"STCB",
"international":false,
"emi":false,
"sub_type":"consumer",
"expiry_month":12,
"expiry_year":2021,
"flows":{
"otp":true,
"recurring":true
}
},
"recurring":true,
"recurring_details":{
"status":"confirmed",
"failure_reason":null
},
"auth_type":null,
"mrn":null,
"used_at":1629779657,
"created_at":1629779657,
"expired_at":1640975399,
"dcc_enabled":false,
"billing_address":null
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch particular token
```php
$api->customer->fetch($customerId)->tokens()->fetch($tokenId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"id": "token_Hxe0skTXLeg9pF",
"entity": "token",
"token": "F85BgXnGVwcuqV",
"bank": null,
"wallet": null,
"method": "card",
"card": {
"entity": "card",
"name": "ankit",
"last4": "5449",
"network": "MasterCard",
"type": "credit",
"issuer": "UTIB",
"international": false,
"emi": false,
"sub_type": "consumer",
"expiry_month": 12,
"expiry_year": 2024,
"flows": {
"recurring": true
}
},
"recurring": true,
"auth_type": null,
"mrn": null,
"used_at": 1632976165,
"created_at": 1631687852,
"expired_at": 1634215992,
"dcc_enabled": false
}
```
-------------------------------------------------------------------------------------------------------
### Delete token
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
### Fetch VPA tokens of a customer id
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_EeroOjvOvorT5L",
"entity": "token",
"token": "4ydxm47GQjrIEx",
"bank": null,
"wallet": null,
"method": "card",
"card": {
"entity": "card",
"name": "Gaurav Kumar",
"last4": "8430",
"network": "Visa",
"type": "credit",
"issuer": "HDFC",
"international": false,
"emi": true,
"expiry_month": 12,
"expiry_year": 2022,
"flows": {
"otp": true,
"recurring": true
}
},
"vpa": null,
"recurring": false,
"auth_type": null,
"mrn": null,
"used_at": 1586976724,
"created_at": 1586976724,
"expired_at": 1672511399,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Create a token
```php
$api->token->create(array(
"customer_id" => "cust_1Aa00000000001",
"method" => "card",
"card" => array(
"number" => "4111111111111111",
"cvv" => "123",
"expiry_month" => "12",
"expiry_year" => "21",
"name" => "Gaurav Kumar"
),
"authentication" => array(
"provider" => "razorpay",
"provider_reference_id" => "pay_123wkejnsakd",
"authentication_reference_number" => "100222021120200000000742753928"
),
"notes" => array()
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| method* | string | The type of object that needs to be tokenised. Currently, `card` is the only supported value. |
| card* | object | All keys listed [here](https://razorpay.com/docs/partners/aggregators/partner-auth/token-sharing/#create-token-on-behalf-of-a-sub-merchant) are supported
|
| authentication | object | All keys listed [here](https://razorpay.com/docs/partners/aggregators/partner-auth/token-sharing/#create-token-on-behalf-of-a-sub-merchant) are supported |
**Response:**
```json
{
"id": "token_IJmat4GwYATMtx",
"entity": "token",
"method": "card",
"card": {
"last4": "1111",
"network": "Visa",
"type": "credit",
"issuer": "IDFB",
"international": false,
"emi": false,
"sub_type": "consumer"
},
"customer": {
"id": "cust_1Aa00000000001",
"entity": "customer",
"name": "Bob",
"email": "bob@gmail.com",
"contact": "9000090000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1658390470
},
"expired_at": 1701368999,
"customer_id": "cust_1Aa00000000001",
"compliant_with_tokenisation_guidelines": true,
"status": "active",
"notes": []
}
```
-------------------------------------------------------------------------------------------------------
### Fetch token
```php
$api->token->fetch(array("id" => "token_4lsdksD31GaZ09"));
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| id* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
**Response:**
```json
{
"id": "token_4lsdksD31GaZ09",
"entity": "token",
"customer_id": "cust_1Aa00000000001",
"method": "card",
"card": {
"last4": "3335",
"network": "Visa",
"type": "debit",
"issuer": "HDFC",
"international": false,
"emi": true,
"sub_type": "consumer",
"token_iin": "453335"
},
"compliant_with_tokenisation_guidelines": true,
"expired_at": 1748716199,
"status": "active",
"status_reason": null,
"notes": []
}
```
-------------------------------------------------------------------------------------------------------
### Delete a token
```php
$api->token->delete(array("id" => "token_4lsdksD31GaZ09"));
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| id* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
**Response:**
```json
[]
```
-------------------------------------------------------------------------------------------------------
### Process a Payment on another PA/PG with Token
```php
$api->token->processPaymentOnAlternatePAorPG(array("id"=>"spt_4lsdksD31GaZ09"));
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| id* | string | The unique identifier of the token whose details are to be fetched. |
**Response:**
```json
{
"card": {
"number": "4016981500100002",
"expiry_month" : "12",
"expiry_year" : 2021
}
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/upi/tokens/)**

View File

@@ -0,0 +1,755 @@
## Transfers
### Create transfers from payment
```php
$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:**
| 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/#create-transfers-from-payments) are supported |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "trf_Jhf4Ak94xAcyeS",
"entity": "transfer",
"status": "pending",
"source": "pay_I7watngocuEY4P",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 0,
"notes": {
"name": "Gaurav Kumar",
"roll_no": "IEC2011025"
},
"linked_account_notes": [
"roll_no"
],
"on_hold": true,
"on_hold_until": 1671222870,
"recipient_settlement_id": null,
"created_at": 1655272292,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_Jhf4Ak94xAcyeS",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Create transfers from order
```php
$api->order->create(array('amount' => 2000,'currency' => 'INR','transfers' => array(array('account' => 'acc_CPRsN1LkFccllA','amount' => 1000,'currency' => 'INR','notes' => array('branch' => 'Acme Corp Bangalore North','name' => 'Gaurav Kumar'),'linked_account_notes' => array('branch'),'on_hold' => 1,'on_hold_until' => 1671222870),array('account' => 'acc_CNo3jSI8OkFJJJ','amount' => 1000,'currency' => 'INR','notes' => array('branch' => 'Acme Corp Bangalore South','name' => 'Saurav Kumar'),'linked_account_notes' => array('branch'),'on_hold' => 0))));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| amount* | integer | The transaction amount, in paise |
| currency* | string | The currency of the payment (defaults to INR) |
| receipt | string | A unique identifier provided by you for your internal reference. |
| transfers | array | All parameters listed [here](https://razorpay.com/docs/api/route/#create-transfers-from-orders) are supported |
**Response:**
```json
{
"id": "order_Jhf1Sn06my7AUb",
"entity": "order",
"amount": 2000,
"amount_paid": 0,
"amount_due": 2000,
"currency": "INR",
"receipt": null,
"offer_id": "offer_JGQvQtvJmVDRIA",
"offers": [
"offer_JGQvQtvJmVDRIA"
],
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1655272138,
"transfers": [
{
"id": "trf_Jhf1SpAYVIeRoP",
"entity": "transfer",
"status": "created",
"source": "order_Jhf1Sn06my7AUb",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 1000,
"currency": "INR",
"amount_reversed": 0,
"notes": {
"branch": "Acme Corp Bangalore North",
"name": "Gaurav Kumar"
},
"linked_account_notes": [
"branch"
],
"on_hold": true,
"on_hold_until": 1671222870,
"recipient_settlement_id": null,
"created_at": 1655272138,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_Jhf1SpAYVIeRoP",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Direct transfers
```php
$api->transfer->create(array('account' => $accountId, 'amount' => 500, 'currency' => 'INR'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The id of the account to be fetched |
| 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) |
**Response:**
```json
{
"id": "trf_JhdmwXgQpEk38N",
"entity": "transfer",
"status": "processed",
"source": "acc_HZbJUcl6DBDLIN",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 0,
"fees": 1,
"tax": 0,
"notes": [],
"linked_account_notes": [],
"on_hold": false,
"on_hold_until": null,
"recipient_settlement_id": null,
"created_at": 1655267791,
"processed_at": 1655267792,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JhdmwXgQpEk38N",
"source": null,
"metadata": null
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch transfer for a payment
```php
$api->payment->fetch($paymentId)->transfers();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "trf_JGQjgcy8zHFq7e",
"entity": "transfer",
"status": "partially_reversed",
"source": "order_JGQjgaUikLJo8n",
"recipient": "acc_HalyQGZh9ZyiGg",
"amount": 500,
"currency": "INR",
"amount_reversed": 100,
"fees": 1,
"tax": 0,
"notes": {
"branch": "Acme Corp Bangalore South",
"name": "Saurav Kumar"
},
"linked_account_notes": [
"branch"
],
"on_hold": true,
"on_hold_until": 1679691505,
"settlement_status": "on_hold",
"recipient_settlement_id": null,
"created_at": 1649326643,
"processed_at": 1649326701,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JGQjgcy8zHFq7e",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch transfer for an order
```php
$api->order->fetch($orderId)->transfers(array('expand[]'=>'transfers'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| orderId* | string | The id of the order to be fetched |
| expand* | string | Supported value is `transfer` |
**Response:**
```json
{
"id": "order_JfOO8JYmAtYRL0",
"entity": "order",
"amount": 2000,
"amount_paid": 0,
"amount_due": 2000,
"currency": "INR",
"receipt": null,
"offer_id": "offer_JGQvQtvJmVDRIA",
"offers": [
"offer_JGQvQtvJmVDRIA"
],
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1654776878,
"transfers": {
"entity": "collection",
"count": 2,
"items": [
{
"id": "trf_JfOO8LGAPdwky4",
"entity": "transfer",
"status": "created",
"source": "order_JfOO8JYmAtYRL0",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 1000,
"currency": "INR",
"amount_reversed": 0,
"fees": 0,
"tax": null,
"notes": {
"branch": "Acme Corp Bangalore North",
"name": "Gaurav Kumar"
},
"linked_account_notes": [
"branch"
],
"on_hold": true,
"on_hold_until": 1671222870,
"settlement_status": null,
"recipient_settlement_id": null,
"created_at": 1654776878,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JfOO8LGAPdwky4",
"source": null,
"metadata": null
}
},
{
"id": "trf_JfOO8M4p6tQZ6g",
"entity": "transfer",
"status": "created",
"source": "order_JfOO8JYmAtYRL0",
"recipient": "acc_HalyQGZh9ZyiGg",
"amount": 1000,
"currency": "INR",
"amount_reversed": 0,
"fees": 0,
"tax": null,
"notes": {
"branch": "Acme Corp Bangalore South",
"name": "Saurav Kumar"
},
"linked_account_notes": [
"branch"
],
"on_hold": false,
"on_hold_until": null,
"settlement_status": null,
"recipient_settlement_id": null,
"created_at": 1654776878,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JfOO8M4p6tQZ6g",
"source": null,
"metadata": null
}
}
]
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch transfer
```php
$api->transfer->fetch($transferId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| transferId* | string | The id of the transfer to be fetched |
**Response:**
```json
{
"id": "trf_IJOI2DHWQYwqU3",
"entity": "transfer",
"status": "created",
"source": "order_IJOI2CD6CNIywP",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 0,
"fees": 0,
"tax": null,
"notes": {
"branch": "Acme Corp Bangalore North",
"name": "Gaurav Kumar"
},
"linked_account_notes": [
"branch"
],
"on_hold": true,
"on_hold_until": 1671222870,
"settlement_status": null,
"recipient_settlement_id": null,
"created_at": 1636435963,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_IJOI2DHWQYwqU3",
"source": null,
"metadata": null
}
}
```
-------------------------------------------------------------------------------------------------------
### Fetch transfers for a settlement
```php
$api->transfer->all(array('recipient_settlement_id'=> $recipientSettlementId));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| recipientSettlementId* | string | The recipient settlement id obtained from the settlement.processed webhook payload. |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "trf_HWjmkReRGPhguR",
"entity": "transfer",
"status": "processed",
"source": "pay_HWjY9DZSMsbm5E",
"recipient": "acc_HWjl1kqobJzf4i",
"amount": 1000,
"currency": "INR",
"amount_reversed": 0,
"fees": 3,
"tax": 0,
"notes": [],
"linked_account_notes": [],
"on_hold": false,
"on_hold_until": null,
"settlement_status": "settled",
"recipient_settlement_id": "setl_HYIIk3H0J4PYdX",
"created_at": 1625812996,
"processed_at": 1625812996,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_HWjmkReRGPhguR",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch settlement details
```php
$api->transfer->all(array('expand[]'=> 'recipient_settlement'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| expand* | string | Supported value is `recipient_settlement` |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "trf_JhdmwXgQpEk38N",
"entity": "transfer",
"status": "processed",
"source": "acc_HZbJUcl6DBDLIN",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 0,
"fees": 1,
"tax": 0,
"notes": [],
"linked_account_notes": [],
"on_hold": false,
"on_hold_until": null,
"settlement_status": null,
"recipient_settlement_id": null,
"recipient_settlement": null,
"created_at": 1655267791,
"processed_at": 1655267792,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JhdmwXgQpEk38N",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Refund payments and reverse transfer from a linked account
```php
$api->payment->fetch("pay_JsPSazUg9UnOX2")->refund(array('amount'=> '100','reverse_all'=>'1'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| paymentId* | string | The id of the payment to be fetched |
| amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
| reverse_all | boolean | Reverses transfer made to a linked account. Possible values:<br> * `1` - Reverses transfer made to a linked account.<br>* `0` - Does not reverse transfer made to a linked account.|
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "pay_JHAe1Zat55GbZB",
"entity": "payment",
"amount": 5000,
"currency": "INR",
"status": "captured",
"order_id": "order_IluGWxBm9U8zJ8",
"invoice_id": null,
"international": false,
"method": "netbanking",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "Test Transaction",
"card_id": null,
"bank": "KKBK",
"wallet": null,
"vpa": null,
"email": "gaurav.kumar@example.com",
"contact": "+919999999999",
"notes": {
"address": "Razorpay Corporate Office"
},
"fee": 118,
"tax": 18,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"bank_transaction_id": "7003347"
},
"created_at": 1649488316
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payments of a linked account
```php
$api->setHeader('X-Razorpay-Account', 'acc_IRQWUleX4BqvYn');
$api->payment->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| X-Razorpay-Account | string | The linked account id to fetch the payments received by linked account |
**Response:**
```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "pay_E9uth3WhYbh9QV",
"entity": "payment",
"amount": 100,
"currency": "INR",
"status": "captured",
"order_id": null,
"invoice_id": null,
"international": null,
"method": "transfer",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": null,
"bank": null,
"wallet": null,
"vpa": null,
"email": "",
"contact": null,
"notes": [],
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"created_at": 1580219046
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Reverse transfers from all linked accounts
```php
$api->transfer->fetch($transferId)->reverse(array('amount'=>'100'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| transferId* | string | The id of the transfer to be fetched |
| amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
**Response:**
```json
{
"id": "rfnd_JJFNlNXPHY640A",
"entity": "refund",
"amount": 100,
"currency": "INR",
"payment_id": "pay_JJCqynf4fQS0N1",
"notes": [],
"receipt": null,
"acquirer_data": {
"arn": null
},
"created_at": 1649941680,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "normal"
}
```
-------------------------------------------------------------------------------------------------------
### Hold settlements for transfers
```php
$api->payment->fetch($paymentId)->transfer(array('transfers' => array(array('account' => 'acc_I0QRP7PpvaHhpB','amount' => 100,'currency' => 'INR','on_hold' => true))));
```
**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 |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "trf_JhemwjNekar9Za",
"entity": "transfer",
"status": "pending",
"source": "pay_I7watngocuEY4P",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 0,
"notes": [],
"linked_account_notes": [],
"on_hold": true,
"on_hold_until": null,
"recipient_settlement_id": null,
"created_at": 1655271313,
"processed_at": null,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JhemwjNekar9Za",
"source": null,
"metadata": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Modify settlement hold for transfers
```php
$api->transfer->fetch($transferId)->edit(array('on_hold' => '1', 'on_hold_until' => '1679691505'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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
{
"id": "trf_JOmyyZ7lsxDzwF",
"entity": "transfer",
"status": "reversed",
"source": "acc_HZbJUcl6DBDLIN",
"recipient": "acc_HjVXbtpSCIxENR",
"amount": 100,
"currency": "INR",
"amount_reversed": 100,
"fees": 1,
"tax": 0,
"notes": [],
"linked_account_notes": [],
"on_hold": true,
"on_hold_until": null,
"settlement_status": null,
"recipient_settlement_id": null,
"created_at": 1651151707,
"processed_at": 1651151708,
"error": {
"code": null,
"description": null,
"reason": null,
"field": null,
"step": null,
"id": "trf_JOmyyZ7lsxDzwF",
"source": null,
"metadata": null
}
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/route/#transfers/)**

View File

@@ -0,0 +1,460 @@
## UPI
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780', 'fail_existing'=> '0', 'notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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 |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Create order
```php
$api->order->create(array('amount' => 0,'currency' => 'INR','method' => 'upi','customer_id' => 'cust_4xbQrmEoA5WJ01', 'token' => array('max_amount' => 200000, 'expire_at' => 2709971120, 'frequency' => 'monthly'),'receipt' => 'Receipt No. 1' ,'notes' => array('notes_key_1' => 'Beam me up Scotty','notes_key_2' => 'Engage')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| amount* | integer | Amount of the order to be paid |
| currency* | string | Currency of the order. Currently only `INR` is supported. |
| method* | string | The authorization method. In this case the value will be `upi` |
| receipt | string | Your system order reference id. |
| notes | array | A key-value pair |
| token* | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction/#112-create-an-order) are supported |
**Response:**
```json
{
"id": "order_1Aa00000000002",
"entity": "order",
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"receipt": "Receipt No. 1",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1565172642
}
```
-------------------------------------------------------------------------------------------------------
### Create an Authorization Payment
Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/upi/authorization-transaction/#113-create-an-authorization-payment) for authorization payment
-------------------------------------------------------------------------------------------------------
### Create registration link
```php
$api->subscription->createSubscriptionRegistration(array('customer'=>array('name'=>'Gaurav Kumar','email'=>'gaurav.kumar@example.com','contact'=>'9123456780'),'type'=>'link','amount'=>100,'currency'=>'INR','description'=>'Registration Link for Gaurav Kumar','subscription_registration'=>array('method'=>'upi', 'max_amount'=>'500', 'expire_at'=>'1634215992', 'frequency'=>'monthly'),'receipt'=>'Receipt No. 5','email_notify'=>1,'sms_notify'=>1,'expire_by'=>1634215992,'notes' => array('note_key 1' => 'Beam me up Scotty','note_key 2' => 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| customer | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction/#121-create-a-registration-link) are supported |
| type* | string | In this case, the value is `link`. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| amount* | integer | The payment amount in the smallest currency sub-unit. |
| description* | string | A description that appears on the hosted page. For example, `12:30 p.m. Thali meals (Gaurav Kumar`). |
| subscription_registration | array | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction/#121-create-a-registration-link) are supported |
| sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
| email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "inv_FHr1ekX0r2VCVK",
"entity": "invoice",
"receipt": "Receipt No. 23",
"invoice_number": "Receipt No. 23",
"customer_id": "cust_BMB3EwbqnqZ2EI",
"customer_details": {
"id": "cust_BMB3EwbqnqZ2EI",
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9123456780",
"gstin": null,
"billing_address": null,
"shipping_address": null,
"customer_name": "Gaurav Kumar",
"customer_email": "gaurav.kumar@example.com",
"customer_contact": "9123456780"
},
"order_id": "order_FHr1ehR3nmNeXo",
"line_items": [],
"payment_id": null,
"status": "issued",
"expire_by": 4102444799,
"issued_at": 1595489219,
"paid_at": null,
"cancelled_at": null,
"expired_at": null,
"sms_status": "pending",
"email_status": "pending",
"date": 1595489219,
"terms": null,
"partial_payment": false,
"gross_amount": 100,
"tax_amount": 0,
"taxable_amount": 0,
"amount": 100,
"amount_paid": 0,
"amount_due": 100,
"currency": "INR",
"currency_symbol": "₹",
"description": "Registration Link for Gaurav Kumar",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"comment": null,
"short_url": "https://rzp.io/i/ak1WxDB",
"view_less": true,
"billing_start": null,
"billing_end": null,
"type": "link",
"group_taxes_discounts": false,
"created_at": 1595489219,
"idempotency_key": null
}
```
-------------------------------------------------------------------------------------------------------
### Send/Resend notifications
```php
$api->invoice->fetch($invoiceId)->notifyBy($medium);
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be notified |
| medium* | string | `sms`/`email`, Medium through which notification should be sent. |
**Response:**
```json
{
"success": true
}
```
-------------------------------------------------------------------------------------------------------
### Cancel a registration link
```php
$api->invoice->fetch($invoiceId)->cancel();
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| invoiceId* | string | The id of the invoice to be cancelled |
**Response:**
```json
{
"amount": 100,
"amount_due": 100,
"amount_paid": 0,
"auth_link_status": "cancelled",
"billing_end": null,
"billing_start": null,
"cancelled_at": 1655110334,
"comment": null,
"created_at": 1655110315,
"currency": "INR",
"currency_symbol": "₹",
"customer_details": {
"billing_address": null,
"contact": "9123456780",
"customer_contact": "9123456780",
"customer_email": "gaurav.kumar@example.com",
"customer_name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"gstin": null,
"id": "cust_DzYEzfJLV03rkp",
"name": "Gaurav Kumar",
"shipping_address": null
},
"customer_id": "cust_DzYEzfJLV03rkp",
"date": 1655110315,
"description": "Registration Link for Gaurav Kumar",
"email_status": "sent",
"entity": "invoice",
"expire_by": 1657699317,
"expired_at": null,
"first_payment_min_amount": null,
"gross_amount": 100,
"group_taxes_discounts": false,
"id": "inv_Jgv4UErmFzfrA0",
"idempotency_key": null,
"invoice_number": "Receipt No. #51",
"issued_at": 1655110315,
"line_items": [],
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"order_id": "order_Jgv4UAyqlixvOB",
"paid_at": null,
"partial_payment": false,
"payment_id": null,
"receipt": "Receipt No. #51",
"reminder_status": null,
"short_url": "https://rzp.io/i/VuAC1WG",
"sms_status": "sent",
"status": "cancelled",
"subscription_status": null,
"supply_state_code": null,
"tax_amount": 0,
"taxable_amount": 0,
"terms": null,
"type": "link",
"user_id": null,
"view_less": true
}
```
-------------------------------------------------------------------------------------------------------
### Fetch token by payment ID
```php
$api->payment->fetch($paymentId);
```
**Parameters:**
| Name | Type | Description |
|------------|--------|-----------------------------------|
| paymentId* | string | Id of the payment to be retrieved |
**Response:**
```json
{
"id": "pay_FHfAzEJ51k8NLj",
"entity": "payment",
"amount": 100,
"currency": "INR",
"status": "captured",
"order_id": "order_FHfANdTUYeP8lb",
"invoice_id": null,
"international": false,
"method": "upi",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": null,
"bank": null,
"wallet": null,
"vpa": "gaurav.kumar@upi",
"email": "gaurav.kumar@example.com",
"contact": "+919876543210",
"customer_id": "cust_DtHaBuooGHTuyZ",
"token_id": "token_FHfAzGzREc1ug6",
"notes": {
"note_key 1": "Beam me up Scotty",
"note_key 2": "Tea. Earl Gray. Hot."
},
"fee": 0,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"rrn": "854977234911",
"upi_transaction_id": "D0BED5A062ECDB3E9B3A1071C96BB273"
},
"created_at": 1595447490
}
```
-------------------------------------------------------------------------------------------------------
### Fetch tokens by customer ID
```php
$api->customer->fetch($customerId)->tokens()->all();
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "token_FHfAzGzREc1ug6",
"entity": "token",
"token": "9KHsdPaCELeQ0t",
"bank": null,
"wallet": null,
"method": "upi",
"vpa": {
"username": "gaurav.kumar",
"handle": "upi",
"name": null
},
"recurring": true,
"recurring_details": {
"status": "confirmed",
"failure_reason": null
},
"auth_type": null,
"mrn": null,
"used_at": 1595447490,
"created_at": 1595447490,
"start_time": 1595447455,
"dcc_enabled": false
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Delete token
```php
$api->customer->fetch($customerId)->tokens()->delete($tokenId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
| tokenId* | string | The id of the token to be fetched |
**Response:**
```json
{
"deleted": true
}
```
-------------------------------------------------------------------------------------------------------
### Create an order to charge the customer
```php
$api->order->create(array('amount' => 1000,'currency' => 'INR','payment_capture' => true,'receipt' => 'Receipt No. 1','notes'=> array('notes_key_1' => 'Tea, Earl Grey, Hot', 'notes_key_2' => 'Tea, Earl Grey… decaf.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| 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 |
| 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
{
"id":"order_1Aa00000000002",
"entity":"order",
"amount":1000,
"amount_paid":0,
"amount_due":1000,
"currency":"INR",
"receipt":"Receipt No. 1",
"offer_id":null,
"status":"created",
"attempts":0,
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at":1579782776
}
```
-------------------------------------------------------------------------------------------------------
### Create a recurring payment
```php
$api->payment->createRecurring(array('email'=>'gaurav.kumar@example.com','contact'=>'9123456789','amount'=>100,'currency'=>'INR','order_id'=>'order_1Aa00000000002','customer_id'=>'cust_1Aa00000000001','token'=>'token_1Aa00000000001','recurring'=>'1','description'=>'Creating recurring payment for Gaurav Kumar', 'notes'=> array('note_key 1' => 'Beam me up Scotty', 'note_key 2' => 'Tea. Earl Gray. Hot.')));
```
**Parameters:**
| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| email* | string | The customer's email address. |
| contact* | string | The customer's phone number. |
| amount* | integer | The amount you want to charge your customer. This should be the same as the amount in the order. |
| currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
| order_id* | string | The unique identifier of the order created. |
| 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. |
**Response:**
```json
{
"razorpay_payment_id" : "pay_1Aa00000000001",
"razorpay_order_id" : "order_1Aa00000000001",
"razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/recurring-payments/upi/authorization-transaction/)**

View File

@@ -0,0 +1,509 @@
## Virtual account
### Create a virtual account
```php
$api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => 'cust_CaVDm8eDRSXYME','close_by' => 1681615838,'notes' => array('project_name' => 'Banking Software')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| receivers* | array | Array that defines what receivers are available for this Virtual Account |
| description | string | A brief description of the virtual account. |
| customer_id | string | Unique identifier of the customer to whom the virtual account must be tagged. |
| close_by | integer | UNIX timestamp at which the virtual account is scheduled to be automatically closed. |
| notes | integer | Any custom notes you might want to add to the virtual account can be entered here. |
**Response:**
```json
{
"id":"va_DlGmm7jInLudH9",
"name":"Acme Corp",
"entity":"virtual_account",
"status":"active",
"description":"Virtual Account created for Raftar Soft",
"amount_expected":null,
"notes":{
"project_name":"Banking Software"
},
"amount_paid":0,
"customer_id":"cust_CaVDm8eDRSXYME",
"receivers":[
{
"id":"ba_DlGmm9mSj8fjRM",
"entity":"bank_account",
"ifsc":"RATN0VAAPIS",
"bank_name": "RBL Bank",
"name":"Acme Corp",
"notes":[],
"account_number":"2223330099089860"
}
],
"close_by":1681615838,
"closed_at":null,
"created_at":1574837626
}
```
-------------------------------------------------------------------------------------------------------
### Create a virtual account with TPV
```php
$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' => 'cust_HssUOFiOd2b1TJ', 'notes' => array('project_name' => 'Banking Software')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| receivers* | array | Array that defines what receivers are available for this Virtual Account |
| allowed_payers* | array | All parameters listed [here](https://razorpay.com/docs/api/smart-collect-tpv/#create-virtual-account) are supported
**Response:**
```json
{
"id":"va_DlGmm7jInLudH9",
"name":"Acme Corp",
"entity":"virtual_account",
"status":"active",
"description":"Virtual Account created for Raftar Soft",
"amount_expected":null,
"notes":{
"project_name":"Banking Software"
},
"amount_paid":0,
"customer_id":"cust_CaVDm8eDRSXYME",
"receivers":[
{
"id":"ba_DlGmm9mSj8fjRM",
"entity":"bank_account",
"ifsc":"RATN0VAAPIS",
"bank_name": "RBL Bank",
"name":"Acme Corp",
"notes":[],
"account_number":"2223330099089860"
}
],
"allowed_payers": [
{
"type": "bank_account",
"id":"ba_DlGmm9mSj8fjRM",
"bank_account": {
"ifsc": "UTIB0000013",
"account_number": "914010012345679"
}
},
{
"type": "bank_account",
"id":"ba_Cmtnm5tSj6agUW",
"bank_account": {
"ifsc": "UTIB0000014",
"account_number": "914010012345680"
}
}
],
"close_by":1681615838,
"closed_at":null,
"created_at":1574837626
}
```
-------------------------------------------------------------------------------------------------------
### Create static/dynamic qr
```php
$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:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| 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. |
| 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
{
"id": "va_4xbQrmEoA5WJ0G",
"name": "Acme Corp",
"entity": "virtual_account",
"status": "active",
"description": "First Payment by BharatQR",
"amount_expected": null,
"notes": {
"reference_key": "reference_value"
},
"amount_paid": 0,
"customer_id": "cust_805c8oBQdBGPwS",
"receivers": [
{
"id": "qr_4lsdkfldlteskf",
"entity": "qr_code",
"reference": "AgdeP8aBgZGckl",
"short_url": "https://rzp.io/i/PLs03pOc"
}
],
"close_by": null,
"closed_at": null,
"created_at": 1607938184
}
```
-------------------------------------------------------------------------------------------------------
### Fetch virtual account by id
```php
$api->virtualAccount->fetch($virtualId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| virtualId* | string | The id of the virtual to be updated |
**Response:**
```json
{
"id": "va_JccTXwXA6UG4Gi",
"name": "ankit",
"entity": "virtual_account",
"status": "active",
"description": null,
"amount_expected": null,
"notes": [],
"amount_paid": 0,
"customer_id": null,
"receivers": [
{
"id": "ba_JccTY5ZkO3ZGHQ",
"entity": "bank_account",
"ifsc": "RAZR0000001",
"bank_name": null,
"name": "ankit",
"notes": [],
"account_number": "1112220057339365"
}
],
"close_by": null,
"closed_at": null,
"created_at": 1654171468
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all virtual account
```php
$api->virtualAccount->all($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of virtual accounts to fetch (default: 10) |
| skip | integer | number of virtual accounts to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "va_Di5gbNptcWV8fQ",
"name": "Acme Corp",
"entity": "virtual_account",
"status": "closed",
"description": "Virtual Account created for M/S ABC Exports",
"amount_expected": 2300,
"notes": {
"material": "teakwood"
},
"amount_paid": 239000,
"customer_id": "cust_DOMUFFiGdCaCUJ",
"receivers": [
{
"id": "ba_Di5gbQsGn0QSz3",
"entity": "bank_account",
"ifsc": "RATN0VAAPIS",
"bank_name": "RBL Bank",
"name": "Acme Corp",
"notes": [],
"account_number": "1112220061746877"
}
],
"close_by": 1574427237,
"closed_at": 1574164078,
"created_at": 1574143517
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payments for a virtual account
```php
$api->virtualAccount->fetch($virtualId)->payments($options);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| virtualId* | string | The id of the virtual to be updated |
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of virtual accounts to fetch (default: 10) |
| skip | integer | number of virtual accounts to be skipped (default: 0) |
**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "pay_Di5iqCqA1WEHq6",
"entity": "payment",
"amount": 239000,
"currency": "INR",
"status": "captured",
"order_id": null,
"invoice_id": null,
"international": false,
"method": "bank_transfer",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "",
"card_id": null,
"bank": null,
"wallet": null,
"vpa": null,
"email": "saurav.kumar@example.com",
"contact": "+919972139994",
"customer_id": "cust_DOMUFFiGdCaCUJ",
"notes": [],
"fee": 2820,
"tax": 430,
"error_code": null,
"error_description": null,
"created_at": 1574143644
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch payment details using id and transfer method
```php
$api->payment->fetch($paymentId)->bankTransfer();
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| paymentId* | string | The id of the payment to be updated |
**Response:**
```json
{
"id": "bt_Di5iqCElVyRlCb",
"entity": "bank_transfer",
"payment_id": "pay_Di5iqCqA1WEHq6",
"mode": "NEFT",
"bank_reference": "157414364471",
"amount": 239000,
"payer_bank_account": {
"id": "ba_Di5iqSxtYrTzPU",
"entity": "bank_account",
"ifsc": "UTIB0003198",
"bank_name": "Axis Bank",
"name": "Acme Corp",
"notes": [],
"account_number": "765432123456789"
},
"virtual_account_id": "va_Di5gbNptcWV8fQ",
"virtual_account": {
"id": "va_Di5gbNptcWV8fQ",
"name": "Acme Corp",
"entity": "virtual_account",
"status": "closed",
"description": "Virtual Account created for M/S ABC Exports",
"amount_expected": 2300,
"notes": {
"material": "teakwood"
},
"amount_paid": 239000,
"customer_id": "cust_DOMUFFiGdCaCUJ",
"receivers": [
{
"id": "ba_Di5gbQsGn0QSz3",
"entity": "bank_account",
"ifsc": "RATN0VAAPIS",
"bank_name": "RBL Bank",
"name": "Acme Corp",
"notes": [],
"account_number": "1112220061746877"
}
],
"close_by": 1574427237,
"closed_at": 1574164078,
"created_at": 1574143517
}
}
```
-------------------------------------------------------------------------------------------------------
### Refund payments made to a virtual account
```php
$api->payment->fetch($paymentId)->refunds();
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| paymentId* | string | The id of the payment to be updated |
**Response:**
```json
{
"id": "rfnd_FP8QHiV938haTz",
"entity": "refund",
"amount": 500100,
"receipt": "Receipt No. 31",
"currency": "INR",
"payment_id": "pay_FCXKPFtYfPXJPy",
"notes": []
"receipt": null,
"acquirer_data": {
"arn": null
},
"created_at": 1597078866,
"batch_id": null,
"status": "processed",
"speed_processed": "normal",
"speed_requested": "normal"
}
```
-------------------------------------------------------------------------------------------------------
### Add receiver to an existing virtual account
```php
$api->virtualAccount->fetch($virtualId)->addReceiver(array('types' => array('vpa'),'vpa' => array('descriptor'=>'gauravkumar')));
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| virtualId* | string | The id of the virtual to be updated |
| types* | array | The receiver type to be added to the virtual account. Possible values are `vpa` or `bank_account` |
| vpa["descriptor"] | string | This is a unique identifier provided by you to identify the customer. For example, `gaurikumar` and `akashkumar` are the descriptors |
**Response:**
For add receiver to an existing virtual account response please click [here](https://razorpay.com/docs/api/smart-collect/#add-receiver-to-an-existing-virtual-account)
-------------------------------------------------------------------------------------------------------
### Add an Allowed Payer Account
```php
$api->virtualAccount->fetch($virtualId)->addAllowedPayer(array('type' => 'bank_account','bank_account' => array('ifsc'=>'UTIB0000013','account_number'=>'914010012345679')));
```
**Parameters:**
| 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:**
```json
{
"id":"va_DlGmm7jInLudH9",
"name":"Acme Corp",
"entity":"virtual_account",
"status":"active",
"description":"Virtual Account created for Raftar Soft",
"amount_expected":null,
"notes":{
"project_name":"Banking Software"
},
"amount_paid":0,
"customer_id":"cust_CaVDm8eDRSXYME",
"receivers":[
{
"id":"ba_DlGmm9mSj8fjRM",
"entity":"bank_account",
"ifsc":"RATN0VAAPIS",
"bank_name": "RBL Bank",
"name":"Acme Corp",
"notes":[],
"account_number":"2223330099089860"
}
],
"allowed_payers": [
{
"type": "bank_account",
"id":"ba_DlGmm9mSj8fjRM",
"bank_account": {
"ifsc": "UTIB0000013",
"account_number": "914010012345679"
}
}
],
"close_by":1681615838,
"closed_at":null,
"created_at":1574837626
}
```
-------------------------------------------------------------------------------------------------------
### Delete an Allowed Payer Account
```php
$api->virtualAccount->fetch($virtualId)->deleteAllowedPayer($allowedPayersId);
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| virtualId* | string | The id of the virtual to be updated |
| allowedPayersId* | string | The id of the allowed payers to be updated |
**Response:**
```json
null
```
-------------------------------------------------------------------------------------------------------
### Close virtual account
```php
$api->virtualAccount->fetch($virtualId)->close();
```
**Parameters:**
| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| virtualId* | string | The id of the virtual to be updated |
**Response:**
For close virtual account response please click [here](https://razorpay.com/docs/api/smart-collect/#close-a-virtual-account)
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/smart-collect/api/)**

View File

@@ -0,0 +1,223 @@
## Webhook
### Create a Webhook
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch($accountId)->webhooks()->create(array(
"url" => "https://google.com",
"alert_email" => "gaurav.kumar@example.com",
"secret" => "12345",
"events" => array(
"payment.authorized",
"payment.failed",
"payment.captured",
"payment.dispute.created",
"refund.failed",
"refund.created"
)
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| url* | string | The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters. |
| alert_email | string | This is the email address to which notifications must be sent in case of webhook failure. |
| secret | string | A secret for the webhook endpoint that is used to validate that the webhook is from Razorpay. |
| events | string | The required events from the list of Active Events. For example `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on. |
**Response:**
```json
{
"id": "JebiXkKGYwua5L",
"created_at": 1654605478,
"updated_at": 1654605478,
"service": "beta-api-live",
"owner_id": "JOGUdtKu3dB03d",
"owner_type": "merchant",
"context": [],
"disabled_at": 0,
"url": "https://google.com",
"alert_email": "gaurav.kumar@example.com",
"secret_exists": true,
"entity": "webhook",
"active": true,
"events": [
"payment.authorized",
"payment.failed",
"payment.captured",
"payment.dispute.created",
"refund.failed",
"refund.created"
]
}
```
-------------------------------------------------------------------------------------------------------
### Edit Webhook
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$webhookId = "HK890egfiItP3H";
$api->account->fetch($accountId)->webhooks()->edit($webhookId, array(
"url" => "https://www.linkedin.com",
"events" => array(
"refund.created"
)
));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| webhookId* | string | The unique identifier of the webhook whose details are to be updated |
| url | string | The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters. |
| events | string | The required events from the list of Active Events. For example `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on. |
**Response:**
```json
{
"id": "HK890egfiItP3H",
"created_at": 1623060358,
"updated_at": 1623067148,
"service": "beta-api-test",
"owner_id": "H3kYHQ635sBwXG",
"owner_type": "merchant",
"context": [],
"disabled_at": 0,
"url": "https://www.linkedin.com",
"alert_email": "gaurav.kumar@example.com",
"secret_exists": true,
"entity": "webhook",
"active": true,
"events": [
"refund.created"
]
}
```
-------------------------------------------------------------------------------------------------------
### Delete an account
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$webhookId = "HK890egfiItP3H";
$api->account->fetch($accountId)->webhooks()->delete($webhookId);
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account that must be deleted. |
| webhookId* | string | The unique identifier of the webhook whose details are to be updated |
**Response:**
```json
[]
```
-------------------------------------------------------------------------------------------------------
### Fetch a webhook
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$webhookId = "HK890egfiItP3H";
$api->account->fetch($accountId)->webhooks()->fetch($webhookId);
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| webhookId* | string | The unique identifier of the webhook whose details are to be updated |
**Response:**
```json
{
"id": "HK890egfiItP3H",
"created_at": 1623060358,
"updated_at": 1623060358,
"owner_id": "H3kYHQ635sBwXG",
"owner_type": "merchant",
"context": [],
"disabled_at": 0,
"url": "https://en1mwkqo5ioct.x.pipedream.net",
"alert_email": "gaurav.kumar@example.com",
"secret_exists": true,
"entity": "webhook",
"active": true,
"events": [
"payment.authorized",
"payment.failed",
"payment.captured",
"payment.dispute.created",
"refund.failed",
"refund.created"
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all Webhooks
```php
$accountId = "acc_GP4lfNA0iIMn5B";
$api->account->fetch($accountId)->webhooks()->all();
```
**Parameters:**
| Name | Type | Description |
|-------------|-------------|---------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| from | integer | Timestamp, in seconds, from when the webhooks are to be fetched. |
| to | integer | Timestamp, in seconds, till when the webhooks are to be fetched. |
| count | integer | Number of webhooks to be fetched. The default value is `10` and the maximum value is `100`. This can be used for pagination, in combination with `skip`. |
| skip | integer | Number of records to be skipped while fetching the webhooks. This can be used for pagination, in combination with `count`. |
**Response:**
```json
{
"id": "HK890egfiItP3H",
"created_at": 1623060358,
"updated_at": 1623060358,
"owner_id": "H3kYHQ635sBwXG",
"owner_type": "merchant",
"context": [],
"disabled_at": 0,
"url": "https://en1mwkqo5ioct.x.pipedream.net",
"alert_email": "gaurav.kumar@example.com",
"secret_exists": true,
"entity": "webhook",
"active": true,
"events": [
"payment.authorized",
"payment.failed",
"payment.captured",
"payment.dispute.created",
"refund.failed",
"refund.created"
]
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/partners/webhooks)**

View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
[{*.json,*.yml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
Requests
========
Copyright (c) 2010-2012 Ryan McCue and contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ComplexPie IRI Parser
=====================
Copyright (c) 2007-2010, Geoffrey Sneddon and Steve Minutillo.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the SimplePie Team nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,168 @@
Requests for PHP
================
[![CS](https://github.com/WordPress/Requests/actions/workflows/cs.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/cs.yml)
[![Lint](https://github.com/WordPress/Requests/actions/workflows/lint.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/lint.yml)
[![Test](https://github.com/WordPress/Requests/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/test.yml)
[![codecov.io](https://codecov.io/gh/WordPress/Requests/branch/stable/graph/badge.svg?token=AfpxK7WMxj&branch=stable)](https://codecov.io/gh/WordPress/Requests?branch=stable)
Requests is a HTTP library written in PHP, for human beings. It is roughly
based on the API from the excellent [Requests Python
library](http://python-requests.org/). Requests is [ISC
Licensed](https://github.com/WordPress/Requests/blob/stable/LICENSE) (similar to
the new BSD license) and has no dependencies, except for PHP 5.6+.
Despite PHP's use as a language for the web, its tools for sending HTTP requests
are severely lacking. cURL has an
[interesting API](https://www.php.net/curl-setopt), to say the
least, and you can't always rely on it being available. Sockets provide only low
level access, and require you to build most of the HTTP response parsing
yourself.
We all have better things to do. That's why Requests was born.
```php
$headers = array('Accept' => 'application/json');
$options = array('auth' => array('user', 'pass'));
$request = WpOrg\Requests\Requests::get('https://api.github.com/gists', $headers, $options);
var_dump($request->status_code);
// int(200)
var_dump($request->headers['content-type']);
// string(31) "application/json; charset=utf-8"
var_dump($request->body);
// string(26891) "[...]"
```
Requests allows you to send **HEAD**, **GET**, **POST**, **PUT**, **DELETE**,
and **PATCH** HTTP requests. You can add headers, form data, multipart files,
and parameters with basic arrays, and access the response data in the same way.
Requests uses cURL and fsockopen, depending on what your system has available,
but abstracts all the nasty stuff out of your way, providing a consistent API.
Features
--------
- International Domains and URLs
- Browser-style SSL Verification
- Basic/Digest Authentication
- Automatic Decompression
- Connection Timeouts
Installation
------------
### Install with Composer
If you're using [Composer](https://getcomposer.org/) to manage
dependencies, you can add Requests with it.
```sh
composer require rmccue/requests
```
or
```json
{
"require": {
"rmccue/requests": "^2.0"
}
}
```
### Install source from GitHub
To install the source code:
```bash
$ git clone git://github.com/WordPress/Requests.git
```
Next, include the autoloader in your scripts:
```php
require_once '/path/to/Requests/src/Autoload.php';
```
You'll probably also want to register the autoloader:
```php
WpOrg\Requests\Autoload::register();
```
### Install source from zip/tarball
Alternatively, you can fetch a [tarball][] or [zipball][]:
```bash
$ curl -L https://github.com/WordPress/Requests/tarball/stable | tar xzv
(or)
$ wget https://github.com/WordPress/Requests/tarball/stable -O - | tar xzv
```
[tarball]: https://github.com/WordPress/Requests/tarball/stable
[zipball]: https://github.com/WordPress/Requests/zipball/stable
### Using a Class Loader
If you're using a class loader (e.g., [Symfony Class Loader][]) for
[PSR-4][]-style class loading:
```php
$loader = new Psr4ClassLoader();
$loader->addPrefix('WpOrg\\Requests\\', 'path/to/vendor/Requests/src');
$loader->register();
```
[Symfony Class Loader]: https://github.com/symfony/ClassLoader
[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4.md
Documentation
-------------
The best place to start is our [prose-based documentation][], which will guide
you through using Requests.
After that, take a look at [the documentation for
`\WpOrg\Requests\Requests::request()`][request_method], where all the parameters are fully
documented.
Requests is [100% documented with PHPDoc](https://requests.ryanmccue.info/api-2.x/).
If you find any problems with it, [create a new
issue](https://github.com/WordPress/Requests/issues/new)!
[prose-based documentation]: https://github.com/WordPress/Requests/blob/stable/docs/README.md
[request_method]: https://requests.ryanmccue.info/api-2.x/classes/WpOrg-Requests-Requests.html#method_request
Testing
-------
Requests strives to have 100% code-coverage of the library with an extensive
set of tests. We're not quite there yet, but [we're getting close][codecov].
[codecov]: https://codecov.io/github/WordPress/Requests/
To run the test suite, first check that you have the [PHP
JSON extension ](https://www.php.net/book.json) enabled. Then
simply:
```bash
$ phpunit
```
If you'd like to run a single set of tests, specify just the name:
```bash
$ phpunit Transport/cURL
```
Contribute
----------
1. Check for open issues or open a new issue for a feature request or a bug.
2. Fork [the repository][] on Github to start making your changes to the
`develop` branch (or branch off of it).
3. Write one or more tests which show that the bug was fixed or that the feature works as expected.
4. Send in a pull request.
If you have questions while working on your contribution and you use Slack, there is
a [#core-http-api] channel available in the [WordPress Slack] in which contributions can be discussed.
[the repository]: https://github.com/WordPress/Requests
[#core-http-api]: https://wordpress.slack.com/archives/C02BBE29V42
[WordPress Slack]: https://make.wordpress.org/chat/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
6ed95025fba2aef0ce7b647607225745624497f876d74ef6ec22b26e73e9de77 cacert.pem

View File

@@ -0,0 +1,88 @@
{
"name": "rmccue/requests",
"description": "A HTTP library written in PHP, for human beings.",
"homepage": "https://requests.ryanmccue.info/",
"license": "ISC",
"type": "library",
"keywords": [
"http",
"idna",
"iri",
"ipv6",
"curl",
"sockets",
"fsockopen"
],
"authors": [
{
"name": "Ryan McCue",
"homepage": "https://rmccue.io/"
},
{
"name": "Alain Schlesser",
"homepage": "https://github.com/schlessera"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl"
},
{
"name": "Contributors",
"homepage": "https://github.com/WordPress/Requests/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/WordPress/Requests/issues",
"source": "https://github.com/WordPress/Requests",
"docs": "https://requests.ryanmccue.info/"
},
"require": {
"php": ">=5.6",
"ext-json": "*"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require-dev": {
"requests/test-server": "dev-main",
"squizlabs/php_codesniffer": "^3.6",
"phpcompatibility/php-compatibility": "^9.0",
"wp-coding-standards/wpcs": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"php-parallel-lint/php-console-highlighter": "^0.5.0",
"yoast/phpunit-polyfills": "^1.0.0",
"roave/security-advisories": "dev-latest"
},
"autoload": {
"psr-4": {
"WpOrg\\Requests\\": "src/"
},
"classmap": ["library/Requests.php"],
"files": ["library/Deprecated.php"]
},
"autoload-dev": {
"psr-4": {
"WpOrg\\Requests\\Tests\\": "tests/"
}
},
"scripts": {
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"checkcs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
],
"fixcs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"coverage": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
}
}

View File

@@ -0,0 +1,19 @@
<?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.
*/
if (class_exists('WpOrg\Requests\Autoload') === false) {
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
}
WpOrg\Requests\Autoload::register();

View File

@@ -0,0 +1,6 @@
## The Library directory is deprecated.
The files in this directory are only still in place to provide backward compatibility with Requests 1.x.
Please see the release notes of Requests 2.0.0 on how to upgrade.
This directory will be removed in Requests v 4.0.0.

View File

@@ -0,0 +1,78 @@
<?php
/**
* Requests for PHP
*
* Inspired by Requests for Python.
*
* Based on concepts from SimplePie_File, RequestCore and WP_Http.
*
* @package Requests
*
* @deprecated 2.0.0
*/
/*
* Integrators who cannot yet upgrade to the PSR-4 class names can silence deprecations
* by defining a `REQUESTS_SILENCE_PSR0_DEPRECATIONS` constant and setting it to `true`.
* The constant needs to be defined before this class is required.
*/
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS') || REQUESTS_SILENCE_PSR0_DEPRECATIONS !== true) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error(
'The PSR-0 `Requests_...` class names in the Request library are deprecated.'
. ' Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.',
E_USER_DEPRECATED
);
// Prevent the deprecation notice from being thrown twice.
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
}
}
require_once dirname(__DIR__) . '/src/Requests.php'; // nosemgrep : https://semgrep.dev/s/e5El
/**
* Requests for PHP
*
* Inspired by Requests for Python.
*
* Based on concepts from SimplePie_File, RequestCore and WP_Http.
*
* @package Requests
*
* @deprecated 2.0.0 Use `WpOrg\Requests\Requests` instead for the actual functionality and
* use `WpOrg\Requests\Autoload` for the autoloading.
*/
class Requests extends WpOrg\Requests\Requests {
/**
* Deprecated autoloader for Requests.
*
* @deprecated 2.0.0 Use the `WpOrg\Requests\Autoload::load()` method instead.
*
* @codeCoverageIgnore
*
* @param string $class Class name to load
*/
public static function autoloader($class) {
if (class_exists('WpOrg\Requests\Autoload') === false) {
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
}
return WpOrg\Requests\Autoload::load($class);
}
/**
* Register the built-in autoloader
*
* @deprecated 2.0.0 Include the `WpOrg\Requests\Autoload` class and
* call `WpOrg\Requests\Autoload::register()` instead.
*
* @codeCoverageIgnore
*/
public static function register_autoloader() {
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
WpOrg\Requests\Autoload::register();
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Authentication provider interface
*
* @package Requests\Authentication
*/
namespace WpOrg\Requests;
use WpOrg\Requests\Hooks;
/**
* Authentication provider interface
*
* Implement this interface to act as an authentication provider.
*
* Parameters should be passed via the constructor where possible, as this
* makes it much easier for users to use your provider.
*
* @see \WpOrg\Requests\Hooks
*
* @package Requests\Authentication
*/
interface Auth {
/**
* Register hooks as needed
*
* This method is called in {@see \WpOrg\Requests\Requests::request()} when the user
* has set an instance as the 'auth' option. Use this callback to register all the
* hooks you'll need.
*
* @see \WpOrg\Requests\Hooks::register()
* @param \WpOrg\Requests\Hooks $hooks Hook system
*/
public function register(Hooks $hooks);
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* Basic Authentication provider
*
* @package Requests\Authentication
*/
namespace WpOrg\Requests\Auth;
use WpOrg\Requests\Auth;
use WpOrg\Requests\Exception\ArgumentCount;
use WpOrg\Requests\Exception\InvalidArgument;
use WpOrg\Requests\Hooks;
/**
* Basic Authentication provider
*
* Provides a handler for Basic HTTP authentication via the Authorization
* header.
*
* @package Requests\Authentication
*/
class Basic implements Auth {
/**
* Username
*
* @var string
*/
public $user;
/**
* Password
*
* @var string
*/
public $pass;
/**
* Constructor
*
* @since 2.0 Throws an `InvalidArgument` exception.
* @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception.
*
* @param array|null $args Array of user and password. Must have exactly two elements
*
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null.
* @throws \WpOrg\Requests\Exception\ArgumentCount On incorrect number of array elements (`authbasicbadargs`).
*/
public function __construct($args = null) {
if (is_array($args)) {
if (count($args) !== 2) {
throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs');
}
list($this->user, $this->pass) = $args;
return;
}
if ($args !== null) {
throw InvalidArgument::create(1, '$args', 'array|null', gettype($args));
}
}
/**
* Register the necessary callbacks
*
* @see \WpOrg\Requests\Auth\Basic::curl_before_send()
* @see \WpOrg\Requests\Auth\Basic::fsockopen_header()
* @param \WpOrg\Requests\Hooks $hooks Hook system
*/
public function register(Hooks $hooks) {
$hooks->register('curl.before_send', [$this, 'curl_before_send']);
$hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']);
}
/**
* Set cURL parameters before the data is sent
*
* @param resource|\CurlHandle $handle cURL handle
*/
public function curl_before_send(&$handle) {
curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString());
}
/**
* Add extra headers to the request before sending
*
* @param string $out HTTP header string
*/
public function fsockopen_header(&$out) {
$out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString()));
}
/**
* Get the authentication string (user:pass)
*
* @return string
*/
public function getAuthString() {
return $this->user . ':' . $this->pass;
}
}

View File

@@ -0,0 +1,187 @@
<?php
/**
* Autoloader for Requests for PHP.
*
* Include this file if you'd like to avoid having to create your own autoloader.
*
* @package Requests
* @since 2.0.0
*
* @codeCoverageIgnore
*/
namespace WpOrg\Requests;
/*
* Ensure the autoloader is only declared once.
* This safeguard is in place as this is the typical entry point for this library
* and this file being required unconditionally could easily cause
* fatal "Class already declared" errors.
*/
if (class_exists('WpOrg\Requests\Autoload') === false) {
/**
* Autoloader for Requests for PHP.
*
* This autoloader supports the PSR-4 based Requests 2.0.0 classes in a case-sensitive manner
* as the most common server OS-es are case-sensitive and the file names are in mixed case.
*
* For the PSR-0 Requests 1.x BC-layer, requested classes will be treated case-insensitively.
*
* @package Requests
*/
final class Autoload {
/**
* List of the old PSR-0 class names in lowercase as keys with their PSR-4 case-sensitive name as a value.
*
* @var array
*/
private static $deprecated_classes = [
// Interfaces.
'requests_auth' => '\WpOrg\Requests\Auth',
'requests_hooker' => '\WpOrg\Requests\HookManager',
'requests_proxy' => '\WpOrg\Requests\Proxy',
'requests_transport' => '\WpOrg\Requests\Transport',
// Classes.
'requests_cookie' => '\WpOrg\Requests\Cookie',
'requests_exception' => '\WpOrg\Requests\Exception',
'requests_hooks' => '\WpOrg\Requests\Hooks',
'requests_idnaencoder' => '\WpOrg\Requests\IdnaEncoder',
'requests_ipv6' => '\WpOrg\Requests\Ipv6',
'requests_iri' => '\WpOrg\Requests\Iri',
'requests_response' => '\WpOrg\Requests\Response',
'requests_session' => '\WpOrg\Requests\Session',
'requests_ssl' => '\WpOrg\Requests\Ssl',
'requests_auth_basic' => '\WpOrg\Requests\Auth\Basic',
'requests_cookie_jar' => '\WpOrg\Requests\Cookie\Jar',
'requests_proxy_http' => '\WpOrg\Requests\Proxy\Http',
'requests_response_headers' => '\WpOrg\Requests\Response\Headers',
'requests_transport_curl' => '\WpOrg\Requests\Transport\Curl',
'requests_transport_fsockopen' => '\WpOrg\Requests\Transport\Fsockopen',
'requests_utility_caseinsensitivedictionary' => '\WpOrg\Requests\Utility\CaseInsensitiveDictionary',
'requests_utility_filterediterator' => '\WpOrg\Requests\Utility\FilteredIterator',
'requests_exception_http' => '\WpOrg\Requests\Exception\Http',
'requests_exception_transport' => '\WpOrg\Requests\Exception\Transport',
'requests_exception_transport_curl' => '\WpOrg\Requests\Exception\Transport\Curl',
'requests_exception_http_304' => '\WpOrg\Requests\Exception\Http\Status304',
'requests_exception_http_305' => '\WpOrg\Requests\Exception\Http\Status305',
'requests_exception_http_306' => '\WpOrg\Requests\Exception\Http\Status306',
'requests_exception_http_400' => '\WpOrg\Requests\Exception\Http\Status400',
'requests_exception_http_401' => '\WpOrg\Requests\Exception\Http\Status401',
'requests_exception_http_402' => '\WpOrg\Requests\Exception\Http\Status402',
'requests_exception_http_403' => '\WpOrg\Requests\Exception\Http\Status403',
'requests_exception_http_404' => '\WpOrg\Requests\Exception\Http\Status404',
'requests_exception_http_405' => '\WpOrg\Requests\Exception\Http\Status405',
'requests_exception_http_406' => '\WpOrg\Requests\Exception\Http\Status406',
'requests_exception_http_407' => '\WpOrg\Requests\Exception\Http\Status407',
'requests_exception_http_408' => '\WpOrg\Requests\Exception\Http\Status408',
'requests_exception_http_409' => '\WpOrg\Requests\Exception\Http\Status409',
'requests_exception_http_410' => '\WpOrg\Requests\Exception\Http\Status410',
'requests_exception_http_411' => '\WpOrg\Requests\Exception\Http\Status411',
'requests_exception_http_412' => '\WpOrg\Requests\Exception\Http\Status412',
'requests_exception_http_413' => '\WpOrg\Requests\Exception\Http\Status413',
'requests_exception_http_414' => '\WpOrg\Requests\Exception\Http\Status414',
'requests_exception_http_415' => '\WpOrg\Requests\Exception\Http\Status415',
'requests_exception_http_416' => '\WpOrg\Requests\Exception\Http\Status416',
'requests_exception_http_417' => '\WpOrg\Requests\Exception\Http\Status417',
'requests_exception_http_418' => '\WpOrg\Requests\Exception\Http\Status418',
'requests_exception_http_428' => '\WpOrg\Requests\Exception\Http\Status428',
'requests_exception_http_429' => '\WpOrg\Requests\Exception\Http\Status429',
'requests_exception_http_431' => '\WpOrg\Requests\Exception\Http\Status431',
'requests_exception_http_500' => '\WpOrg\Requests\Exception\Http\Status500',
'requests_exception_http_501' => '\WpOrg\Requests\Exception\Http\Status501',
'requests_exception_http_502' => '\WpOrg\Requests\Exception\Http\Status502',
'requests_exception_http_503' => '\WpOrg\Requests\Exception\Http\Status503',
'requests_exception_http_504' => '\WpOrg\Requests\Exception\Http\Status504',
'requests_exception_http_505' => '\WpOrg\Requests\Exception\Http\Status505',
'requests_exception_http_511' => '\WpOrg\Requests\Exception\Http\Status511',
'requests_exception_http_unknown' => '\WpOrg\Requests\Exception\Http\StatusUnknown',
];
/**
* Register the autoloader.
*
* Note: the autoloader is *prepended* in the autoload queue.
* This is done to ensure that the Requests 2.0 autoloader takes precedence
* over a potentially (dependency-registered) Requests 1.x autoloader.
*
* @internal This method contains a safeguard against the autoloader being
* registered multiple times. This safeguard uses a global constant to
* (hopefully/in most cases) still function correctly, even if the
* class would be renamed.
*
* @return void
*/
public static function register() {
if (defined('REQUESTS_AUTOLOAD_REGISTERED') === false) {
spl_autoload_register([self::class, 'load'], true);
define('REQUESTS_AUTOLOAD_REGISTERED', true);
}
}
/**
* Autoloader.
*
* @param string $class_name Name of the class name to load.
*
* @return bool Whether a class was loaded or not.
*/
public static function load($class_name) {
// Check that the class starts with "Requests" (PSR-0) or "WpOrg\Requests" (PSR-4).
$psr_4_prefix_pos = strpos($class_name, 'WpOrg\\Requests\\');
if (stripos($class_name, 'Requests') !== 0 && $psr_4_prefix_pos !== 0) {
return false;
}
$class_lower = strtolower($class_name);
if ($class_lower === 'requests') {
// Reference to the original PSR-0 Requests class.
$file = dirname(__DIR__) . '/library/Requests.php';
} elseif ($psr_4_prefix_pos === 0) {
// PSR-4 classname.
$file = __DIR__ . '/' . strtr(substr($class_name, 15), '\\', '/') . '.php';
}
if (isset($file) && file_exists($file)) {
include $file; // nosemgrep : https://semgrep.dev/s/e5El
return true;
}
/*
* Okay, so the class starts with "Requests", but we couldn't find the file.
* If this is one of the deprecated/renamed PSR-0 classes being requested,
* let's alias it to the new name and throw a deprecation notice.
*/
if (isset(self::$deprecated_classes[$class_lower])) {
/*
* Integrators who cannot yet upgrade to the PSR-4 class names can silence deprecations
* by defining a `REQUESTS_SILENCE_PSR0_DEPRECATIONS` constant and setting it to `true`.
* The constant needs to be defined before the first deprecated class is requested
* via this autoloader.
*/
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS') || REQUESTS_SILENCE_PSR0_DEPRECATIONS !== true) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error(
'The PSR-0 `Requests_...` class names in the Request library are deprecated.'
. ' Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.',
E_USER_DEPRECATED
);
// Prevent the deprecation notice from being thrown twice.
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
}
}
// Create an alias and let the autoloader recursively kick in to load the PSR-4 class.
return class_alias(self::$deprecated_classes[$class_lower], $class_name, true);
}
return false;
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Capability interface declaring the known capabilities.
*
* @package Requests\Utilities
*/
namespace WpOrg\Requests;
/**
* Capability interface declaring the known capabilities.
*
* This is used as the authoritative source for which capabilities can be queried.
*
* @package Requests\Utilities
*/
interface Capability {
/**
* Support for SSL.
*
* @var string
*/
const SSL = 'ssl';
/**
* Collection of all capabilities supported in Requests.
*
* Note: this does not automatically mean that the capability will be supported for your chosen transport!
*
* @var array<string>
*/
const ALL = [
self::SSL,
];
}

View File

@@ -0,0 +1,522 @@
<?php
/**
* Cookie storage object
*
* @package Requests\Cookies
*/
namespace WpOrg\Requests;
use WpOrg\Requests\Exception\InvalidArgument;
use WpOrg\Requests\Iri;
use WpOrg\Requests\Response\Headers;
use WpOrg\Requests\Utility\CaseInsensitiveDictionary;
use WpOrg\Requests\Utility\InputValidator;
/**
* Cookie storage object
*
* @package Requests\Cookies
*/
class Cookie {
/**
* Cookie name.
*
* @var string
*/
public $name;
/**
* Cookie value.
*
* @var string
*/
public $value;
/**
* Cookie attributes
*
* Valid keys are (currently) path, domain, expires, max-age, secure and
* httponly.
*
* @var \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array Array-like object
*/
public $attributes = [];
/**
* Cookie flags
*
* Valid keys are (currently) creation, last-access, persistent and
* host-only.
*
* @var array
*/
public $flags = [];
/**
* Reference time for relative calculations
*
* This is used in place of `time()` when calculating Max-Age expiration and
* checking time validity.
*
* @var int
*/
public $reference_time = 0;
/**
* Create a new cookie object
*
* @param string $name
* @param string $value
* @param array|\WpOrg\Requests\Utility\CaseInsensitiveDictionary $attributes Associative array of attribute data
* @param array $flags
* @param int|null $reference_time
*
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $name argument is not a string.
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $value argument is not a string.
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $attributes argument is not an array or iterable object with array access.
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $flags argument is not an array.
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $reference_time argument is not an integer or null.
*/
public function __construct($name, $value, $attributes = [], $flags = [], $reference_time = null) {
if (is_string($name) === false) {
throw InvalidArgument::create(1, '$name', 'string', gettype($name));
}
if (is_string($value) === false) {
throw InvalidArgument::create(2, '$value', 'string', gettype($value));
}
if (InputValidator::has_array_access($attributes) === false || InputValidator::is_iterable($attributes) === false) {
throw InvalidArgument::create(3, '$attributes', 'array|ArrayAccess&Traversable', gettype($attributes));
}
if (is_array($flags) === false) {
throw InvalidArgument::create(4, '$flags', 'array', gettype($flags));
}
if ($reference_time !== null && is_int($reference_time) === false) {
throw InvalidArgument::create(5, '$reference_time', 'integer|null', gettype($reference_time));
}
$this->name = $name;
$this->value = $value;
$this->attributes = $attributes;
$default_flags = [
'creation' => time(),
'last-access' => time(),
'persistent' => false,
'host-only' => true,
];
$this->flags = array_merge($default_flags, $flags);
$this->reference_time = time();
if ($reference_time !== null) {
$this->reference_time = $reference_time;
}
$this->normalize();
}
/**
* Get the cookie value
*
* Attributes and other data can be accessed via methods.
*/
public function __toString() {
return $this->value;
}
/**
* Check if a cookie is expired.
*
* Checks the age against $this->reference_time to determine if the cookie
* is expired.
*
* @return boolean True if expired, false if time is valid.
*/
public function is_expired() {
// RFC6265, s. 4.1.2.2:
// If a cookie has both the Max-Age and the Expires attribute, the Max-
// Age attribute has precedence and controls the expiration date of the
// cookie.
if (isset($this->attributes['max-age'])) {
$max_age = $this->attributes['max-age'];
return $max_age < $this->reference_time;
}
if (isset($this->attributes['expires'])) {
$expires = $this->attributes['expires'];
return $expires < $this->reference_time;
}
return false;
}
/**
* Check if a cookie is valid for a given URI
*
* @param \WpOrg\Requests\Iri $uri URI to check
* @return boolean Whether the cookie is valid for the given URI
*/
public function uri_matches(Iri $uri) {
if (!$this->domain_matches($uri->host)) {
return false;
}
if (!$this->path_matches($uri->path)) {
return false;
}
return empty($this->attributes['secure']) || $uri->scheme === 'https';
}
/**
* Check if a cookie is valid for a given domain
*
* @param string $domain Domain to check
* @return boolean Whether the cookie is valid for the given domain
*/
public function domain_matches($domain) {
if (is_string($domain) === false) {
return false;
}
if (!isset($this->attributes['domain'])) {
// Cookies created manually; cookies created by Requests will set
// the domain to the requested domain
return true;
}
$cookie_domain = $this->attributes['domain'];
if ($cookie_domain === $domain) {
// The cookie domain and the passed domain are identical.
return true;
}
// If the cookie is marked as host-only and we don't have an exact
// match, reject the cookie
if ($this->flags['host-only'] === true) {
return false;
}
if (strlen($domain) <= strlen($cookie_domain)) {
// For obvious reasons, the cookie domain cannot be a suffix if the passed domain
// is shorter than the cookie domain
return false;
}
if (substr($domain, -1 * strlen($cookie_domain)) !== $cookie_domain) {
// The cookie domain should be a suffix of the passed domain.
return false;
}
$prefix = substr($domain, 0, strlen($domain) - strlen($cookie_domain));
if (substr($prefix, -1) !== '.') {
// The last character of the passed domain that is not included in the
// domain string should be a %x2E (".") character.
return false;
}
// The passed domain should be a host name (i.e., not an IP address).
return !preg_match('#^(.+\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $domain);
}
/**
* Check if a cookie is valid for a given path
*
* From the path-match check in RFC 6265 section 5.1.4
*
* @param string $request_path Path to check
* @return boolean Whether the cookie is valid for the given path
*/
public function path_matches($request_path) {
if (empty($request_path)) {
// Normalize empty path to root
$request_path = '/';
}
if (!isset($this->attributes['path'])) {
// Cookies created manually; cookies created by Requests will set
// the path to the requested path
return true;
}
if (is_scalar($request_path) === false) {
return false;
}
$cookie_path = $this->attributes['path'];
if ($cookie_path === $request_path) {
// The cookie-path and the request-path are identical.
return true;
}
if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) {
if (substr($cookie_path, -1) === '/') {
// The cookie-path is a prefix of the request-path, and the last
// character of the cookie-path is %x2F ("/").
return true;
}
if (substr($request_path, strlen($cookie_path), 1) === '/') {
// The cookie-path is a prefix of the request-path, and the
// first character of the request-path that is not included in
// the cookie-path is a %x2F ("/") character.
return true;
}
}
return false;
}
/**
* Normalize cookie and attributes
*
* @return boolean Whether the cookie was successfully normalized
*/
public function normalize() {
foreach ($this->attributes as $key => $value) {
$orig_value = $value;
$value = $this->normalize_attribute($key, $value);
if ($value === null) {
unset($this->attributes[$key]);
continue;
}
if ($value !== $orig_value) {
$this->attributes[$key] = $value;
}
}
return true;
}
/**
* Parse an individual cookie attribute
*
* Handles parsing individual attributes from the cookie values.
*
* @param string $name Attribute name
* @param string|boolean $value Attribute value (string value, or true if empty/flag)
* @return mixed Value if available, or null if the attribute value is invalid (and should be skipped)
*/
protected function normalize_attribute($name, $value) {
switch (strtolower($name)) {
case 'expires':
// Expiration parsing, as per RFC 6265 section 5.2.1
if (is_int($value)) {
return $value;
}
$expiry_time = strtotime($value);
if ($expiry_time === false) {
return null;
}
return $expiry_time;
case 'max-age':
// Expiration parsing, as per RFC 6265 section 5.2.2
if (is_int($value)) {
return $value;
}
// Check that we have a valid age
if (!preg_match('/^-?\d+$/', $value)) {
return null;
}
$delta_seconds = (int) $value;
if ($delta_seconds <= 0) {
$expiry_time = 0;
} else {
$expiry_time = $this->reference_time + $delta_seconds;
}
return $expiry_time;
case 'domain':
// Domains are not required as per RFC 6265 section 5.2.3
if (empty($value)) {
return null;
}
// Domain normalization, as per RFC 6265 section 5.2.3
if ($value[0] === '.') {
$value = substr($value, 1);
}
return $value;
default:
return $value;
}
}
/**
* Format a cookie for a Cookie header
*
* This is used when sending cookies to a server.
*
* @return string Cookie formatted for Cookie header
*/
public function format_for_header() {
return sprintf('%s=%s', $this->name, $this->value);
}
/**
* Format a cookie for a Set-Cookie header
*
* This is used when sending cookies to clients. This isn't really
* applicable to client-side usage, but might be handy for debugging.
*
* @return string Cookie formatted for Set-Cookie header
*/
public function format_for_set_cookie() {
$header_value = $this->format_for_header();
if (!empty($this->attributes)) {
$parts = [];
foreach ($this->attributes as $key => $value) {
// Ignore non-associative attributes
if (is_numeric($key)) {
$parts[] = $value;
} else {
$parts[] = sprintf('%s=%s', $key, $value);
}
}
$header_value .= '; ' . implode('; ', $parts);
}
return $header_value;
}
/**
* Parse a cookie string into a cookie object
*
* Based on Mozilla's parsing code in Firefox and related projects, which
* is an intentional deviation from RFC 2109 and RFC 2616. RFC 6265
* specifies some of this handling, but not in a thorough manner.
*
* @param string $cookie_header Cookie header value (from a Set-Cookie header)
* @param string $name
* @param int|null $reference_time
* @return \WpOrg\Requests\Cookie Parsed cookie object
*
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $cookie_header argument is not a string.
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $name argument is not a string.
*/
public static function parse($cookie_header, $name = '', $reference_time = null) {
if (is_string($cookie_header) === false) {
throw InvalidArgument::create(1, '$cookie_header', 'string', gettype($cookie_header));
}
if (is_string($name) === false) {
throw InvalidArgument::create(2, '$name', 'string', gettype($name));
}
$parts = explode(';', $cookie_header);
$kvparts = array_shift($parts);
if (!empty($name)) {
$value = $cookie_header;
} elseif (strpos($kvparts, '=') === false) {
// Some sites might only have a value without the equals separator.
// Deviate from RFC 6265 and pretend it was actually a blank name
// (`=foo`)
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=169091
$name = '';
$value = $kvparts;
} else {
list($name, $value) = explode('=', $kvparts, 2);
}
$name = trim($name);
$value = trim($value);
// Attribute keys are handled case-insensitively
$attributes = new CaseInsensitiveDictionary();
if (!empty($parts)) {
foreach ($parts as $part) {
if (strpos($part, '=') === false) {
$part_key = $part;
$part_value = true;
} else {
list($part_key, $part_value) = explode('=', $part, 2);
$part_value = trim($part_value);
}
$part_key = trim($part_key);
$attributes[$part_key] = $part_value;
}
}
return new static($name, $value, $attributes, [], $reference_time);
}
/**
* Parse all Set-Cookie headers from request headers
*
* @param \WpOrg\Requests\Response\Headers $headers Headers to parse from
* @param \WpOrg\Requests\Iri|null $origin URI for comparing cookie origins
* @param int|null $time Reference time for expiration calculation
* @return array
*/
public static function parse_from_headers(Headers $headers, Iri $origin = null, $time = null) {
$cookie_headers = $headers->getValues('Set-Cookie');
if (empty($cookie_headers)) {
return [];
}
$cookies = [];
foreach ($cookie_headers as $header) {
$parsed = self::parse($header, '', $time);
// Default domain/path attributes
if (empty($parsed->attributes['domain']) && !empty($origin)) {
$parsed->attributes['domain'] = $origin->host;
$parsed->flags['host-only'] = true;
} else {
$parsed->flags['host-only'] = false;
}
$path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/');
if (!$path_is_valid && !empty($origin)) {
$path = $origin->path;
// Default path normalization as per RFC 6265 section 5.1.4
if (substr($path, 0, 1) !== '/') {
// If the uri-path is empty or if the first character of
// the uri-path is not a %x2F ("/") character, output
// %x2F ("/") and skip the remaining steps.
$path = '/';
} elseif (substr_count($path, '/') === 1) {
// If the uri-path contains no more than one %x2F ("/")
// character, output %x2F ("/") and skip the remaining
// step.
$path = '/';
} else {
// Output the characters of the uri-path from the first
// character up to, but not including, the right-most
// %x2F ("/").
$path = substr($path, 0, strrpos($path, '/'));
}
$parsed->attributes['path'] = $path;
}
// Reject invalid cookie domains
if (!empty($origin) && !$parsed->domain_matches($origin->host)) {
continue;
}
$cookies[$parsed->name] = $parsed;
}
return $cookies;
}
}

View File

@@ -0,0 +1,186 @@
<?php
/**
* Cookie holder object
*
* @package Requests\Cookies
*/
namespace WpOrg\Requests\Cookie;
use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
use ReturnTypeWillChange;
use WpOrg\Requests\Cookie;
use WpOrg\Requests\Exception;
use WpOrg\Requests\Exception\InvalidArgument;
use WpOrg\Requests\HookManager;
use WpOrg\Requests\Iri;
use WpOrg\Requests\Response;
/**
* Cookie holder object
*
* @package Requests\Cookies
*/
class Jar implements ArrayAccess, IteratorAggregate {
/**
* Actual item data
*
* @var array
*/
protected $cookies = [];
/**
* Create a new jar
*
* @param array $cookies Existing cookie values
*
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array.
*/
public function __construct($cookies = []) {
if (is_array($cookies) === false) {
throw InvalidArgument::create(1, '$cookies', 'array', gettype($cookies));
}
$this->cookies = $cookies;
}
/**
* Normalise cookie data into a \WpOrg\Requests\Cookie
*
* @param string|\WpOrg\Requests\Cookie $cookie
* @return \WpOrg\Requests\Cookie
*/
public function normalize_cookie($cookie, $key = '') {
if ($cookie instanceof Cookie) {
return $cookie;
}
return Cookie::parse($cookie, $key);
}
/**
* Check if the given item exists
*
* @param string $offset Item key
* @return boolean Does the item exist?
*/
#[ReturnTypeWillChange]
public function offsetExists($offset) {
return isset($this->cookies[$offset]);
}
/**
* Get the value for the item
*
* @param string $offset Item key
* @return string|null Item value (null if offsetExists is false)
*/
#[ReturnTypeWillChange]
public function offsetGet($offset) {
if (!isset($this->cookies[$offset])) {
return null;
}
return $this->cookies[$offset];
}
/**
* Set the given item
*
* @param string $offset Item name
* @param string $value Item value
*
* @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
*/
#[ReturnTypeWillChange]
public function offsetSet($offset, $value) {
if ($offset === null) {
throw new Exception('Object is a dictionary, not a list', 'invalidset');
}
$this->cookies[$offset] = $value;
}
/**
* Unset the given header
*
* @param string $offset
*/
#[ReturnTypeWillChange]
public function offsetUnset($offset) {
unset($this->cookies[$offset]);
}
/**
* Get an iterator for the data
*
* @return \ArrayIterator
*/
#[ReturnTypeWillChange]
public function getIterator() {
return new ArrayIterator($this->cookies);
}
/**
* Register the cookie handler with the request's hooking system
*
* @param \WpOrg\Requests\HookManager $hooks Hooking system
*/
public function register(HookManager $hooks) {
$hooks->register('requests.before_request', [$this, 'before_request']);
$hooks->register('requests.before_redirect_check', [$this, 'before_redirect_check']);
}
/**
* Add Cookie header to a request if we have any
*
* As per RFC 6265, cookies are separated by '; '
*
* @param string $url
* @param array $headers
* @param array $data
* @param string $type
* @param array $options
*/
public function before_request($url, &$headers, &$data, &$type, &$options) {
if (!$url instanceof Iri) {
$url = new Iri($url);
}
if (!empty($this->cookies)) {
$cookies = [];
foreach ($this->cookies as $key => $cookie) {
$cookie = $this->normalize_cookie($cookie, $key);
// Skip expired cookies
if ($cookie->is_expired()) {
continue;
}
if ($cookie->domain_matches($url->host)) {
$cookies[] = $cookie->format_for_header();
}
}
$headers['Cookie'] = implode('; ', $cookies);
}
}
/**
* Parse all cookies from a response and attach them to the response
*
* @param \WpOrg\Requests\Response $response
*/
public function before_redirect_check(Response $response) {
$url = $response->url;
if (!$url instanceof Iri) {
$url = new Iri($url);
}
$cookies = Cookie::parse_from_headers($response->headers, $url);
$this->cookies = array_merge($this->cookies, $cookies);
$response->cookies = $this;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* Exception for HTTP requests
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests;
use Exception as PHPException;
/**
* Exception for HTTP requests
*
* @package Requests\Exceptions
*/
class Exception extends PHPException {
/**
* Type of exception
*
* @var string
*/
protected $type;
/**
* Data associated with the exception
*
* @var mixed
*/
protected $data;
/**
* Create a new exception
*
* @param string $message Exception message
* @param string $type Exception type
* @param mixed $data Associated data
* @param integer $code Exception numerical code, if applicable
*/
public function __construct($message, $type, $data = null, $code = 0) {
parent::__construct($message, $code);
$this->type = $type;
$this->data = $data;
}
/**
* Like {@see \Exception::getCode()}, but a string code.
*
* @codeCoverageIgnore
* @return string
*/
public function getType() {
return $this->type;
}
/**
* Gives any relevant data
*
* @codeCoverageIgnore
* @return mixed
*/
public function getData() {
return $this->data;
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace WpOrg\Requests\Exception;
use WpOrg\Requests\Exception;
/**
* Exception for when an incorrect number of arguments are passed to a method.
*
* Typically, this exception is used when all arguments for a method are optional,
* but certain arguments need to be passed together, i.e. a method which can be called
* with no arguments or with two arguments, but not with one argument.
*
* Along the same lines, this exception is also used if a method expects an array
* with a certain number of elements and the provided number of elements does not comply.
*
* @package Requests\Exceptions
* @since 2.0.0
*/
final class ArgumentCount extends Exception {
/**
* Create a new argument count exception with a standardized text.
*
* @param string $expected The argument count expected as a phrase.
* For example: `at least 2 arguments` or `exactly 1 argument`.
* @param int $received The actual argument count received.
* @param string $type Exception type.
*
* @return \WpOrg\Requests\Exception\ArgumentCount
*/
public static function create($expected, $received, $type) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
return new self(
sprintf(
'%s::%s() expects %s, %d given',
$stack[1]['class'],
$stack[1]['function'],
$expected,
$received
),
$type
);
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* Exception based on HTTP response
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception;
use WpOrg\Requests\Exception;
use WpOrg\Requests\Exception\Http\StatusUnknown;
/**
* Exception based on HTTP response
*
* @package Requests\Exceptions
*/
class Http extends Exception {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 0;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Unknown';
/**
* Create a new exception
*
* There is no mechanism to pass in the status code, as this is set by the
* subclass used. Reason phrases can vary, however.
*
* @param string|null $reason Reason phrase
* @param mixed $data Associated data
*/
public function __construct($reason = null, $data = null) {
if ($reason !== null) {
$this->reason = $reason;
}
$message = sprintf('%d %s', $this->code, $this->reason);
parent::__construct($message, 'httpresponse', $data, $this->code);
}
/**
* Get the status message.
*
* @return string
*/
public function getReason() {
return $this->reason;
}
/**
* Get the correct exception class for a given error code
*
* @param int|bool $code HTTP status code, or false if unavailable
* @return string Exception class name to use
*/
public static function get_class($code) {
if (!$code) {
return StatusUnknown::class;
}
$class = sprintf('\WpOrg\Requests\Exception\Http\Status%d', $code);
if (class_exists($class)) {
return $class;
}
return StatusUnknown::class;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 304 Not Modified responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 304 Not Modified responses
*
* @package Requests\Exceptions
*/
final class Status304 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 304;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Not Modified';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 305 Use Proxy responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 305 Use Proxy responses
*
* @package Requests\Exceptions
*/
final class Status305 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 305;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Use Proxy';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 306 Switch Proxy responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 306 Switch Proxy responses
*
* @package Requests\Exceptions
*/
final class Status306 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 306;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Switch Proxy';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 400 Bad Request responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 400 Bad Request responses
*
* @package Requests\Exceptions
*/
final class Status400 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 400;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Bad Request';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 401 Unauthorized responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 401 Unauthorized responses
*
* @package Requests\Exceptions
*/
final class Status401 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 401;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Unauthorized';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 402 Payment Required responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 402 Payment Required responses
*
* @package Requests\Exceptions
*/
final class Status402 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 402;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Payment Required';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 403 Forbidden responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 403 Forbidden responses
*
* @package Requests\Exceptions
*/
final class Status403 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 403;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Forbidden';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 404 Not Found responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 404 Not Found responses
*
* @package Requests\Exceptions
*/
final class Status404 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 404;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Not Found';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 405 Method Not Allowed responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 405 Method Not Allowed responses
*
* @package Requests\Exceptions
*/
final class Status405 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 405;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Method Not Allowed';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 406 Not Acceptable responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 406 Not Acceptable responses
*
* @package Requests\Exceptions
*/
final class Status406 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 406;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Not Acceptable';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 407 Proxy Authentication Required responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 407 Proxy Authentication Required responses
*
* @package Requests\Exceptions
*/
final class Status407 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 407;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Proxy Authentication Required';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 408 Request Timeout responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 408 Request Timeout responses
*
* @package Requests\Exceptions
*/
final class Status408 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 408;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Request Timeout';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 409 Conflict responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 409 Conflict responses
*
* @package Requests\Exceptions
*/
final class Status409 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 409;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Conflict';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 410 Gone responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 410 Gone responses
*
* @package Requests\Exceptions
*/
final class Status410 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 410;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Gone';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 411 Length Required responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 411 Length Required responses
*
* @package Requests\Exceptions
*/
final class Status411 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 411;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Length Required';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 412 Precondition Failed responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 412 Precondition Failed responses
*
* @package Requests\Exceptions
*/
final class Status412 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 412;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Precondition Failed';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 413 Request Entity Too Large responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 413 Request Entity Too Large responses
*
* @package Requests\Exceptions
*/
final class Status413 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 413;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Request Entity Too Large';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 414 Request-URI Too Large responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 414 Request-URI Too Large responses
*
* @package Requests\Exceptions
*/
final class Status414 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 414;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Request-URI Too Large';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 415 Unsupported Media Type responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 415 Unsupported Media Type responses
*
* @package Requests\Exceptions
*/
final class Status415 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 415;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Unsupported Media Type';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 416 Requested Range Not Satisfiable responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 416 Requested Range Not Satisfiable responses
*
* @package Requests\Exceptions
*/
final class Status416 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 416;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Requested Range Not Satisfiable';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 417 Expectation Failed responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 417 Expectation Failed responses
*
* @package Requests\Exceptions
*/
final class Status417 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 417;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Expectation Failed';
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Exception for 418 I'm A Teapot responses
*
* @link https://tools.ietf.org/html/rfc2324
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 418 I'm A Teapot responses
*
* @link https://tools.ietf.org/html/rfc2324
*
* @package Requests\Exceptions
*/
final class Status418 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 418;
/**
* Reason phrase
*
* @var string
*/
protected $reason = "I'm A Teapot";
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Exception for 428 Precondition Required responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 428 Precondition Required responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
final class Status428 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 428;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Precondition Required';
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Exception for 429 Too Many Requests responses
*
* @link https://tools.ietf.org/html/draft-nottingham-http-new-status-04
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 429 Too Many Requests responses
*
* @link https://tools.ietf.org/html/draft-nottingham-http-new-status-04
*
* @package Requests\Exceptions
*/
final class Status429 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 429;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Too Many Requests';
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Exception for 431 Request Header Fields Too Large responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 431 Request Header Fields Too Large responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
final class Status431 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 431;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Request Header Fields Too Large';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 500 Internal Server Error responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 500 Internal Server Error responses
*
* @package Requests\Exceptions
*/
final class Status500 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 500;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Internal Server Error';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 501 Not Implemented responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 501 Not Implemented responses
*
* @package Requests\Exceptions
*/
final class Status501 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 501;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Not Implemented';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 502 Bad Gateway responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 502 Bad Gateway responses
*
* @package Requests\Exceptions
*/
final class Status502 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 502;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Bad Gateway';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 503 Service Unavailable responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 503 Service Unavailable responses
*
* @package Requests\Exceptions
*/
final class Status503 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 503;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Service Unavailable';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 504 Gateway Timeout responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 504 Gateway Timeout responses
*
* @package Requests\Exceptions
*/
final class Status504 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 504;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Gateway Timeout';
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Exception for 505 HTTP Version Not Supported responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 505 HTTP Version Not Supported responses
*
* @package Requests\Exceptions
*/
final class Status505 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 505;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'HTTP Version Not Supported';
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Exception for 511 Network Authentication Required responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
/**
* Exception for 511 Network Authentication Required responses
*
* @link https://tools.ietf.org/html/rfc6585
*
* @package Requests\Exceptions
*/
final class Status511 extends Http {
/**
* HTTP status code
*
* @var integer
*/
protected $code = 511;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Network Authentication Required';
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* Exception for unknown status responses
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Response;
/**
* Exception for unknown status responses
*
* @package Requests\Exceptions
*/
final class StatusUnknown extends Http {
/**
* HTTP status code
*
* @var integer|bool Code if available, false if an error occurred
*/
protected $code = 0;
/**
* Reason phrase
*
* @var string
*/
protected $reason = 'Unknown';
/**
* Create a new exception
*
* If `$data` is an instance of {@see \WpOrg\Requests\Response}, uses the status
* code from it. Otherwise, sets as 0
*
* @param string|null $reason Reason phrase
* @param mixed $data Associated data
*/
public function __construct($reason = null, $data = null) {
if ($data instanceof Response) {
$this->code = (int) $data->status_code;
}
parent::__construct($reason, $data);
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace WpOrg\Requests\Exception;
use InvalidArgumentException;
/**
* Exception for an invalid argument passed.
*
* @package Requests\Exceptions
* @since 2.0.0
*/
final class InvalidArgument extends InvalidArgumentException {
/**
* Create a new invalid argument exception with a standardized text.
*
* @param int $position The argument position in the function signature. 1-based.
* @param string $name The argument name in the function signature.
* @param string $expected The argument type expected as a string.
* @param string $received The actual argument type received.
*
* @return \WpOrg\Requests\Exception\InvalidArgument
*/
public static function create($position, $name, $expected, $received) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
return new self(
sprintf(
'%s::%s(): Argument #%d (%s) must be of type %s, %s given',
$stack[1]['class'],
$stack[1]['function'],
$position,
$name,
$expected,
$received
)
);
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* Transport Exception
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception;
use WpOrg\Requests\Exception;
/**
* Transport Exception
*
* @package Requests\Exceptions
*/
class Transport extends Exception {}

View File

@@ -0,0 +1,80 @@
<?php
/**
* CURL Transport Exception.
*
* @package Requests\Exceptions
*/
namespace WpOrg\Requests\Exception\Transport;
use WpOrg\Requests\Exception\Transport;
/**
* CURL Transport Exception.
*
* @package Requests\Exceptions
*/
final class Curl extends Transport {
const EASY = 'cURLEasy';
const MULTI = 'cURLMulti';
const SHARE = 'cURLShare';
/**
* cURL error code
*
* @var integer
*/
protected $code = -1;
/**
* Which type of cURL error
*
* EASY|MULTI|SHARE
*
* @var string
*/
protected $type = 'Unknown';
/**
* Clear text error message
*
* @var string
*/
protected $reason = 'Unknown';
/**
* Create a new exception.
*
* @param string $message Exception message.
* @param string $type Exception type.
* @param mixed $data Associated data, if applicable.
* @param int $code Exception numerical code, if applicable.
*/
public function __construct($message, $type, $data = null, $code = 0) {
if ($type !== null) {
$this->type = $type;
}
if ($code !== null) {
$this->code = (int) $code;
}
if ($message !== null) {
$this->reason = $message;
}
$message = sprintf('%d %s', $this->code, $this->reason);
parent::__construct($message, $this->type, $data, $this->code);
}
/**
* Get the error message.
*
* @return string
*/
public function getReason() {
return $this->reason;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Event dispatcher
*
* @package Requests\EventDispatcher
*/
namespace WpOrg\Requests;
/**
* Event dispatcher
*
* @package Requests\EventDispatcher
*/
interface HookManager {
/**
* Register a callback for a hook
*
* @param string $hook Hook name
* @param callable $callback Function/method to call on event
* @param int $priority Priority number. <0 is executed earlier, >0 is executed later
*/
public function register($hook, $callback, $priority = 0);
/**
* Dispatch a message
*
* @param string $hook Hook name
* @param array $parameters Parameters to pass to callbacks
* @return boolean Successfulness
*/
public function dispatch($hook, $parameters = []);
}

Some files were not shown because too many files have changed in this diff Show More