diff --git a/README.txt b/README.txt index 1e09ed5..0194bea 100644 --- a/README.txt +++ b/README.txt @@ -2,8 +2,8 @@ Contributors: razorpay Tags: razorpay, payments, india, quick, simple Requires at least: 3.0.1 -Tested up to: 4.8.1 -Stable tag: 1.0.1 +Tested up to: 5.3.2 +Stable tag: 1.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -33,4 +33,11 @@ For this plugin to work correctly, please mention the following items as page me 1. 'name' of the product. 2. 'description' of the product. -3. 'amount' in paise, with a minimum of 1 rupee. \ No newline at end of file +3. 'amount' with a minimum of 1 rupee. + +== Changelog == + += 1.1.0 = +* Added metadata information. +* Updates Razorpay SDK +* Tested upto WordPress 5.3.2 \ No newline at end of file diff --git a/razorpay-php/README.md b/razorpay-php/README.md index 28f18f8..f0f415a 100644 --- a/razorpay-php/README.md +++ b/razorpay-php/README.md @@ -2,32 +2,26 @@ [![Build Status](https://travis-ci.org/razorpay/razorpay-php.svg?branch=master)](https://travis-ci.org/razorpay/razorpay-php) [![Latest Stable Version](https://poser.pugx.org/razorpay/razorpay/v/stable.svg)](https://packagist.org/packages/razorpay/razorpay) [![License](https://poser.pugx.org/razorpay/razorpay/license.svg)](https://packagist.org/packages/razorpay/razorpay) -Razorpay client PHP Api. The api follows the following practices: +Razorpay client PHP API. The Api follows the following practices: -- namespaced under Razorpay\Api -- call $api->class->function() to access the api -- api throws exceptions instead of returning errors -- options are passed as an array instead of multiple arguments wherever possible -- All request and responses are communicated over JSON -- A minimum of PHP 5.3 is required +- Namespaced under `Razorpay\Api` +- Call `$api->class->function()` to access the API +- API throws exceptions instead of returning errors +- Options are passed as an array instead of multiple arguments wherever possible +- All requests and responses are communicated over JSON +- A minimum of PHP 5.3 is required # Installation -- If your project uses composer, add following to composer.json -```json -{ - "require": { - "razorpay/razorpay": "1.*" - } -} -``` +- If your project uses composer, run the below command -Then, run `composer update`. If you are not using composer, download -the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases). -**You should download the `razorpay-php.zip` file**. +``` +composer require razorpay/razorpay:2.* +``` -After that include `Razorpay.php` in your application and you can use the -API as usual. +- 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. # Usage @@ -35,16 +29,94 @@ API as usual. use Razorpay\Api\Api; $api = new Api($api_key, $api_secret); -$api->payment->all($options); // Returns array of payment objects -$payment = $api->payment->fetch($id); // Returns a particular payment -$api->payment->fetch($id)->capture(array('amount'=>$amount)); // Captures a payment -$api->payment->fetch($id)->refund(); // Refunds a payment -$api->payment->fetch($id)->refund(array('amount'=>$refundAmount)); // Partially refunds a payment + +// Orders +$order = $api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR')); // Creates order +$order = $api->order->fetch($orderId); // Returns a particular order +$orders = $api->order->all($options); // Returns array of order objects +$payments = $api->order->fetch($orderId)->payments(); // Returns array of payment objects against an order + +// Payments +$payments = $api->payment->all($options); // Returns array of payment objects +$payment = $api->payment->fetch($id); // Returns a particular payment +$payment = $api->payment->fetch($id)->capture(array('amount'=>$amount)); // Captures a payment // To get the payment details echo $payment->amount; echo $payment->currency; // And so on for other attributes + +// Refunds +$refund = $api->refund->create(array('payment_id' => $id)); // Creates refund for a payment +$refund = $api->refund->create(array('payment_id' => $id, 'amount'=>$refundAmount)); // Creates partial refund for a payment +$refund = $api->refund->fetch($refundId); // Returns a particular refund + +// Cards +$card = $api->card->fetch($cardId); // Returns a particular card + +// Customers +$customer = $api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com')); // Creates customer +$customer = $api->customer->fetch($customerId); // Returns a particular customer +$customer = $api->customer->edit(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com')); // Edits customer + +// Tokens +$token = $api->customer->token()->fetch($tokenId); // Returns a particular token +$tokens = $api->customer->token()->all($options); // Returns array of token objects +$api->customer->token()->delete($tokenId); // Deletes a token + + +// Transfers +$transfer = $api->payment->fetch($paymentId)->transfer(array('transfers' => [ ['account' => $accountId, 'amount' => 100, 'currency' => 'INR']])); // Create transfer +$transfers = $api->transfer->all(); // Fetch all transfers +$transfers = $api->payment->fetch($paymentId)->transfers(); // Fetch all transfers created on a payment +$transfer = $api->transfer->fetch($transferId)->edit($options); // Edit a transfer +$reversal = $api->transfer->fetch($transferId)->reverse(); // Reverse a transfer + +// Payment Links +$links = $api->invoice->all(); +$link = $api->invoice->fetch('inv_00000000000001'); +$link = $api->invoice->create(arary('type' => 'link', 'amount' => 500, 'description' => 'For XYZ purpose', 'customer' => array('email' => 'test@test.test'))); +$link->cancel(); +$link->notifyBy('sms'); + +// Invoices +$invoices = $api->invoice->all(); +$invoice = $api->invoice->fetch('inv_00000000000001'); +$invoice = $api->invoice->create($params); // Ref: razorpay.com/docs/invoices for request params example +$invoice = $invoice->edit($params); +$invoice->issue(); +$invoice->notifyBy('email'); +$invoice->cancel(); +$invoice->delete(); + +// Virtual Accounts +$virtualAccount = $api->virtualAccount->create(array('receiver_types' => array('bank_account'), 'description' => 'First Virtual Account', 'notes' => array('receiver_key' => 'receiver_value'))); +$virtualAccounts = $api->virtualAccount->all(); +$virtualAccount = $api->virtualAccount->fetch('va_4xbQrmEoA5WJ0G'); +$virtualAccount = $virtualAccount->close(); +$payments = $virtualAccount->payments(); +$bankTransfer = $api->payment->fetch('pay_8JpVEWsoNPKdQh')->bankTransfer(); + +// Bharat QR +$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'amount_expected' => 100, 'notes' => array('receiver_key' => 'receiver_value'))); // Create Static QR +$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'notes' => array('receiver_key' => 'receiver_value'))); // Create Dynamic QR + +// Subscriptions +$plan = $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'))); +$plan = $api->plan->fetch('plan_7wAosPWtrkhqZw'); +$plans = $api->plan->all(); +$subscription = $api->subscription->create(array('plan_id' => 'plan_7wAosPWtrkhqZw', 'customer_notify' => 1, 'total_count' => 6, 'start_at' => 1495995837, 'addons' => array(array('item' => array('name' => 'Delivery charges', 'amount' => 30000, 'currency' => 'INR'))))); +$subscription = $api->subscription->fetch('sub_82uBGfpFK47AlA'); +$subscriptions = $api->subscription->all(); +$subscription = $api->subscription->fetch('sub_82uBGfpFK47AlA')->cancel($options); //$options = ['cancel_at_cycle_end' => 1]; +$addon = $api->subscription->fetch('sub_82uBGfpFK47AlA')->createAddon(array('item' => array('name' => 'Extra Chair', 'amount' => 30000, 'currency' => 'INR'), 'quantity' => 2)); +$addon = $api->addon->fetch('ao_8nDvQYYGQI5o4H'); +$addon = $api->addon->fetch('ao_8nDvQYYGQI5o4H')->delete(); + +// Settlements +$settlement = $api->settlement->fetch('setl_7IZKKI4Pnt2kEe'); +$settlements = $api->settlement->all(); +$reports = $api->settlement->reports(array('year' => 2018, 'month' => 2)); ``` For further help, see our documentation on . @@ -57,16 +129,17 @@ See the [doc.md](doc.md) file for getting started with development. ## License -The Razorpay PHP SDK is released under the MIT License. +The Razorpay PHP SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details. ## Release Steps to follow for a release: -0. Merge the branch with the new code to master. -1. Bump the Version in `src/Api.php`. -2. Rename Unreleased to the new tag in `CHANGELOG` -3. Fix links at bottom in `CHANGELOG` -4. Commit -5. Tag the release and push to GitHub -6. Create a release on GitHub using the website with more details about the release +0. Merge the branch with the new code to master. +1. Bump the Version in `src/Api.php`. +1. Rename Unreleased to the new tag in `CHANGELOG.md` +1. Add a new empty "Unreleased" section at the top of `CHANGELOG.md` +1. Fix links at bottom in `CHANGELOG.md` +1. Commit +1. Tag the release and push to GitHub +1. A release should automatically be created once the travis build passes. Edit the release to add some description. diff --git a/razorpay-php/Razorpay.php b/razorpay-php/Razorpay.php index 0715d4a..8347083 100644 --- a/razorpay-php/Razorpay.php +++ b/razorpay-php/Razorpay.php @@ -3,12 +3,12 @@ // Include Requests only if not already defined if (class_exists('Requests') === false) { - require_once __DIR__.'/libs/Requests-1.6.1/library/Requests.php'; + require_once __DIR__.'/libs/Requests-1.7.0/library/Requests.php'; } try { - Requests::register_autoloader(); + Requests::register_autoloader(); if (version_compare(Requests::VERSION, '1.6.0') === -1) { diff --git a/razorpay-php/composer.json b/razorpay-php/composer.json new file mode 100644 index 0000000..625ddef --- /dev/null +++ b/razorpay-php/composer.json @@ -0,0 +1,40 @@ +{ + "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": ">=5.3.0", + "rmccue/requests": "v1.7.0", + "ext-json": "*" + }, + "require-dev": { + "raveren/kint": "1.*", + "phpunit/phpunit": "~4.8|~5.0" + }, + "autoload": { + "psr-4": { + "Razorpay\\Api\\": "src/", + "Razorpay\\Tests\\": "tests/" + } + } +} diff --git a/razorpay-php/composer.lock b/razorpay-php/composer.lock new file mode 100644 index 0000000..90bfe05 --- /dev/null +++ b/razorpay-php/composer.lock @@ -0,0 +1,1503 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "1e5e467b861c668ce477e29d6a0c22e4", + "packages": [ + { + "name": "rmccue/requests", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/rmccue/Requests.git", + "reference": "87932f52ffad70504d93f04f15690cf16a089546" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rmccue/Requests/zipball/87932f52ffad70504d93f04f15690cf16a089546", + "reference": "87932f52ffad70504d93f04f15690cf16a089546", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "require-dev": { + "requests/test-server": "dev-master" + }, + "type": "library", + "autoload": { + "psr-0": { + "Requests": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Ryan McCue", + "homepage": "http://ryanmccue.info" + } + ], + "description": "A HTTP library written in PHP, for human beings.", + "homepage": "http://github.com/rmccue/Requests", + "keywords": [ + "curl", + "fsockopen", + "http", + "idna", + "ipv6", + "iri", + "sockets" + ], + "time": "2016-10-13T00:11:37+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14T21:17:01+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-10T14:09:06+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-08-05T17:53:17+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" + }, + "require-dev": { + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" + }, + "suggest": { + "ext-xdebug": "^2.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2017-04-02T07:44:40+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2017-11-27T13:52:08+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26T11:10:40+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.12", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-12-04T08:55:13+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "5.7.27", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "^1.2.4", + "sebastian/diff": "^1.4.3", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2018-02-01T05:50:59+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "abandoned": true, + "time": "2017-06-30T09:13:00+00:00" + }, + { + "name": "raveren/kint", + "version": "1.1", + "source": { + "type": "git", + "url": "https://github.com/kint-php/kint.git", + "reference": "a8549198558560b24e2879c6bac2875de5371483" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kint-php/kint/zipball/a8549198558560b24e2879c6bac2875de5371483", + "reference": "a8549198558560b24e2879c6bac2875de5371483", + "shasum": "" + }, + "require": { + "php": ">=5.1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "Kint.class.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rokas Šleinius", + "homepage": "https://github.com/kint-php" + }, + { + "name": "Contributors", + "homepage": "https://github.com/kint-php/kint/contributors" + } + ], + "description": "Kint - debugging helper for PHP developers", + "homepage": "https://github.com/kint-php/kint", + "keywords": [ + "debug", + "kint", + "php" + ], + "abandoned": "kint-php/kint", + "time": "2017-01-15T14:23:43+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29T09:50:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2017-05-22T07:24:03+00:00" + }, + { + "name": "sebastian/environment", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-11-26T07:53:53+00:00" + }, + { + "name": "sebastian/exporter", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-11-19T08:54:04+00:00" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12T03:26:01+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18T15:18:39+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-11-19T07:33:16+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.4.27", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2019-03-25T07:48:46+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-12-25T11:19:39+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0", + "ext-json": "*" + }, + "platform-dev": [] +} diff --git a/razorpay-php/doc.md b/razorpay-php/doc.md new file mode 100644 index 0000000..a358708 --- /dev/null +++ b/razorpay-php/doc.md @@ -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) + { + + } +} +``` \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/.travis.yml b/razorpay-php/libs/Requests-1.6.1/.travis.yml deleted file mode 100755 index 6db28d2..0000000 --- a/razorpay-php/libs/Requests-1.6.1/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php -before_script: - - phpenv local 5.4 - - composer install --dev --no-interaction - - phpenv local --unset - - cd tests -script: - - phpunit --coverage-clover clover.xml -after_script: - - cd .. - - phpenv local 5.4 - - php vendor/bin/coveralls -v - - phpenv local --unset -php: - - 5.2 - - 5.3 - - 5.4 - - 5.5 - - hhvm diff --git a/razorpay-php/libs/Requests-1.6.1/CHANGELOG.md b/razorpay-php/libs/Requests-1.6.1/CHANGELOG.md deleted file mode 100755 index 2f2d106..0000000 --- a/razorpay-php/libs/Requests-1.6.1/CHANGELOG.md +++ /dev/null @@ -1,56 +0,0 @@ -Changelog -========= - -1.6.1 ------ -- [Fix compatibility with HHVM][#121] - Using HHVM with Requests would - previously cause either exceptions with SSL or segfaults with the cURL - handler. Props Ozh for his work here. - -[#121]: https://github.com/rmccue/Requests/issues/121 - -1.6.0 ------ -- [Add multiple request support][#23] - Send multiple HTTP requests with both - fsockopen and cURL, transparently falling back to synchronous when - not supported. - -- [Add proxy support][#70] - HTTP proxies are now natively supported via a - [high-level API][docs/proxy]. Major props to Ozh for his fantastic work - on this. - -- [Verify host name for SSL requests][#63] - Requests is now the first and only - standalone HTTP library to fully verify SSL hostnames even with socket - connections. Thanks to Michael Adams, Dion Hulse, Jon Cave, and Pádraic Brady - for reviewing the crucial code behind this. - -- [Add cookie support][#64] - Adds built-in support for cookies (built entirely - as a high-level API) - -- [Add sessions][#62] - To compliment cookies, [sessions][docs/usage-advanced] - can be created with a base URL and default options, plus a shared cookie jar. - -- Add [PUT][#1], [DELETE][#3], and [PATCH][#2] request support - -- [Add Composer support][#6] - You can now install Requests via the - `rmccue/requests` package on Composer - -[docs/proxy]: http://requests.ryanmccue.info/docs/proxy.html -[docs/usage-advanced]: http://requests.ryanmccue.info/docs/usage-advanced.html - -[#1]: https://github.com/rmccue/Requests/issues/1 -[#2]: https://github.com/rmccue/Requests/issues/2 -[#3]: https://github.com/rmccue/Requests/issues/3 -[#6]: https://github.com/rmccue/Requests/issues/6 -[#9]: https://github.com/rmccue/Requests/issues/9 -[#23]: https://github.com/rmccue/Requests/issues/23 -[#62]: https://github.com/rmccue/Requests/issues/62 -[#63]: https://github.com/rmccue/Requests/issues/63 -[#64]: https://github.com/rmccue/Requests/issues/64 -[#70]: https://github.com/rmccue/Requests/issues/70 - -[View all changes][https://github.com/rmccue/Requests/compare/v1.5.0...v1.6.0] - -1.5.0 ------ -Initial release! \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/bin/create_pear_package.php b/razorpay-php/libs/Requests-1.6.1/bin/create_pear_package.php deleted file mode 100755 index 3267709..0000000 --- a/razorpay-php/libs/Requests-1.6.1/bin/create_pear_package.php +++ /dev/null @@ -1,55 +0,0 @@ - ' . PHP_EOL; - echo PHP_EOL; - echo ' version:' . PHP_EOL; - echo ' Version of the package, in the form of major.minor.bug' . PHP_EOL; - echo PHP_EOL; - echo ' stability:' . PHP_EOL; - echo ' One of alpha, beta, stable' . PHP_EOL; - die(); -} - -if (!isset($argv[2])) { - die('You must provide the stability (alpha, beta, or stable)'); -} - -$context = array( - 'date' => gmdate('Y-m-d'), - 'time' => gmdate('H:m:00'), - 'version' => $argv[1], - 'api_version' => $argv[1], - 'stability' => $argv[2], - 'api_stability' => $argv[2], -); - -$context['files'] = ''; -$path = realpath(dirname(__FILE__).'/../library/Requests'); -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if (preg_match('/\.php$/', $file)) { - $name = str_replace($path . DIRECTORY_SEPARATOR, '', $file); - $name = str_replace(DIRECTORY_SEPARATOR, '/', $name); - $context['files'][] = "\t\t\t\t\t" . ''; - } -} - -$context['files'] = implode("\n", $context['files']); - -$template = file_get_contents(dirname(__FILE__).'/../package.xml.tpl'); -$content = preg_replace_callback('/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/', 'replace_parameters', $template); -file_put_contents(dirname(__FILE__).'/../package.xml', $content); - -function replace_parameters($matches) { - global $context; - - return isset($context[$matches[1]]) ? $context[$matches[1]] : null; -} diff --git a/razorpay-php/libs/Requests-1.6.1/docs/README.md b/razorpay-php/libs/Requests-1.6.1/docs/README.md deleted file mode 100755 index 8116963..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/README.md +++ /dev/null @@ -1,28 +0,0 @@ -Documentation -============= - -If you're here, you're looking for documentation for Requests! The documents -here are prose; you might also want to check out the [API documentation][]. - -[API documentation]: http://requests.ryanmccue.info/api/ - -* Introduction - * [Goals][goals] - * [Why should I use Requests instead of X?][why-requests] -* Usage - * [Making a request][usage] - * [Advanced usage][usage-advanced] - * [Authenticating your request][authentication] -* Advanced Usage - * [Custom authentication][authentication-custom] - * [Requests through proxy][proxy] - * [Hooking system][hooks] - -[goals]: goals.md -[why-requests]: why-requests.md -[usage]: usage.md -[usage-advanced]: usage-advanced.md -[authentication]: authentication.md -[authentication-custom]: authentication-custom.md -[hooks]: hooks.md -[proxy]: proxy.md \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/docs/authentication-custom.md b/razorpay-php/libs/Requests-1.6.1/docs/authentication-custom.md deleted file mode 100755 index d145d21..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/authentication-custom.md +++ /dev/null @@ -1,44 +0,0 @@ -Custom Authentication -===================== -Custom authentication handlers are designed to be extremely simple to write. -In order to write a handler, you'll need to implement the `Requests_Auth` -interface. - -An instance of this handler is then passed in by the user via the `auth` -option, just like for normal authentication. - -Let's say we have a HTTP endpoint that checks for the `Hotdog` header and -authenticates you if said header is set to `Yummy`. (I don't know of any -services that do this; perhaps this is a market waiting to be tapped?) - -```php -class MySoftware_Auth_Hotdog implements Requests_Auth { - protected $password; - - public function __construct($password) { - $this->password = $password; - } - - public function register(Requests_Hooks &$hooks) { - $hooks->register('requests.before_request', array(&$this, 'before_request')); - } - - public function before_request(&$url, &$headers, &$data, &$type, &$options) { - $headers['Hotdog'] = $this->password; - } -} -``` - -We then use this in our request calls: - -``` -$options = array( - 'auth' => new MySoftware_Auth_Hotdog('yummy') -); -$response = Requests::get('http://hotdogbin.org/admin', array(), $options); -``` - -(For more information on how to register and use hooks, see the [hooking -system documentation][hooks]) - -[hooks]: hooks.md \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/docs/authentication.md b/razorpay-php/libs/Requests-1.6.1/docs/authentication.md deleted file mode 100755 index eaa7ea5..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/authentication.md +++ /dev/null @@ -1,31 +0,0 @@ -Authentication -============== -Many requests that you make will require authentication of some type. Requests -includes support out of the box for HTTP Basic authentication, with more -built-ins coming soon. - -Making a Basic authenticated call is ridiculously easy: - -```php -$options = array( - 'auth' => new Requests_Auth_Basic(array('user', 'password')) -); -Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options); -``` - -As Basic authentication is usually what you want when you specify a username -and password, you can also just pass in an array as a shorthand: - -```php -$options = array( - 'auth' => array('user', 'password') -); -Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options); -``` - -Note that POST/PUT can also take a data parameter, so you also need that -before `$options`: - -```php -Requests::get('http://httpbin.org/basic-auth/user/password', array(), null, $options); -``` \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/docs/goals.md b/razorpay-php/libs/Requests-1.6.1/docs/goals.md deleted file mode 100755 index 3275a3f..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/goals.md +++ /dev/null @@ -1,29 +0,0 @@ -Goals -===== - -1. **Simple interface** - - Requests is designed to provide a simple, unified interface to making - requests, regardless of what is available on the system. This means not worrying. - -2. **Fully tested code** - - Requests strives to have 90%+ code coverage from the unit tests, aiming for - the ideal 100%. Introducing new features always means introducing new tests - - (Note: some parts of the code are not covered by design. These sections are - marked with `@codeCoverageIgnore` tags) - -3. **Maximum compatibility** - - No matter what you have installed on your system, you should be able to run - Requests. We use cURL if it's available, and fallback to sockets otherwise. - We require only a baseline of PHP 5.2, leaving the choice of PHP minimum - requirement fully in your hands, and giving you the ability to support many - more hosts. - -4. **No dependencies** - - Requests is designed to be entirely self-contained and doesn't require - anything else at all. You can run Requests on an entirely stock PHP build - without any additional extensions outside the standard library. diff --git a/razorpay-php/libs/Requests-1.6.1/docs/hooks.md b/razorpay-php/libs/Requests-1.6.1/docs/hooks.md deleted file mode 100755 index 96a39bf..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/hooks.md +++ /dev/null @@ -1,92 +0,0 @@ -Hooks -===== -Requests has a hook system that you can use to manipulate parts of the request -process along with internal transport hooks. - -Check out the [API documentation for `Requests_Hooks`][requests_hooks] for more -information on how to use the hook system. - -Available Hooks ---------------- - -* `requests.before_request` - - Alter the request before it's sent to the transport. - - Parameters: `string &$url`, `array &$headers`, `array|string &$data`, - `string &$type`, `array &$options` - -* `requests.before_parse` - - Alter the raw HTTP response before parsing - - Parameters: `string &$response` - -* `requests.after_request` - - Alter the response object before it's returned to the user - - Parameters: `Requests_Response &$return` - -* `curl.before_request` - - Set cURL options before the transport sets any (note that Requests may - override these) - - Parameters: `cURL resource &$fp` - -* `curl.before_send` - - Set cURL options just before the request is actually sent via `curl_exec` - - Parameters: `cURL resource &$fp` - -* `curl.after_request` - - Alter the raw HTTP response before returning for parsing - - Parameters: `string &$response` - -* `fsockopen.before_request` - - Run events before the transport does anything - -* `fsockopen.after_headers` - - Add extra headers before the body begins (i.e. before `\r\n\r\n`) - - Parameters: `string &$out` - -* `fsockopen.before_send` - - Add body data before sending the request - - Parameters: `string &$out` - -* `fsockopen.after_send` - - Run events after writing the data to the socket - -* `fsockopen.after_request` - - Alter the raw HTTP response before returning for parsing - - Parameters: `string &$response` - - -Registering Hooks ------------------ -Note: if you're doing this in an authentication handler, see the [Custom -Authentication guide][authentication-custom] instead. - -[authentication-custom]: authentication-custom.md - -In order to register your own hooks, you need to instantiate `Requests_hooks` -and pass this in via the 'hooks' option. - -```php -$hooks = new Requests_Hooks(); -$hooks->register('requests.after_request', 'mycallback'); - -$request = Requests::get('http://httpbin.org/get', array(), array('hooks' => $hooks)); -``` \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/docs/proxy.md b/razorpay-php/libs/Requests-1.6.1/docs/proxy.md deleted file mode 100644 index cb2675d..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/proxy.md +++ /dev/null @@ -1,23 +0,0 @@ -Proxy Support -============= - -You can easily make requests through HTTP proxies. - -To make requests through an open proxy, specify the following options: - -```php -$options = array( - 'proxy' => '127.0.0.1:3128' -); -Requests::get('http://httpbin.org/ip', array(), $options); -``` - -If your proxy needs you to authenticate, the option will become an array like -the following: - -```php -$options = array( - 'proxy' => array( '127.0.0.1:3128', 'my_username', 'my_password' ) -); -Requests::get('http://httpbin.org/ip', array(), $options); -``` diff --git a/razorpay-php/libs/Requests-1.6.1/docs/usage-advanced.md b/razorpay-php/libs/Requests-1.6.1/docs/usage-advanced.md deleted file mode 100755 index b3f2880..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/usage-advanced.md +++ /dev/null @@ -1,74 +0,0 @@ -Advanced Usage -============== - -Session Handling ----------------- -Making multiple requests to the same site with similar options can be a pain, -since you end up repeating yourself. The Session object can be used to set -default parameters for these. - -Let's simulate communicating with GitHub. - -```php -$session = new Requests_Session('https://api.github.com/'); -$session->headers['X-ContactAuthor'] = 'rmccue'; -$session->useragent = 'My-Awesome-App'; - -$response = $session->get('/zen'); -``` - -You can use the `url`, `headers`, `data` and `options` properties of the Session -object to set the defaults for this session, and the constructor also takes -parameters in the same order as `Requests::request()`. Accessing any other -properties will set the corresponding key in the options array; that is: - -```php -// Setting the property... -$session->useragent = 'My-Awesome-App'; - -// ...is the same as setting the option -$session->options['useragent'] = 'My-Awesome-App'; -``` - - -Secure Requests with SSL ------------------------- -By default, HTTPS requests will use the most secure options available: - -```php -$response = Requests::get('https://httpbin.org/'); -``` - -Requests bundles certificates from the [Mozilla certificate authority list][], -which is the same list of root certificates used in most browsers. If you're -accessing sites with certificates from other CAs, or self-signed certificates, -you can point Requests to a custom CA list in PEM form (the same format -accepted by cURL and OpenSSL): - -```php -$options = array( - 'verify' => '/path/to/cacert.pem' -); -$response = Requests::get('https://httpbin.org/', array(), $options); -``` - -Alternatively, if you want to disable verification completely, this is possible -with `'verify' => false`, but note that this is extremely insecure and should be -avoided. - -### Security Note -Requests supports SSL across both cURL and fsockopen in a transparent manner. -Unlike other PHP HTTP libraries, support for verifying the certificate name is -built-in; that is, a request for `https://github.com/` will actually verify the -certificate's name even with the fsockopen transport. This makes Requests the -first and currently only PHP HTTP library that supports full SSL verification. - -(Note that WordPress now also supports this verification, thanks to efforts by -the Requests development team.) - -(See also the [related PHP][php-bug-47030] and [OpenSSL-related][php-bug-55820] -bugs in PHP for more information on Subject Alternate Name field.) - -[Mozilla certificate authority list]: http://www.mozilla.org/projects/security/certs/ -[php-bug-47030]: https://bugs.php.net/bug.php?id=47030 -[php-bug-55820]:https://bugs.php.net/bug.php?id=55820 diff --git a/razorpay-php/libs/Requests-1.6.1/docs/usage.md b/razorpay-php/libs/Requests-1.6.1/docs/usage.md deleted file mode 100755 index 53ca495..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/usage.md +++ /dev/null @@ -1,154 +0,0 @@ -Usage -===== - -Ready to go? Make sure you have Requests installed before attempting any of the -steps in this guide. - - -Loading Requests ----------------- -Before we can load Requests up, we'll need to make sure it's loaded. This is a -simple two-step: - -```php -// First, include Requests -include('/path/to/library/Requests.php'); - -// Next, make sure Requests can load internal classes -Requests::register_autoloader(); -``` - -If you'd like to bring along your own autoloader, you can forget about this -completely. - - -Make a GET Request ------------------- -One of the most basic things you can do with HTTP is make a GET request. - -Let's grab GitHub's public timeline: - -```php -$response = Requests::get('https://github.com/timeline.json'); -``` - -`$response` is now a **Requests_Response** object. Response objects are what -you'll be working with whenever you want to get data back from your request. - - -Using the Response Object -------------------------- -Now that we have the response from GitHub, let's get the body of the response. - -```php -var_dump($response->body); -// string(42865) "[{"repository":{"url":"... -``` - - -Custom Headers --------------- -If you want to add custom headers to the request, simply pass them in as an -associative array as the second parameter: - -```php -$response = Requests::get('https://github.com/timeline.json', array('X-Requests' => 'Is Awesome!')); -``` - - -Make a POST Request -------------------- -Making a POST request is very similar to making a GET: - -```php -$response = Requests::post('http://httpbin.org/post'); -``` - -You'll probably also want to pass in some data. You can pass in either a -string, an array or an object (Requests uses [`http_build_query`][build_query] -internally) as the third parameter (after the URL and headers): - -[build_query]: http://php.net/http_build_query - -```php -$data = array('key1' => 'value1', 'key2' => 'value2'); -$response = Requests::post('http://httpbin.org/post', array(), $data); -var_dump($response->body); -``` - -This gives the output: - - string(503) "{ - "origin": "124.191.162.147", - "files": {}, - "form": { - "key2": "value2", - "key1": "value1" - }, - "headers": { - "Content-Length": "23", - "Accept-Encoding": "deflate;q=1.0, compress;q=0.5, gzip;q=0.5", - "X-Forwarded-Port": "80", - "Connection": "keep-alive", - "User-Agent": "php-requests/1.6-dev", - "Host": "httpbin.org", - "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" - }, - "url": "http://httpbin.org/post", - "args": {}, - "data": "" - }" - -To send raw data, simply pass in a string instead. You'll probably also want to -set the Content-Type header to ensure the remote server knows what you're -sending it: - -```php -$url = 'https://api.github.com/some/endpoint'; -$headers = array('Content-Type' => 'application/json'); -$data = array('some' => 'data'); -$response = Requests::post($url, $headers, json_encode($data)); -``` - -Note that if you don't manually specify a Content-Type header, Requests has -undefined behaviour for the header. It may be set to various values depending -on the internal execution path, so it's recommended to set this explicitly if -you need to. - - -Status Codes ------------- -The Response object also gives you access to the status code: - -```php -var_dump($response->status_code); -// int(200) -``` - -You can also easily check if this status code is a success code, or if it's an -error: - -```php -var_dump($response->success); -// bool(true) -``` - - -Response Headers ----------------- -We can also grab headers pretty easily: - -```php -var_dump($response->headers['Date']); -// string(29) "Thu, 09 Feb 2012 15:22:06 GMT" -``` - -Note that this is case-insensitive, so the following are all equivalent: - -* `$response->headers['Date']` -* `$response->headers['date']` -* `$response->headers['DATE']` -* `$response->headers['dAtE']` - -If a header isn't set, this will give `null`. You can also check with -`isset($response->headers['date'])` diff --git a/razorpay-php/libs/Requests-1.6.1/docs/why-requests.md b/razorpay-php/libs/Requests-1.6.1/docs/why-requests.md deleted file mode 100755 index 2874731..0000000 --- a/razorpay-php/libs/Requests-1.6.1/docs/why-requests.md +++ /dev/null @@ -1,192 +0,0 @@ -Why Requests Instead of X? -========================== -This is a quick look at why you should use Requests instead of another -solution. Keep in mind though that these are my point of view, and they may not -be issues for you. - -As always with software, you should choose what you think is best. - - -Why should I use Requests? --------------------------- -1. **Designed for maximum compatibility** - - The realities of working with widely deployable software mean that awesome - PHP features aren't always available. PHP 5.3, cURL, OpenSSL and more are not - necessarily going to be available on every system. While you're welcome to - require PHP 5.3, 5.4 or even 5.5, it's not our job to force you to use those. - - (The WordPress project estimates [about 60%][wpstats] of hosts are running - PHP 5.2, so this is a serious issue for developers working on large - deployable projects.) - - Don't worry though, Requests will automatically use better features where - possible, giving you an extra speed boost with cURL. - -2. **Simple API** - - Requests' API is designed to be able to be learnt in 10 minutes. Everything - from basic requests all the way up to advanced usage involving custom SSL - certificates and stored cookies is handled by a simple API. - - Other HTTP libraries optimize for the library developer's time; **Requests - optimizes for your time**. - -3. **Thoroughly tested** - - Requests is [continuously integrated with Travis][travis] and test coverage - is [constantly monitored with Coveralls][coveralls] to give you confidence in - the library. We aim for test coverage **over 90%** at all times, and new - features require new tests to go along with them. This ensures that you can - be confident in the quality of the code, as well as being able to update to - the latest version of Requests without worrying about compatibility. - -4. **Secure by default** - - Unlike other HTTP libraries, Requests is secure by default. Requests is the - **first and currently only** standalone HTTP library to - **[fully verify][requests_ssl] all HTTPS requests** even without cURL. We - also bundle the latest root certificate authorities to ensure that your - secure requests are actually secure. - - (Of note is that WordPress as of version 3.7 also supports full checking of - the certificates, thanks to [evangelism efforts on our behalf][wpssl]. - Together, we are the only HTTP libraries in PHP to fully verify certificates - to the same level as browsers.) - -5. **Extensible from the core** - - If you need low-level access to Requests' internals, simply plug your - callbacks in via the built-in [hooking system][] and mess around as much as - you want. Requests' simple hooking system is so powerful that both - authentication handlers and cookie support is actually handled internally - with hooks. - -[coveralls]: https://coveralls.io/r/rmccue/Requests -[hooking system]: hooks.md -[requests_ssl]: https://github.com/rmccue/Requests/blob/master/library/Requests/SSL.php -[travis]: https://travis-ci.org/rmccue/Requests -[wpssl]: http://core.trac.wordpress.org/ticket/25007 - - -Why shouldn't I use... ----------------------- -Requests isn't the first or only HTTP library in PHP and it's important to -acknowledge the other solutions out there. Here's why you should use Requests -instead of something else, in our opinion. - - -### cURL - -1. **Not every host has cURL installed** - - cURL is far from being ubiquitous, so you can't rely on it always being - available when distributing software. Anecdotal data collected from various - projects indicates that cURL is available on roughly 90% of hosts, but that - leaves 10% of hosts without it. - -2. **cURL's interface sucks** - - cURL's interface was designed for PHP 4, and hence uses resources with - horrible functions such as `curl_setopt()`. Combined with that, it uses 229 - global constants, polluting the global namespace horribly. - - Requests, on the other hand, exposes only a handful of classes to the - global namespace, most of which are for internal use. You can learn to use - the `Requests::request()` method and the `Requests_Response` object in the - space of 10 minutes and you already know how to use Requests. - - -### Guzzle - -1. **Requires cURL and PHP 5.3+** - - Guzzle is designed to be a client to fit a large number of installations, but - as a result of optimizing for Guzzle developer time, it uses cURL as an - underlying transport. As noted above, this is a majority of systems, but - far from all. - - The same is true for PHP 5.3+. While we'd all love to rely on PHP's newer - features, the fact is that a huge percentage of hosts are still running on - PHP 5.2. (The WordPress project estimates [about 60%][wpstats] of hosts are - running PHP 5.2.) - -2. **Not just a HTTP client** - - Guzzle is not intended to just be a HTTP client, but rather to be a - full-featured REST client. Requests is just a HTTP client, intentionally. Our - development strategy is to act as a low-level library that REST clients can - easily be built on, not to provide the whole kitchen sink for you. - - If you want to rapidly develop a web service client using a framework, Guzzle - will suit you perfectly. On the other hand, if you want a HTTP client without - all the rest, Requests is the way to go. - -[wpstats]: http://wordpress.org/about/stats/ - - -### Buzz - -1. **Requires PHP 5.3+** - - As with Guzzle, while PHP 5.3+ is awesome, you can't always rely on it being - on a host. With widely distributable software, this is a huge problem. - -2. **Not transport-transparent** - - For making certain types of requests, such as multi-requests, you can't rely - on a high-level abstraction and instead have to use the low-level transports. - This really gains nothing (other than a fancy interface) over just using the - methods directly and means that you can't rely on features to be available. - - -### fsockopen - -1. **Very low-level** - - fsockopen is used for working with sockets directly, so it only knows about - the transport layer (TCP in our case), not anything higher (i.e. HTTP on the - application layer). To be able to use fsockopen as a HTTP client, you need - to write all the HTTP code yourself, and once you're done, you'll end up - with something that is almost exactly like Requests. - - -### PEAR HTTP_Request2 - -1. **Requires PEAR** - - PEAR is (in theory) a great distribution system (with a less than wonderful - implementation), however it is not ubiquitous, as many hosts disable it to - save on space that most people aren't going to use anyway. - - PEAR is also a pain for users. Users want to be able to download a zip of - your project without needing to install anything else from PEAR. - - (If you really want though, Requests is available via PEAR. Check the README - to see how to grab it.) - -2. **Depends on other PEAR utilities** - - HTTP\_Request2 requires Net_URL2 in order to function, locking you in to - using PEAR for your project. - - Requests is entirely self-contained, and includes all the libraries it needs - (for example, Requests\_IRI is based on ComplexPie\_IRI by Geoffrey Sneddon). - - -### PECL HttpRequest - -1. **Requires a PECL extension** - - Similar to PEAR, users aren't big fans of installing extra libraries. Unlike - PEAR though, PECL extensions require compiling, which end users will be - unfamiliar with. In addition, on systems where users do not have full - control over PHP, they will be unable to install custom extensions. - - -### Zend Framework's Zend\_Http\_Client - -1. **Requires other parts of the Zend Framework** - - Similar to HTTP_Request2, Zend's client is not fully self-contained and - requires other components from the framework. diff --git a/razorpay-php/libs/Requests-1.6.1/examples/basic-auth.php b/razorpay-php/libs/Requests-1.6.1/examples/basic-auth.php deleted file mode 100755 index a9584a8..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/basic-auth.php +++ /dev/null @@ -1,16 +0,0 @@ - array('someuser', 'password') -); -$request = Requests::get('http://httpbin.org/basic-auth/someuser/password', array(), $options); - -// Check what we received -var_dump($request); \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/examples/get.php b/razorpay-php/libs/Requests-1.6.1/examples/get.php deleted file mode 100755 index 8d06537..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/get.php +++ /dev/null @@ -1,13 +0,0 @@ - 'application/json')); - -// Check what we received -var_dump($request); \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/examples/multiple.php b/razorpay-php/libs/Requests-1.6.1/examples/multiple.php deleted file mode 100755 index 69757c3..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/multiple.php +++ /dev/null @@ -1,45 +0,0 @@ - 'http://httpbin.org/get', - 'headers' => array('Accept' => 'application/javascript'), - ), - 'post' => array( - 'url' => 'http://httpbin.org/post', - 'data' => array('mydata' => 'something'), - ), - 'delayed' => array( - 'url' => 'http://httpbin.org/delay/10', - 'options' => array( - 'timeout' => 20, - ), - ), -); - -// Setup a callback -function my_callback(&$request, $id) { - var_dump($id, $request); -} - -// Tell Requests to use the callback -$options = array( - 'complete' => 'my_callback', -); - -// Send the request! -$responses = Requests::request_multiple($requests, $options); - -// Note: the response from the above call will be an associative array matching -// $requests with the response data, however we've already handled it in -// my_callback() anyway! -// -// If you don't believe me, uncomment this: -# var_dump($responses); \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/examples/post.php b/razorpay-php/libs/Requests-1.6.1/examples/post.php deleted file mode 100755 index 5c9e2c7..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/post.php +++ /dev/null @@ -1,13 +0,0 @@ - 'something')); - -// Check what we received -var_dump($request); \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/examples/proxy.php b/razorpay-php/libs/Requests-1.6.1/examples/proxy.php deleted file mode 100644 index c8a2e94..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/proxy.php +++ /dev/null @@ -1,18 +0,0 @@ - '127.0.0.1:8080', // syntax: host:port, eg 12.13.14.14:8080 or someproxy.com:3128 - // If you need to authenticate, use the following syntax: - // 'proxy' => array( '127.0.0.1:8080', 'username', 'password' ), -); -$request = Requests::get('http://httpbin.org/ip', array(), $options ); - -// See result -var_dump($request->body); diff --git a/razorpay-php/libs/Requests-1.6.1/examples/session.php b/razorpay-php/libs/Requests-1.6.1/examples/session.php deleted file mode 100755 index ff44d24..0000000 --- a/razorpay-php/libs/Requests-1.6.1/examples/session.php +++ /dev/null @@ -1,24 +0,0 @@ -headers['Accept'] = 'application/json'; -$session->useragent = 'Awesomesauce'; - -// Now let's make a request! -$request = $session->get('/get'); - -// Check what we received -var_dump($request); - -// Let's check our user agent! -$request = $session->get('/user-agent'); - -// And check again -var_dump($request); diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie.php b/razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie.php deleted file mode 100644 index 365fad8..0000000 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie.php +++ /dev/null @@ -1,171 +0,0 @@ -name = $name; - $this->value = $value; - $this->attributes = $attributes; - } - - /** - * 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 formatForHeader() { - 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 formatForSetCookie() { - $header_value = $this->formatForHeader(); - if (!empty($this->attributes)) { - $parts = array(); - 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; - } - - /** - * Get the cookie value - * - * Attributes and other data can be accessed via methods. - */ - public function __toString() { - return $this->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 value (from a Set-Cookie header) - * @return Requests_Cookie Parsed cookie object - */ - public static function parse($string, $name = '') { - $parts = explode(';', $string); - $kvparts = array_shift($parts); - - if (!empty($name)) { - $value = $string; - } - 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 key are handled case-insensitively - $attributes = new Requests_Utility_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 Requests_Cookie($name, $value, $attributes); - } - - /** - * Parse all Set-Cookie headers from request headers - * - * @param Requests_Response_Headers $headers - * @return array - */ - public static function parseFromHeaders(Requests_Response_Headers $headers) { - $cookie_headers = $headers->getValues('Set-Cookie'); - if (empty($cookie_headers)) { - return array(); - } - - $cookies = array(); - foreach ($cookie_headers as $header) { - $parsed = self::parse($header); - $cookies[$parsed->name] = $parsed; - } - - return $cookies; - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/IPv6.php b/razorpay-php/libs/Requests-1.6.1/library/Requests/IPv6.php deleted file mode 100755 index 5e5c259..0000000 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/IPv6.php +++ /dev/null @@ -1,221 +0,0 @@ - FF01:0:0:0:0:0:0:101 - * ::1 -> 0:0:0:0:0:0:0:1 - * - * @author Alexander Merz - * @author elfrink at introweb dot nl - * @author Josh Peck - * @copyright 2003-2005 The PHP Group - * @license http://www.opensource.org/licenses/bsd-license.php - * @param string $ip An IPv6 address - * @return string The uncompressed IPv6 address - */ - public static function uncompress($ip) - { - $c1 = -1; - $c2 = -1; - if (substr_count($ip, '::') === 1) - { - list($ip1, $ip2) = explode('::', $ip); - if ($ip1 === '') - { - $c1 = -1; - } - else - { - $c1 = substr_count($ip1, ':'); - } - if ($ip2 === '') - { - $c2 = -1; - } - else - { - $c2 = substr_count($ip2, ':'); - } - if (strpos($ip2, '.') !== false) - { - $c2++; - } - // :: - if ($c1 === -1 && $c2 === -1) - { - $ip = '0:0:0:0:0:0:0:0'; - } - // ::xxx - else if ($c1 === -1) - { - $fill = str_repeat('0:', 7 - $c2); - $ip = str_replace('::', $fill, $ip); - } - // xxx:: - else if ($c2 === -1) - { - $fill = str_repeat(':0', 7 - $c1); - $ip = str_replace('::', $fill, $ip); - } - // xxx::xxx - else - { - $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); - $ip = str_replace('::', $fill, $ip); - } - } - return $ip; - } - - /** - * Compresses an IPv6 address - * - * RFC 4291 allows you to compress consecutive zero pieces in an address to - * '::'. This method expects a valid IPv6 address and compresses consecutive - * zero pieces to '::'. - * - * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 - * 0:0:0:0:0:0:0:1 -> ::1 - * - * @see uncompress() - * @param string $ip An IPv6 address - * @return string The compressed IPv6 address - */ - public static function compress($ip) - { - // Prepare the IP to be compressed - $ip = self::uncompress($ip); - $ip_parts = self::split_v6_v4($ip); - - // Replace all leading zeros - $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); - - // Find bunches of zeros - if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) - { - $max = 0; - $pos = null; - foreach ($matches[0] as $match) - { - if (strlen($match[0]) > $max) - { - $max = strlen($match[0]); - $pos = $match[1]; - } - } - - $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); - } - - if ($ip_parts[1] !== '') - { - return implode(':', $ip_parts); - } - else - { - return $ip_parts[0]; - } - } - - /** - * Splits an IPv6 address into the IPv6 and IPv4 representation parts - * - * RFC 4291 allows you to represent the last two parts of an IPv6 address - * using the standard IPv4 representation - * - * Example: 0:0:0:0:0:0:13.1.68.3 - * 0:0:0:0:0:FFFF:129.144.52.38 - * - * @param string $ip An IPv6 address - * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part - */ - private static function split_v6_v4($ip) - { - if (strpos($ip, '.') !== false) - { - $pos = strrpos($ip, ':'); - $ipv6_part = substr($ip, 0, $pos); - $ipv4_part = substr($ip, $pos + 1); - return array($ipv6_part, $ipv4_part); - } - else - { - return array($ip, ''); - } - } - - /** - * Checks an IPv6 address - * - * Checks if the given IP is a valid IPv6 address - * - * @param string $ip An IPv6 address - * @return bool true if $ip is a valid IPv6 address - */ - public static function check_ipv6($ip) - { - $ip = self::uncompress($ip); - list($ipv6, $ipv4) = self::split_v6_v4($ip); - $ipv6 = explode(':', $ipv6); - $ipv4 = explode('.', $ipv4); - if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) - { - foreach ($ipv6 as $ipv6_part) - { - // The section can't be empty - if ($ipv6_part === '') - return false; - - // Nor can it be over four characters - if (strlen($ipv6_part) > 4) - return false; - - // Remove leading zeros (this is safe because of the above) - $ipv6_part = ltrim($ipv6_part, '0'); - if ($ipv6_part === '') - $ipv6_part = '0'; - - // Check the value is valid - $value = hexdec($ipv6_part); - if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) - return false; - } - if (count($ipv4) === 4) - { - foreach ($ipv4 as $ipv4_part) - { - $value = (int) $ipv4_part; - if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) - return false; - } - } - return true; - } - else - { - return false; - } - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/IRI.php b/razorpay-php/libs/Requests-1.6.1/library/Requests/IRI.php deleted file mode 100755 index b8dceae..0000000 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/IRI.php +++ /dev/null @@ -1,1220 +0,0 @@ - array( - 'port' => 674 - ), - 'dict' => array( - 'port' => 2628 - ), - 'file' => array( - 'ihost' => 'localhost' - ), - 'http' => array( - 'port' => 80, - 'ipath' => '/' - ), - 'https' => array( - 'port' => 443, - 'ipath' => '/' - ), - ); - - /** - * Return the entire IRI when you try and read the object as a string - * - * @return string - */ - public function __toString() - { - return $this->get_iri(); - } - - /** - * Overload __set() to provide access via properties - * - * @param string $name Property name - * @param mixed $value Property value - */ - public function __set($name, $value) - { - if (method_exists($this, 'set_' . $name)) - { - call_user_func(array($this, 'set_' . $name), $value); - } - elseif ( - $name === 'iauthority' - || $name === 'iuserinfo' - || $name === 'ihost' - || $name === 'ipath' - || $name === 'iquery' - || $name === 'ifragment' - ) - { - call_user_func(array($this, 'set_' . substr($name, 1)), $value); - } - } - - /** - * Overload __get() to provide access via properties - * - * @param string $name Property name - * @return mixed - */ - public function __get($name) - { - // isset() returns false for null, we don't want to do that - // Also why we use array_key_exists below instead of isset() - $props = get_object_vars($this); - - if ( - $name === 'iri' || - $name === 'uri' || - $name === 'iauthority' || - $name === 'authority' - ) - { - $return = $this->{"get_$name"}(); - } - elseif (array_key_exists($name, $props)) - { - $return = $this->$name; - } - // host -> ihost - elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) - { - $name = $prop; - $return = $this->$prop; - } - // ischeme -> scheme - elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) - { - $name = $prop; - $return = $this->$prop; - } - else - { - trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); - $return = null; - } - - if ($return === null && isset($this->normalization[$this->scheme][$name])) - { - return $this->normalization[$this->scheme][$name]; - } - else - { - return $return; - } - } - - /** - * Overload __isset() to provide access via properties - * - * @param string $name Property name - * @return bool - */ - public function __isset($name) - { - if (method_exists($this, 'get_' . $name) || isset($this->$name)) - { - return true; - } - else - { - return false; - } - } - - /** - * Overload __unset() to provide access via properties - * - * @param string $name Property name - */ - public function __unset($name) - { - if (method_exists($this, 'set_' . $name)) - { - call_user_func(array($this, 'set_' . $name), ''); - } - } - - /** - * Create a new IRI object, from a specified string - * - * @param string $iri - */ - public function __construct($iri = null) - { - $this->set_iri($iri); - } - - /** - * Create a new IRI object by resolving a relative IRI - * - * Returns false if $base is not absolute, otherwise an IRI. - * - * @param IRI|string $base (Absolute) Base IRI - * @param IRI|string $relative Relative IRI - * @return IRI|false - */ - public static function absolutize($base, $relative) - { - if (!($relative instanceof Requests_IRI)) - { - $relative = new Requests_IRI($relative); - } - if (!$relative->is_valid()) - { - return false; - } - elseif ($relative->scheme !== null) - { - return clone $relative; - } - else - { - if (!($base instanceof Requests_IRI)) - { - $base = new Requests_IRI($base); - } - if ($base->scheme !== null && $base->is_valid()) - { - if ($relative->get_iri() !== '') - { - if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) - { - $target = clone $relative; - $target->scheme = $base->scheme; - } - else - { - $target = new Requests_IRI; - $target->scheme = $base->scheme; - $target->iuserinfo = $base->iuserinfo; - $target->ihost = $base->ihost; - $target->port = $base->port; - if ($relative->ipath !== '') - { - if ($relative->ipath[0] === '/') - { - $target->ipath = $relative->ipath; - } - elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') - { - $target->ipath = '/' . $relative->ipath; - } - elseif (($last_segment = strrpos($base->ipath, '/')) !== false) - { - $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; - } - else - { - $target->ipath = $relative->ipath; - } - $target->ipath = $target->remove_dot_segments($target->ipath); - $target->iquery = $relative->iquery; - } - else - { - $target->ipath = $base->ipath; - if ($relative->iquery !== null) - { - $target->iquery = $relative->iquery; - } - elseif ($base->iquery !== null) - { - $target->iquery = $base->iquery; - } - } - $target->ifragment = $relative->ifragment; - } - } - else - { - $target = clone $base; - $target->ifragment = null; - } - $target->scheme_normalization(); - return $target; - } - else - { - return false; - } - } - } - - /** - * Parse an IRI into scheme/authority/path/query/fragment segments - * - * @param string $iri - * @return array - */ - protected function parse_iri($iri) - { - $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); - if (preg_match('/^((?P[^:\/?#]+):)?(\/\/(?P[^\/?#]*))?(?P[^?#]*)(\?(?P[^#]*))?(#(?P.*))?$/', $iri, $match)) - { - if ($match[1] === '') - { - $match['scheme'] = null; - } - if (!isset($match[3]) || $match[3] === '') - { - $match['authority'] = null; - } - if (!isset($match[5])) - { - $match['path'] = ''; - } - if (!isset($match[6]) || $match[6] === '') - { - $match['query'] = null; - } - if (!isset($match[8]) || $match[8] === '') - { - $match['fragment'] = null; - } - return $match; - } - else - { - trigger_error('This should never happen', E_USER_ERROR); - die; - } - } - - /** - * Remove dot segments from a path - * - * @param string $input - * @return string - */ - protected function remove_dot_segments($input) - { - $output = ''; - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') - { - // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, - if (strpos($input, '../') === 0) - { - $input = substr($input, 3); - } - elseif (strpos($input, './') === 0) - { - $input = substr($input, 2); - } - // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, - elseif (strpos($input, '/./') === 0) - { - $input = substr($input, 2); - } - elseif ($input === '/.') - { - $input = '/'; - } - // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, - elseif (strpos($input, '/../') === 0) - { - $input = substr($input, 3); - $output = substr_replace($output, '', strrpos($output, '/')); - } - elseif ($input === '/..') - { - $input = '/'; - $output = substr_replace($output, '', strrpos($output, '/')); - } - // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, - elseif ($input === '.' || $input === '..') - { - $input = ''; - } - // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer - elseif (($pos = strpos($input, '/', 1)) !== false) - { - $output .= substr($input, 0, $pos); - $input = substr_replace($input, '', 0, $pos); - } - else - { - $output .= $input; - $input = ''; - } - } - return $output . $input; - } - - /** - * Replace invalid character with percent encoding - * - * @param string $string Input string - * @param string $extra_chars Valid characters not in iunreserved or - * iprivate (this is ASCII-only) - * @param bool $iprivate Allow iprivate - * @return string - */ - protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) - { - // Normalize as many pct-encoded sections as possible - $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string); - - // Replace invalid percent characters - $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); - - // Add unreserved and % to $extra_chars (the latter is safe because all - // pct-encoded sections are now valid). - $extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; - - // Now replace any bytes that aren't allowed with their pct-encoded versions - $position = 0; - $strlen = strlen($string); - while (($position += strspn($string, $extra_chars, $position)) < $strlen) - { - $value = ord($string[$position]); - - // Start position - $start = $position; - - // By default we are valid - $valid = true; - - // No one byte sequences are valid due to the while. - // Two byte sequence: - if (($value & 0xE0) === 0xC0) - { - $character = ($value & 0x1F) << 6; - $length = 2; - $remaining = 1; - } - // Three byte sequence: - elseif (($value & 0xF0) === 0xE0) - { - $character = ($value & 0x0F) << 12; - $length = 3; - $remaining = 2; - } - // Four byte sequence: - elseif (($value & 0xF8) === 0xF0) - { - $character = ($value & 0x07) << 18; - $length = 4; - $remaining = 3; - } - // Invalid byte: - else - { - $valid = false; - $length = 1; - $remaining = 0; - } - - if ($remaining) - { - if ($position + $length <= $strlen) - { - for ($position++; $remaining; $position++) - { - $value = ord($string[$position]); - - // Check that the byte is valid, then add it to the character: - if (($value & 0xC0) === 0x80) - { - $character |= ($value & 0x3F) << (--$remaining * 6); - } - // If it is invalid, count the sequence as invalid and reprocess the current byte: - else - { - $valid = false; - $position--; - break; - } - } - } - else - { - $position = $strlen - 1; - $valid = false; - } - } - - // Percent encode anything invalid or not in ucschar - if ( - // Invalid sequences - !$valid - // Non-shortest form sequences are invalid - || $length > 1 && $character <= 0x7F - || $length > 2 && $character <= 0x7FF - || $length > 3 && $character <= 0xFFFF - // Outside of range of ucschar codepoints - // Noncharacters - || ($character & 0xFFFE) === 0xFFFE - || $character >= 0xFDD0 && $character <= 0xFDEF - || ( - // Everything else not in ucschar - $character > 0xD7FF && $character < 0xF900 - || $character < 0xA0 - || $character > 0xEFFFD - ) - && ( - // Everything not in iprivate, if it applies - !$iprivate - || $character < 0xE000 - || $character > 0x10FFFD - ) - ) - { - // If we were a character, pretend we weren't, but rather an error. - if ($valid) - $position--; - - for ($j = $start; $j <= $position; $j++) - { - $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); - $j += 2; - $position += 2; - $strlen += 2; - } - } - } - - return $string; - } - - /** - * Callback function for preg_replace_callback. - * - * Removes sequences of percent encoded bytes that represent UTF-8 - * encoded characters in iunreserved - * - * @param array $match PCRE match - * @return string Replacement - */ - protected function remove_iunreserved_percent_encoded($match) - { - // As we just have valid percent encoded sequences we can just explode - // and ignore the first member of the returned array (an empty string). - $bytes = explode('%', $match[0]); - - // Initialize the new string (this is what will be returned) and that - // there are no bytes remaining in the current sequence (unsurprising - // at the first byte!). - $string = ''; - $remaining = 0; - - // Loop over each and every byte, and set $value to its value - for ($i = 1, $len = count($bytes); $i < $len; $i++) - { - $value = hexdec($bytes[$i]); - - // If we're the first byte of sequence: - if (!$remaining) - { - // Start position - $start = $i; - - // By default we are valid - $valid = true; - - // One byte sequence: - if ($value <= 0x7F) - { - $character = $value; - $length = 1; - } - // Two byte sequence: - elseif (($value & 0xE0) === 0xC0) - { - $character = ($value & 0x1F) << 6; - $length = 2; - $remaining = 1; - } - // Three byte sequence: - elseif (($value & 0xF0) === 0xE0) - { - $character = ($value & 0x0F) << 12; - $length = 3; - $remaining = 2; - } - // Four byte sequence: - elseif (($value & 0xF8) === 0xF0) - { - $character = ($value & 0x07) << 18; - $length = 4; - $remaining = 3; - } - // Invalid byte: - else - { - $valid = false; - $remaining = 0; - } - } - // Continuation byte: - else - { - // Check that the byte is valid, then add it to the character: - if (($value & 0xC0) === 0x80) - { - $remaining--; - $character |= ($value & 0x3F) << ($remaining * 6); - } - // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: - else - { - $valid = false; - $remaining = 0; - $i--; - } - } - - // If we've reached the end of the current byte sequence, append it to Unicode::$data - if (!$remaining) - { - // Percent encode anything invalid or not in iunreserved - if ( - // Invalid sequences - !$valid - // Non-shortest form sequences are invalid - || $length > 1 && $character <= 0x7F - || $length > 2 && $character <= 0x7FF - || $length > 3 && $character <= 0xFFFF - // Outside of range of iunreserved codepoints - || $character < 0x2D - || $character > 0xEFFFD - // Noncharacters - || ($character & 0xFFFE) === 0xFFFE - || $character >= 0xFDD0 && $character <= 0xFDEF - // Everything else not in iunreserved (this is all BMP) - || $character === 0x2F - || $character > 0x39 && $character < 0x41 - || $character > 0x5A && $character < 0x61 - || $character > 0x7A && $character < 0x7E - || $character > 0x7E && $character < 0xA0 - || $character > 0xD7FF && $character < 0xF900 - ) - { - for ($j = $start; $j <= $i; $j++) - { - $string .= '%' . strtoupper($bytes[$j]); - } - } - else - { - for ($j = $start; $j <= $i; $j++) - { - $string .= chr(hexdec($bytes[$j])); - } - } - } - } - - // If we have any bytes left over they are invalid (i.e., we are - // mid-way through a multi-byte sequence) - if ($remaining) - { - for ($j = $start; $j < $len; $j++) - { - $string .= '%' . strtoupper($bytes[$j]); - } - } - - return $string; - } - - protected function scheme_normalization() - { - if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) - { - $this->iuserinfo = null; - } - if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) - { - $this->ihost = null; - } - if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) - { - $this->port = null; - } - if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) - { - $this->ipath = ''; - } - if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) - { - $this->iquery = null; - } - if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) - { - $this->ifragment = null; - } - } - - /** - * Check if the object represents a valid IRI. This needs to be done on each - * call as some things change depending on another part of the IRI. - * - * @return bool - */ - public function is_valid() - { - $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; - if ($this->ipath !== '' && - ( - $isauthority && ( - $this->ipath[0] !== '/' || - substr($this->ipath, 0, 2) === '//' - ) || - ( - $this->scheme === null && - !$isauthority && - strpos($this->ipath, ':') !== false && - (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) - ) - ) - ) - { - return false; - } - - return true; - } - - /** - * Set the entire IRI. Returns true on success, false on failure (if there - * are any invalid characters). - * - * @param string $iri - * @return bool - */ - protected function set_iri($iri) - { - static $cache; - if (!$cache) - { - $cache = array(); - } - - if ($iri === null) - { - return true; - } - elseif (isset($cache[$iri])) - { - list($this->scheme, - $this->iuserinfo, - $this->ihost, - $this->port, - $this->ipath, - $this->iquery, - $this->ifragment, - $return) = $cache[$iri]; - return $return; - } - else - { - $parsed = $this->parse_iri((string) $iri); - - $return = $this->set_scheme($parsed['scheme']) - && $this->set_authority($parsed['authority']) - && $this->set_path($parsed['path']) - && $this->set_query($parsed['query']) - && $this->set_fragment($parsed['fragment']); - - $cache[$iri] = array($this->scheme, - $this->iuserinfo, - $this->ihost, - $this->port, - $this->ipath, - $this->iquery, - $this->ifragment, - $return); - return $return; - } - } - - /** - * Set the scheme. Returns true on success, false on failure (if there are - * any invalid characters). - * - * @param string $scheme - * @return bool - */ - protected function set_scheme($scheme) - { - if ($scheme === null) - { - $this->scheme = null; - } - elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) - { - $this->scheme = null; - return false; - } - else - { - $this->scheme = strtolower($scheme); - } - return true; - } - - /** - * Set the authority. Returns true on success, false on failure (if there are - * any invalid characters). - * - * @param string $authority - * @return bool - */ - protected function set_authority($authority) - { - static $cache; - if (!$cache) - $cache = array(); - - if ($authority === null) - { - $this->iuserinfo = null; - $this->ihost = null; - $this->port = null; - return true; - } - elseif (isset($cache[$authority])) - { - list($this->iuserinfo, - $this->ihost, - $this->port, - $return) = $cache[$authority]; - - return $return; - } - else - { - $remaining = $authority; - if (($iuserinfo_end = strrpos($remaining, '@')) !== false) - { - $iuserinfo = substr($remaining, 0, $iuserinfo_end); - $remaining = substr($remaining, $iuserinfo_end + 1); - } - else - { - $iuserinfo = null; - } - if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) - { - if (($port = substr($remaining, $port_start + 1)) === false) - { - $port = null; - } - $remaining = substr($remaining, 0, $port_start); - } - else - { - $port = null; - } - - $return = $this->set_userinfo($iuserinfo) && - $this->set_host($remaining) && - $this->set_port($port); - - $cache[$authority] = array($this->iuserinfo, - $this->ihost, - $this->port, - $return); - - return $return; - } - } - - /** - * Set the iuserinfo. - * - * @param string $iuserinfo - * @return bool - */ - protected function set_userinfo($iuserinfo) - { - if ($iuserinfo === null) - { - $this->iuserinfo = null; - } - else - { - $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); - $this->scheme_normalization(); - } - - return true; - } - - /** - * Set the ihost. Returns true on success, false on failure (if there are - * any invalid characters). - * - * @param string $ihost - * @return bool - */ - protected function set_host($ihost) - { - if ($ihost === null) - { - $this->ihost = null; - return true; - } - elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') - { - if (Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) - { - $this->ihost = '[' . Requests_IPv6::compress(substr($ihost, 1, -1)) . ']'; - } - else - { - $this->ihost = null; - return false; - } - } - else - { - $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); - - // Lowercase, but ignore pct-encoded sections (as they should - // remain uppercase). This must be done after the previous step - // as that can add unescaped characters. - $position = 0; - $strlen = strlen($ihost); - while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) - { - if ($ihost[$position] === '%') - { - $position += 3; - } - else - { - $ihost[$position] = strtolower($ihost[$position]); - $position++; - } - } - - $this->ihost = $ihost; - } - - $this->scheme_normalization(); - - return true; - } - - /** - * Set the port. Returns true on success, false on failure (if there are - * any invalid characters). - * - * @param string $port - * @return bool - */ - protected function set_port($port) - { - if ($port === null) - { - $this->port = null; - return true; - } - elseif (strspn($port, '0123456789') === strlen($port)) - { - $this->port = (int) $port; - $this->scheme_normalization(); - return true; - } - else - { - $this->port = null; - return false; - } - } - - /** - * Set the ipath. - * - * @param string $ipath - * @return bool - */ - protected function set_path($ipath) - { - static $cache; - if (!$cache) - { - $cache = array(); - } - - $ipath = (string) $ipath; - - if (isset($cache[$ipath])) - { - $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; - } - else - { - $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); - $removed = $this->remove_dot_segments($valid); - - $cache[$ipath] = array($valid, $removed); - $this->ipath = ($this->scheme !== null) ? $removed : $valid; - } - - $this->scheme_normalization(); - return true; - } - - /** - * Set the iquery. - * - * @param string $iquery - * @return bool - */ - protected function set_query($iquery) - { - if ($iquery === null) - { - $this->iquery = null; - } - else - { - $this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); - $this->scheme_normalization(); - } - return true; - } - - /** - * Set the ifragment. - * - * @param string $ifragment - * @return bool - */ - protected function set_fragment($ifragment) - { - if ($ifragment === null) - { - $this->ifragment = null; - } - else - { - $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); - $this->scheme_normalization(); - } - return true; - } - - /** - * Convert an IRI to a URI (or parts thereof) - * - * @return string - */ - protected function to_uri($string) - { - static $non_ascii; - if (!$non_ascii) - { - $non_ascii = implode('', range("\x80", "\xFF")); - } - - $position = 0; - $strlen = strlen($string); - while (($position += strcspn($string, $non_ascii, $position)) < $strlen) - { - $string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); - $position += 3; - $strlen += 2; - } - - return $string; - } - - /** - * Get the complete IRI - * - * @return string - */ - protected function get_iri() - { - if (!$this->is_valid()) - { - return false; - } - - $iri = ''; - if ($this->scheme !== null) - { - $iri .= $this->scheme . ':'; - } - if (($iauthority = $this->get_iauthority()) !== null) - { - $iri .= '//' . $iauthority; - } - $iri .= $this->ipath; - if ($this->iquery !== null) - { - $iri .= '?' . $this->iquery; - } - if ($this->ifragment !== null) - { - $iri .= '#' . $this->ifragment; - } - - return $iri; - } - - /** - * Get the complete URI - * - * @return string - */ - protected function get_uri() - { - return $this->to_uri($this->get_iri()); - } - - /** - * Get the complete iauthority - * - * @return string - */ - protected function get_iauthority() - { - if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null) - { - $iauthority = ''; - if ($this->iuserinfo !== null) - { - $iauthority .= $this->iuserinfo . '@'; - } - if ($this->ihost !== null) - { - $iauthority .= $this->ihost; - } - if ($this->port !== null) - { - $iauthority .= ':' . $this->port; - } - return $iauthority; - } - else - { - return null; - } - } - - /** - * Get the complete authority - * - * @return string - */ - protected function get_authority() - { - $iauthority = $this->get_iauthority(); - if (is_string($iauthority)) - return $this->to_uri($iauthority); - else - return $iauthority; - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cURL.php b/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cURL.php deleted file mode 100755 index c0465c4..0000000 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cURL.php +++ /dev/null @@ -1,351 +0,0 @@ -version = $curl['version']; - $this->fp = curl_init(); - - curl_setopt($this->fp, CURLOPT_HEADER, false); - curl_setopt($this->fp, CURLOPT_RETURNTRANSFER, 1); - if (version_compare($this->version, '7.10.5', '>=')) { - curl_setopt($this->fp, CURLOPT_ENCODING, ''); - } - if (defined('CURLOPT_PROTOCOLS')) { - curl_setopt($this->fp, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($this->fp, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - } - - /** - * Perform a request - * - * @throws Requests_Exception On a cURL error (`curlerror`) - * - * @param string $url URL to request - * @param array $headers Associative array of request headers - * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD - * @param array $options Request options, see {@see Requests::response()} for documentation - * @return string Raw HTTP result - */ - public function request($url, $headers = array(), $data = array(), $options = array()) { - $this->setup_handle($url, $headers, $data, $options); - - $options['hooks']->dispatch('curl.before_send', array(&$this->fp)); - - if ($options['filename'] !== false) { - $this->stream_handle = fopen($options['filename'], 'wb'); - curl_setopt($this->fp, CURLOPT_FILE, $this->stream_handle); - } - - if (isset($options['verify'])) { - if ($options['verify'] === false) { - curl_setopt($this->fp, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($this->fp, CURLOPT_SSL_VERIFYPEER, 0); - - } elseif (is_string($options['verify'])) { - curl_setopt($this->fp, CURLOPT_CAINFO, $options['verify']); - } - } - - if (isset($options['verifyname']) && $options['verifyname'] === false) { - curl_setopt($this->fp, CURLOPT_SSL_VERIFYHOST, 0); - } - - $response = curl_exec($this->fp); - - $options['hooks']->dispatch('curl.after_send', array(&$fake_headers)); - - if (curl_errno($this->fp) === 23 || curl_errno($this->fp) === 61) { - curl_setopt($this->fp, CURLOPT_ENCODING, 'none'); - $response = curl_exec($this->fp); - } - - $this->process_response($response, $options); - curl_close($this->fp); - return $this->headers; - } - - /** - * Send multiple requests simultaneously - * - * @param array $requests Request data - * @param array $options Global options - * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well) - */ - public function request_multiple($requests, $options) { - $multihandle = curl_multi_init(); - $subrequests = array(); - $subhandles = array(); - - $class = get_class($this); - foreach ($requests as $id => $request) { - $subrequests[$id] = new $class(); - $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']); - $request['options']['hooks']->dispatch('curl.before_multi_add', array(&$subhandles[$id])); - curl_multi_add_handle($multihandle, $subhandles[$id]); - } - - $completed = 0; - $responses = array(); - - $request['options']['hooks']->dispatch('curl.before_multi_exec', array(&$multihandle)); - - do { - $active = false; - - do { - $status = curl_multi_exec($multihandle, $active); - } - while ($status === CURLM_CALL_MULTI_PERFORM); - - $to_process = array(); - - // Read the information as needed - while ($done = curl_multi_info_read($multihandle)) { - $key = array_search($done['handle'], $subhandles, true); - if (!isset($to_process[$key])) { - $to_process[$key] = $done; - } - } - - // Parse the finished requests before we start getting the new ones - foreach ($to_process as $key => $done) { - $options = $requests[$key]['options']; - $responses[$key] = $subrequests[$key]->process_response(curl_multi_getcontent($done['handle']), $options); - - $options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key])); - - curl_multi_remove_handle($multihandle, $done['handle']); - curl_close($done['handle']); - - if (!is_string($responses[$key])) { - $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); - } - $completed++; - } - } - while ($active || $completed < count($subrequests)); - - $request['options']['hooks']->dispatch('curl.after_multi_exec', array(&$multihandle)); - - curl_multi_close($multihandle); - - return $responses; - } - - /** - * Get the cURL handle for use in a multi-request - * - * @param string $url URL to request - * @param array $headers Associative array of request headers - * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD - * @param array $options Request options, see {@see Requests::response()} for documentation - * @return resource Subrequest's cURL handle - */ - public function &get_subrequest_handle($url, $headers, $data, $options) { - $this->setup_handle($url, $headers, $data, $options); - - if ($options['filename'] !== false) { - $this->stream_handle = fopen($options['filename'], 'wb'); - curl_setopt($this->fp, CURLOPT_FILE, $this->stream_handle); - } - - return $this->fp; - } - - /** - * Setup the cURL handle for the given data - * - * @param string $url URL to request - * @param array $headers Associative array of request headers - * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD - * @param array $options Request options, see {@see Requests::response()} for documentation - */ - protected function setup_handle($url, $headers, $data, $options) { - $options['hooks']->dispatch('curl.before_request', array(&$this->fp)); - - $headers = Requests::flatten($headers); - if (in_array($options['type'], array(Requests::HEAD, Requests::GET, Requests::DELETE)) & !empty($data)) { - $url = self::format_get($url, $data); - } - elseif (!empty($data) && !is_string($data)) { - $data = http_build_query($data, null, '&'); - } - - switch ($options['type']) { - case Requests::POST: - curl_setopt($this->fp, CURLOPT_POST, true); - curl_setopt($this->fp, CURLOPT_POSTFIELDS, $data); - break; - case Requests::PATCH: - case Requests::PUT: - curl_setopt($this->fp, CURLOPT_CUSTOMREQUEST, $options['type']); - curl_setopt($this->fp, CURLOPT_POSTFIELDS, $data); - break; - case Requests::DELETE: - curl_setopt($this->fp, CURLOPT_CUSTOMREQUEST, 'DELETE'); - break; - case Requests::HEAD: - curl_setopt($this->fp, CURLOPT_NOBODY, true); - break; - } - - curl_setopt($this->fp, CURLOPT_URL, $url); - curl_setopt($this->fp, CURLOPT_TIMEOUT, $options['timeout']); - curl_setopt($this->fp, CURLOPT_CONNECTTIMEOUT, $options['timeout']); - curl_setopt($this->fp, CURLOPT_REFERER, $url); - curl_setopt($this->fp, CURLOPT_USERAGENT, $options['useragent']); - curl_setopt($this->fp, CURLOPT_HTTPHEADER, $headers); - - if (true === $options['blocking']) { - curl_setopt($this->fp, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); - } - } - - public function process_response($response, $options) { - if ($options['blocking'] === false) { - $fake_headers = ''; - $options['hooks']->dispatch('curl.after_request', array(&$fake_headers)); - return false; - } - if ($options['filename'] !== false) { - fclose($this->stream_handle); - $this->headers = trim($this->headers); - } - else { - $this->headers .= $response; - } - - if (curl_errno($this->fp)) { - throw new Requests_Exception('cURL error ' . curl_errno($this->fp) . ': ' . curl_error($this->fp), 'curlerror', $this->fp); - return; - } - $this->info = curl_getinfo($this->fp); - - $options['hooks']->dispatch('curl.after_request', array(&$this->headers)); - return $this->headers; - } - - /** - * Collect the headers as they are received - * - * @param resource $handle cURL resource - * @param string $headers Header string - * @return integer Length of provided header - */ - protected function stream_headers($handle, $headers) { - // Why do we do this? cURL will send both the final response and any - // interim responses, such as a 100 Continue. We don't need that. - // (We may want to keep this somewhere just in case) - if ($this->done_headers) { - $this->headers = ''; - $this->done_headers = false; - } - $this->headers .= $headers; - - if ($headers === "\r\n") { - $this->done_headers = true; - } - return strlen($headers); - } - - /** - * Format a URL given GET data - * - * @param string $url - * @param array|object $data Data to build query using, see {@see http://php.net/http_build_query} - * @return string URL with data - */ - protected static function format_get($url, $data) { - if (!empty($data)) { - $url_parts = parse_url($url); - if (empty($url_parts['query'])) { - $query = $url_parts['query'] = ''; - } - else { - $query = $url_parts['query']; - } - - $query .= '&' . http_build_query($data, null, '&'); - $query = trim($query, '&'); - - if (empty($url_parts['query'])) { - $url .= '?' . $query; - } - else { - $url = str_replace($url_parts['query'], $query, $url); - } - } - return $url; - } - - /** - * Whether this transport is valid - * - * @codeCoverageIgnore - * @return boolean True if the transport is valid, false otherwise. - */ - public static function test() { - return (function_exists('curl_init') && function_exists('curl_exec')); - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Auth/Basic.php b/razorpay-php/libs/Requests-1.6.1/tests/Auth/Basic.php deleted file mode 100755 index 9f19014..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Auth/Basic.php +++ /dev/null @@ -1,87 +0,0 @@ -markTestSkipped($transport . ' is not available'); - return; - } - - $options = array( - 'auth' => array('user', 'passwd'), - 'transport' => $transport, - ); - $request = Requests::get('http://httpbin.org/basic-auth/user/passwd', array(), $options); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body); - $this->assertEquals(true, $result->authenticated); - $this->assertEquals('user', $result->user); - } - - /** - * @dataProvider transportProvider - */ - public function testUsingInstantiation($transport) { - if (!call_user_func(array($transport, 'test'))) { - $this->markTestSkipped($transport . ' is not available'); - return; - } - - $options = array( - 'auth' => new Requests_Auth_Basic(array('user', 'passwd')), - 'transport' => $transport, - ); - $request = Requests::get('http://httpbin.org/basic-auth/user/passwd', array(), $options); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body); - $this->assertEquals(true, $result->authenticated); - $this->assertEquals('user', $result->user); - } - - /** - * @dataProvider transportProvider - */ - public function testPOSTUsingInstantiation($transport) { - if (!call_user_func(array($transport, 'test'))) { - $this->markTestSkipped($transport . ' is not available'); - return; - } - - $options = array( - 'auth' => new Requests_Auth_Basic(array('user', 'passwd')), - 'transport' => $transport, - ); - $data = 'test'; - $request = Requests::post('http://httpbin.org/post', array(), $data, $options); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body); - - $auth = $result->headers->Authorization; - $auth = explode(' ', $auth); - - $this->assertEquals(base64_encode('user:passwd'), $auth[1]); - $this->assertEquals('test', $result->data); - } - - /** - * @expectedException Requests_Exception - */ - public function testMissingPassword() { - $auth = new Requests_Auth_Basic(array('user')); - } - -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/ChunkedEncoding.php b/razorpay-php/libs/Requests-1.6.1/tests/ChunkedEncoding.php deleted file mode 100755 index fa87538..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/ChunkedEncoding.php +++ /dev/null @@ -1,68 +0,0 @@ -body = $body; - $transport->chunked = true; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - - $this->assertEquals($expected, $response->body); - } - - /** - * Response says it's chunked, but actually isn't - */ - public function testNotActuallyChunked() { - $transport = new MockTransport(); - $transport->body = 'Hello! This is a non-chunked response!'; - $transport->chunked = true; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - - $this->assertEquals($transport->body, $response->body); - } - - /** - * Response says it's chunked and starts looking like it is, but turns out - * that they're lying to us - */ - public function testMixedChunkiness() { - $transport = new MockTransport(); - $transport->body = "02\r\nab\r\nNot actually chunked!"; - $transport->chunked = true; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - $this->assertEquals($transport->body, $response->body); - } -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Cookies.php b/razorpay-php/libs/Requests-1.6.1/tests/Cookies.php deleted file mode 100755 index 0348fd8..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Cookies.php +++ /dev/null @@ -1,174 +0,0 @@ -assertEquals('requests-testcookie', $cookie->name); - $this->assertEquals('testvalue', $cookie->value); - $this->assertEquals('testvalue', (string) $cookie); - - $this->assertEquals('requests-testcookie=testvalue', $cookie->formatForHeader()); - $this->assertEquals('requests-testcookie=testvalue', $cookie->formatForSetCookie()); - } - - public function testCookieWithAttributes() { - $attributes = array( - 'httponly', - 'path' => '/' - ); - $cookie = new Requests_Cookie('requests-testcookie', 'testvalue', $attributes); - - $this->assertEquals('requests-testcookie=testvalue', $cookie->formatForHeader()); - $this->assertEquals('requests-testcookie=testvalue; httponly; path=/', $cookie->formatForSetCookie()); - } - - public function testEmptyCookieName() { - $cookie = Requests_Cookie::parse('test'); - $this->assertEquals('', $cookie->name); - $this->assertEquals('test', $cookie->value); - } - - public function testEmptyAttributes() { - $cookie = Requests_Cookie::parse('foo=bar; HttpOnly'); - $this->assertTrue($cookie->attributes['httponly']); - } - - public function testCookieJarSetter() { - $jar1 = new Requests_Cookie_Jar(); - $jar1['requests-testcookie'] = 'testvalue'; - - $jar2 = new Requests_Cookie_Jar(array( - 'requests-testcookie' => 'testvalue', - )); - $this->assertEquals($jar1, $jar2); - } - - public function testCookieJarUnsetter() { - $jar = new Requests_Cookie_Jar(); - $jar['requests-testcookie'] = 'testvalue'; - - $this->assertEquals('testvalue', $jar['requests-testcookie']); - - unset($jar['requests-testcookie']); - $this->assertEmpty($jar['requests-testcookie']); - $this->assertFalse(isset($jar['requests-testcookie'])); - } - - /** - * @expectedException Requests_Exception - */ - public function testCookieJarAsList() { - $cookies = new Requests_Cookie_Jar(); - $cookies[] = 'requests-testcookie1=testvalue1'; - } - - public function testCookieJarIterator() { - $cookies = array( - 'requests-testcookie1' => 'testvalue1', - 'requests-testcookie2' => 'testvalue2', - ); - $jar = new Requests_Cookie_Jar($cookies); - - foreach ($jar as $key => $value) { - $this->assertEquals($cookies[$key], $value); - } - } - - public function testReceivingCookies() { - $options = array( - 'follow_redirects' => false, - ); - $url = 'http://httpbin.org/cookies/set?requests-testcookie=testvalue'; - - $response = Requests::get($url, array(), $options); - - $cookie = $response->cookies['requests-testcookie']; - $this->assertNotEmpty( $cookie ); - $this->assertEquals( 'testvalue', $cookie->value ); - } - - public function testPersistenceOnRedirect() { - $options = array( - 'follow_redirects' => true, - ); - $url = 'http://httpbin.org/cookies/set?requests-testcookie=testvalue'; - - $response = Requests::get($url, array(), $options); - - $cookie = $response->cookies['requests-testcookie']; - $this->assertNotEmpty( $cookie ); - $this->assertEquals( 'testvalue', $cookie->value ); - } - - protected function setCookieRequest($cookies) { - $options = array( - 'cookies' => $cookies, - ); - $response = Requests::get('http://httpbin.org/cookies/set', array(), $options); - - $data = json_decode($response->body, true); - $this->assertInternalType('array', $data); - $this->assertArrayHasKey('cookies', $data); - return $data['cookies']; - } - - public function testSendingCookie() { - $cookies = array( - 'requests-testcookie1' => 'testvalue1', - ); - - $data = $this->setCookieRequest($cookies); - - $this->assertArrayHasKey('requests-testcookie1', $data); - $this->assertEquals('testvalue1', $data['requests-testcookie1']); - } - - public function testSendingCookieWithJar() { - $cookies = new Requests_Cookie_Jar(array( - 'requests-testcookie1' => 'testvalue1', - )); - $data = $this->setCookieRequest($cookies); - - $this->assertArrayHasKey('requests-testcookie1', $data); - $this->assertEquals('testvalue1', $data['requests-testcookie1']); - } - - public function testSendingMultipleCookies() { - $cookies = array( - 'requests-testcookie1' => 'testvalue1', - 'requests-testcookie2' => 'testvalue2', - ); - $data = $this->setCookieRequest($cookies); - - $this->assertArrayHasKey('requests-testcookie1', $data); - $this->assertEquals('testvalue1', $data['requests-testcookie1']); - - $this->assertArrayHasKey('requests-testcookie2', $data); - $this->assertEquals('testvalue2', $data['requests-testcookie2']); - } - - public function testSendingMultipleCookiesWithJar() { - $cookies = new Requests_Cookie_Jar(array( - 'requests-testcookie1' => 'testvalue1', - 'requests-testcookie2' => 'testvalue2', - )); - $data = $this->setCookieRequest($cookies); - - $this->assertArrayHasKey('requests-testcookie1', $data); - $this->assertEquals('testvalue1', $data['requests-testcookie1']); - - $this->assertArrayHasKey('requests-testcookie2', $data); - $this->assertEquals('testvalue2', $data['requests-testcookie2']); - } - - public function testSendingPrebakedCookie() { - $cookies = new Requests_Cookie_Jar(array( - new Requests_Cookie('requests-testcookie', 'testvalue'), - )); - $data = $this->setCookieRequest($cookies); - - $this->assertArrayHasKey('requests-testcookie', $data); - $this->assertEquals('testvalue', $data['requests-testcookie']); - } -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Encoding.php b/razorpay-php/libs/Requests-1.6.1/tests/Encoding.php deleted file mode 100644 index 7e2f138..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Encoding.php +++ /dev/null @@ -1,94 +0,0 @@ - $set) { - $real_set = self::mapData($key, $set); - $data = array_merge($data, $real_set); - } - return $data; - } - - /** - * @dataProvider encodedData - */ - public function testDecompress($original, $encoded) { - $decoded = Requests::decompress($encoded); - $this->assertEquals($original, $decoded); - } - - /** - * @dataProvider encodedData - */ - public function testCompatibleInflate($original, $encoded) { - $decoded = Requests::compatible_gzinflate($encoded); - $this->assertEquals($original, $decoded); - } - - protected function bin2hex($field) { - $field = bin2hex($field); - $field = chunk_split($field,2,"\\x"); - $field = "\\x" . substr($field,0,-2); - return $field; - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/IDNAEncoder.php b/razorpay-php/libs/Requests-1.6.1/tests/IDNAEncoder.php deleted file mode 100755 index 24df2de..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/IDNAEncoder.php +++ /dev/null @@ -1,102 +0,0 @@ -assertEquals($expected, $result); - } - - /** - * @expectedException Requests_Exception - */ - public function testASCIITooLong() { - $data = str_repeat("abcd", 20); - $result = Requests_IDNAEncoder::encode($data); - } - - /** - * @expectedException Requests_Exception - */ - public function testEncodedTooLong() { - $data = str_repeat("\xe4\xbb\x96", 60); - $result = Requests_IDNAEncoder::encode($data); - } - - /** - * @expectedException Requests_Exception - */ - public function testAlreadyPrefixed() { - $result = Requests_IDNAEncoder::encode("xn--\xe4\xbb\x96"); - } - - public function testASCIICharacter() { - $result = Requests_IDNAEncoder::encode("a"); - $this->assertEquals('a', $result); - } - - public function testTwoByteCharacter() { - $result = Requests_IDNAEncoder::encode("\xc2\xb6"); // Pilcrow character - $this->assertEquals('xn--tba', $result); - } - - public function testThreeByteCharacter() { - $result = Requests_IDNAEncoder::encode("\xe2\x82\xac"); // Euro symbol - $this->assertEquals('xn--lzg', $result); - } - - public function testFourByteCharacter() { - $result = Requests_IDNAEncoder::encode("\xf0\xa4\xad\xa2"); // Chinese symbol? - $this->assertEquals('xn--ww6j', $result); - } - - /** - * @expectedException Requests_Exception - */ - public function testFiveByteCharacter() { - $result = Requests_IDNAEncoder::encode("\xfb\xb6\xb6\xb6\xb6"); - } - - /** - * @expectedException Requests_Exception - */ - public function testSixByteCharacter() { - $result = Requests_IDNAEncoder::encode("\xfd\xb6\xb6\xb6\xb6\xb6"); - } - - /** - * @expectedException Requests_Exception - */ - public function testInvalidASCIICharacterWithMultibyte() { - $result = Requests_IDNAEncoder::encode("\0\xc2\xb6"); - } - - /** - * @expectedException Requests_Exception - */ - public function testUnfinishedMultibyte() { - $result = Requests_IDNAEncoder::encode("\xc2"); - } - - /** - * @expectedException Requests_Exception - */ - public function testPartialMultibyte() { - $result = Requests_IDNAEncoder::encode("\xc2\xc2\xb6"); - } -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/IRI.php b/razorpay-php/libs/Requests-1.6.1/tests/IRI.php deleted file mode 100755 index db0fef4..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/IRI.php +++ /dev/null @@ -1,418 +0,0 @@ -assertEquals($expected, Requests_IRI::absolutize($base, $relative)->iri); - $this->assertEquals($expected, (string) Requests_IRI::absolutize($base, $relative)); - } - - /** - * @dataProvider rfc3986_tests - */ - public function testBothStringRFC3986($relative, $expected) - { - $base = 'http://a/b/c/d;p?q'; - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)->iri); - $this->assertEquals($expected, (string) Requests_IRI::absolutize($base, $relative)); - } - - /** - * @dataProvider rfc3986_tests - */ - public function testObjectRFC3986($relative, $expected) - { - $base = new Requests_IRI('http://a/b/c/d;p?q'); - $expected = new Requests_IRI($expected); - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)); - } - - public static function sp_tests() - { - return array( - array('http://a/b/c/d', 'f%0o', 'http://a/b/c/f%250o'), - array('http://a/b/', 'c', 'http://a/b/c'), - array('http://a/', 'b', 'http://a/b'), - array('http://a/', '/b', 'http://a/b'), - array('http://a/b', 'c', 'http://a/c'), - array('http://a/b/', "c\x0Ad", 'http://a/b/c%0Ad'), - array('http://a/b/', "c\x0A\x0B", 'http://a/b/c%0A%0B'), - array('http://a/b/c', '//0', 'http://0'), - array('http://a/b/c', '0', 'http://a/b/0'), - array('http://a/b/c', '?0', 'http://a/b/c?0'), - array('http://a/b/c', '#0', 'http://a/b/c#0'), - array('http://0/b/c', 'd', 'http://0/b/d'), - array('http://a/b/c?0', 'd', 'http://a/b/d'), - array('http://a/b/c#0', 'd', 'http://a/b/d'), - array('http://example.com', '//example.net', 'http://example.net'), - array('http:g', 'a', 'http:a'), - ); - } - - /** - * @dataProvider sp_tests - */ - public function testStringSP($base, $relative, $expected) - { - $base = new Requests_IRI($base); - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)->iri); - $this->assertEquals($expected, (string) Requests_IRI::absolutize($base, $relative)); - } - - /** - * @dataProvider sp_tests - */ - public function testObjectSP($base, $relative, $expected) - { - $base = new Requests_IRI($base); - $expected = new Requests_IRI($expected); - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)); - } - - public static function absolutize_tests() - { - return array( - array('http://example.com/', 'foo/111:bar', 'http://example.com/foo/111:bar'), - array('http://example.com/#foo', '', 'http://example.com'), - ); - } - - /** - * @dataProvider absolutize_tests - */ - public function testAbsolutizeString($base, $relative, $expected) - { - $base = new Requests_IRI($base); - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)->iri); - } - - /** - * @dataProvider absolutize_tests - */ - public function testAbsolutizeObject($base, $relative, $expected) - { - $base = new Requests_IRI($base); - $expected = new Requests_IRI($expected); - $this->assertEquals($expected, Requests_IRI::absolutize($base, $relative)); - } - - public static function normalization_tests() - { - return array( - array('example://a/b/c/%7Bfoo%7D', 'example://a/b/c/%7Bfoo%7D'), - array('eXAMPLE://a/./b/../b/%63/%7bfoo%7d', 'example://a/b/c/%7Bfoo%7D'), - array('example://%61/', 'example://a/'), - array('example://%41/', 'example://a/'), - array('example://A/', 'example://a/'), - array('example://a/', 'example://a/'), - array('example://%25A/', 'example://%25a/'), - array('HTTP://EXAMPLE.com/', 'http://example.com'), - array('http://example.com/', 'http://example.com'), - array('http://example.com:', 'http://example.com'), - array('http://example.com:80', 'http://example.com'), - array('http://@example.com', 'http://@example.com'), - array('http://', 'http://'), - array('http://example.com?', 'http://example.com?'), - array('http://example.com#', 'http://example.com#'), - array('https://example.com/', 'https://example.com'), - array('https://example.com:', 'https://example.com'), - array('https://@example.com', 'https://@example.com'), - array('https://example.com?', 'https://example.com?'), - array('https://example.com#', 'https://example.com#'), - array('file://localhost/foobar', 'file:/foobar'), - array('http://[0:0:0:0:0:0:0:1]', 'http://[::1]'), - array('http://[2001:db8:85a3:0000:0000:8a2e:370:7334]', 'http://[2001:db8:85a3::8a2e:370:7334]'), - array('http://[0:0:0:0:0:ffff:c0a8:a01]', 'http://[::ffff:c0a8:a01]'), - array('http://[ffff:0:0:0:0:0:0:0]', 'http://[ffff::]'), - array('http://[::ffff:192.0.2.128]', 'http://[::ffff:192.0.2.128]'), - array('http://[invalid]', 'http:'), - array('http://[0:0:0:0:0:0:0:1]:', 'http://[::1]'), - array('http://[0:0:0:0:0:0:0:1]:80', 'http://[::1]'), - array('http://[0:0:0:0:0:0:0:1]:1234', 'http://[::1]:1234'), - // Punycode decoding helps with normalisation of IRIs, but is not - // needed for URIs, so we don't really care about it for Requests - //array('http://xn--tdali-d8a8w.lv', 'http://tūdaliņ.lv'), - //array('http://t%C5%ABdali%C5%86.lv', 'http://tūdaliņ.lv'), - array('http://Aa@example.com', 'http://Aa@example.com'), - array('http://example.com?Aa', 'http://example.com?Aa'), - array('http://example.com/Aa', 'http://example.com/Aa'), - array('http://example.com#Aa', 'http://example.com#Aa'), - array('http://[0:0:0:0:0:0:0:0]', 'http://[::]'), - array('http:.', 'http:'), - array('http:..', 'http:'), - array('http:./', 'http:'), - array('http:../', 'http:'), - array('http://example.com/%3A', 'http://example.com/%3A'), - array('http://example.com/:', 'http://example.com/:'), - array('http://example.com/%C2', 'http://example.com/%C2'), - array('http://example.com/%C2a', 'http://example.com/%C2a'), - array('http://example.com/%C2%00', 'http://example.com/%C2%00'), - array('http://example.com/%C3%A9', 'http://example.com/é'), - array('http://example.com/%C3%A9%00', 'http://example.com/é%00'), - array('http://example.com/%C3%A9cole', 'http://example.com/école'), - array('http://example.com/%FF', 'http://example.com/%FF'), - array("http://example.com/\xF3\xB0\x80\x80", 'http://example.com/%F3%B0%80%80'), - array("http://example.com/\xF3\xB0\x80\x80%00", 'http://example.com/%F3%B0%80%80%00'), - array("http://example.com/\xF3\xB0\x80\x80a", 'http://example.com/%F3%B0%80%80a'), - array("http://example.com?\xF3\xB0\x80\x80", "http://example.com?\xF3\xB0\x80\x80"), - array("http://example.com?\xF3\xB0\x80\x80%00", "http://example.com?\xF3\xB0\x80\x80%00"), - array("http://example.com?\xF3\xB0\x80\x80a", "http://example.com?\xF3\xB0\x80\x80a"), - array("http://example.com/\xEE\x80\x80", 'http://example.com/%EE%80%80'), - array("http://example.com/\xEE\x80\x80%00", 'http://example.com/%EE%80%80%00'), - array("http://example.com/\xEE\x80\x80a", 'http://example.com/%EE%80%80a'), - array("http://example.com?\xEE\x80\x80", "http://example.com?\xEE\x80\x80"), - array("http://example.com?\xEE\x80\x80%00", "http://example.com?\xEE\x80\x80%00"), - array("http://example.com?\xEE\x80\x80a", "http://example.com?\xEE\x80\x80a"), - array("http://example.com/\xC2", 'http://example.com/%C2'), - array("http://example.com/\xC2a", 'http://example.com/%C2a'), - array("http://example.com/\xC2\x00", 'http://example.com/%C2%00'), - array("http://example.com/\xC3\xA9", 'http://example.com/é'), - array("http://example.com/\xC3\xA9\x00", 'http://example.com/é%00'), - array("http://example.com/\xC3\xA9cole", 'http://example.com/école'), - array("http://example.com/\xFF", 'http://example.com/%FF'), - array("http://example.com/\xFF%00", 'http://example.com/%FF%00'), - array("http://example.com/\xFFa", 'http://example.com/%FFa'), - array('http://example.com/%61', 'http://example.com/a'), - array('http://example.com?%26', 'http://example.com?%26'), - array('http://example.com?%61', 'http://example.com?a'), - array('///', '///'), - ); - } - - /** - * @dataProvider normalization_tests - */ - public function testStringNormalization($input, $output) - { - $input = new Requests_IRI($input); - $this->assertEquals($output, $input->iri); - $this->assertEquals($output, (string) $input); - } - - /** - * @dataProvider normalization_tests - */ - public function testObjectNormalization($input, $output) - { - $input = new Requests_IRI($input); - $output = new Requests_IRI($output); - $this->assertEquals($output, $input); - } - - public static function equivalence_tests() - { - return array( - array('http://É.com', 'http://%C3%89.com'), - ); - } - - /** - * @dataProvider equivalence_tests - */ - public function testObjectEquivalence($input, $output) - { - $input = new Requests_IRI($input); - $output = new Requests_IRI($output); - $this->assertEquals($output, $input); - } - - public static function not_equivalence_tests() - { - return array( - array('http://example.com/foo/bar', 'http://example.com/foo%2Fbar'), - ); - } - - /** - * @dataProvider not_equivalence_tests - */ - public function testObjectNotEquivalence($input, $output) - { - $input = new Requests_IRI($input); - $output = new Requests_IRI($output); - $this->assertNotEquals($output, $input); - } - - public function testInvalidAbsolutizeBase() - { - $this->assertFalse(Requests_IRI::absolutize('://not a URL', '../')); - } - - public function testInvalidAbsolutizeRelative() - { - $this->assertFalse(Requests_IRI::absolutize('http://example.com/', 'http://example.com//not a URL')); - } - - public function testFullGamut() - { - $iri = new Requests_IRI(); - $iri->scheme = 'http'; - $iri->userinfo = 'user:password'; - $iri->host = 'example.com'; - $iri->path = '/test/'; - $iri->fragment = 'test'; - - $this->assertEquals('http', $iri->scheme); - $this->assertEquals('user:password', $iri->userinfo); - $this->assertEquals('example.com', $iri->host); - $this->assertEquals(80, $iri->port); - $this->assertEquals('/test/', $iri->path); - $this->assertEquals('test', $iri->fragment); - } - - public function testReadAliased() - { - $iri = new Requests_IRI(); - $iri->scheme = 'http'; - $iri->userinfo = 'user:password'; - $iri->host = 'example.com'; - $iri->path = '/test/'; - $iri->fragment = 'test'; - - $this->assertEquals('http', $iri->ischeme); - $this->assertEquals('user:password', $iri->iuserinfo); - $this->assertEquals('example.com', $iri->ihost); - $this->assertEquals(80, $iri->iport); - $this->assertEquals('/test/', $iri->ipath); - $this->assertEquals('test', $iri->ifragment); - } - - public function testWriteAliased() - { - $iri = new Requests_IRI(); - $iri->scheme = 'http'; - $iri->iuserinfo = 'user:password'; - $iri->ihost = 'example.com'; - $iri->ipath = '/test/'; - $iri->ifragment = 'test'; - - $this->assertEquals('http', $iri->scheme); - $this->assertEquals('user:password', $iri->userinfo); - $this->assertEquals('example.com', $iri->host); - $this->assertEquals(80, $iri->port); - $this->assertEquals('/test/', $iri->path); - $this->assertEquals('test', $iri->fragment); - } - - /** - * @expectedException PHPUnit_Framework_Error_Notice - */ - public function testNonexistantProperty() - { - $iri = new Requests_IRI(); - $this->assertFalse(isset($iri->nonexistant_prop)); - $should_fail = $iri->nonexistant_prop; - } - - public function testBlankHost() - { - $iri = new Requests_IRI('http://example.com/a/?b=c#d'); - $iri->host = null; - - $this->assertEquals(null, $iri->host); - $this->assertEquals('http:/a/?b=c#d', (string) $iri); - } - - public function testBadPort() - { - $iri = new Requests_IRI(); - $iri->port = 'example'; - - $this->assertEquals(null, $iri->port); - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Requests.php b/razorpay-php/libs/Requests-1.6.1/tests/Requests.php deleted file mode 100755 index e13698e..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Requests.php +++ /dev/null @@ -1,140 +0,0 @@ -assertEquals(200, $request->status_code); - } - - /** - * Standard response header parsing - */ - public function testHeaderParsing() { - $transport = new RawTransport(); - $transport->data = - "HTTP/1.0 200 OK\r\n". - "Host: localhost\r\n". - "Host: ambiguous\r\n". - "Nospace:here\r\n". - "Muchspace: there \r\n". - "Empty:\r\n". - "Empty2: \r\n". - "Folded: one\r\n". - "\ttwo\r\n". - " three\r\n\r\n". - "stop\r\n"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - $expected = new Requests_Response_Headers(); - $expected['host'] = 'localhost,ambiguous'; - $expected['nospace'] = 'here'; - $expected['muchspace'] = 'there'; - $expected['empty'] = ''; - $expected['empty2'] = ''; - $expected['folded'] = 'one two three'; - foreach ($expected as $key => $value) { - $this->assertEquals($value, $response->headers[$key]); - } - - foreach ($response->headers as $key => $value) { - $this->assertEquals($value, $expected[$key]); - } - } - - public function testRawAccess() { - $transport = new RawTransport(); - $transport->data = - "HTTP/1.0 200 OK\r\n". - "Host: localhost\r\n\r\n". - "Test"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - $this->assertEquals($transport->data, $response->raw); - } - - /** - * Headers with only \n delimiting should be treated as if they're \r\n - */ - public function testHeaderOnlyLF() { - $transport = new RawTransport(); - $transport->data = "HTTP/1.0 200 OK\r\nTest: value\nAnother-Test: value\r\n\r\n"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - $this->assertEquals('value', $response->headers['test']); - $this->assertEquals('value', $response->headers['another-test']); - } - - /** - * Check that invalid protocols are not accepted - * - * We do not support HTTP/0.9. If this is really an issue for you, file a - * new issue, and update your server/proxy to support a proper protocol. - * - * @expectedException Requests_Exception - */ - public function testInvalidProtocolVersion() { - $transport = new RawTransport(); - $transport->data = "HTTP/0.9 200 OK\r\n\r\n

Test"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - } - - /** - * HTTP/0.9 also appears to use a single CRLF instead of two - * - * @expectedException Requests_Exception - */ - public function testSingleCRLFSeparator() { - $transport = new RawTransport(); - $transport->data = "HTTP/0.9 200 OK\r\n

Test"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - } - - /** - * @expectedException Requests_Exception - */ - public function testInvalidStatus() { - $transport = new RawTransport(); - $transport->data = "HTTP/1.1 OK\r\nTest: value\nAnother-Test: value\r\n\r\nTest"; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - } - - public function test30xWithoutLocation() { - $transport = new MockTransport(); - $transport->code = 302; - - $options = array( - 'transport' => $transport - ); - $response = Requests::get('http://example.com/', array(), $options); - $this->assertEquals(302, $response->status_code); - $this->assertEquals(0, $response->redirects); - } -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Response/Headers.php b/razorpay-php/libs/Requests-1.6.1/tests/Response/Headers.php deleted file mode 100755 index 7541f37..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Response/Headers.php +++ /dev/null @@ -1,55 +0,0 @@ -assertEquals('text/plain', $headers['Content-Type']); - } - public function testCaseInsensitiveArrayAccess() { - $headers = new Requests_Response_Headers(); - $headers['Content-Type'] = 'text/plain'; - - $this->assertEquals('text/plain', $headers['CONTENT-TYPE']); - $this->assertEquals('text/plain', $headers['content-type']); - } - - /** - * @depends testArrayAccess - */ - public function testIteration() { - $headers = new Requests_Response_Headers(); - $headers['Content-Type'] = 'text/plain'; - $headers['Content-Length'] = 10; - - foreach ($headers as $name => $value) { - switch (strtolower($name)) { - case 'content-type': - $this->assertEquals('text/plain', $value); - break; - case 'content-length': - $this->assertEquals(10, $value); - break; - default: - throw new Exception('Invalid name: ' . $name); - } - } - } - - /** - * @expectedException Requests_Exception - */ - public function testInvalidKey() { - $headers = new Requests_Response_Headers(); - $headers[] = 'text/plain'; - } - - public function testMultipleHeaders() { - $headers = new Requests_Response_Headers(); - $headers['Accept'] = 'text/html;q=1.0'; - $headers['Accept'] = '*/*;q=0.1'; - - $this->assertEquals('text/html;q=1.0,*/*;q=0.1', $headers['Accept']); - } -} \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/tests/SSL.php b/razorpay-php/libs/Requests-1.6.1/tests/SSL.php deleted file mode 100755 index 62bb998..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/SSL.php +++ /dev/null @@ -1,108 +0,0 @@ -assertTrue(Requests_SSL::match_domain($base, $dnsname)); - } - - /** - * @dataProvider domainNoMatchProvider - */ - public function testNoMatch($base, $dnsname) { - $this->assertFalse(Requests_SSL::match_domain($base, $dnsname)); - } - - protected function fakeCertificate($dnsname, $with_san = true) { - $certificate = array( - 'subject' => array( - 'CN' => $dnsname - ), - ); - - if ($with_san !== false) { - // If SAN is set to true, default it to the dNSName - if ($with_san === true) { - $with_san = $dnsname; - } - $certificate['extensions'] = array( - 'subjectAltName' => 'DNS: ' . $with_san, - ); - } - - return $certificate; - } - - /** - * @dataProvider domainMatchProvider - */ - public function testMatchViaCertificate($base, $dnsname) { - $certificate = $this->fakeCertificate($dnsname); - $this->assertTrue(Requests_SSL::verify_certificate($base, $certificate)); - } - - /** - * @dataProvider domainNoMatchProvider - */ - public function testNoMatchViaCertificate($base, $dnsname) { - $certificate = $this->fakeCertificate($dnsname); - $this->assertFalse(Requests_SSL::verify_certificate($base, $certificate)); - } - - public function testCNFallback() { - $certificate = $this->fakeCertificate('example.com', false); - $this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate)); - } - - public function testInvalidCNFallback() { - $certificate = $this->fakeCertificate('example.com', false); - $this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate)); - } - - /** - * Test a certificate with both CN and SAN fields - * - * As per RFC2818, if the SAN field exists, we should parse that and ignore - * the value of the CN field. - * - * @link http://tools.ietf.org/html/rfc2818#section-3.1 - */ - public function testIgnoreCNWithSAN() { - $certificate = $this->fakeCertificate('example.net', 'example.com'); - - $this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate), 'Checking SAN validation'); - $this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate), 'Checking CN non-validation'); - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Session.php b/razorpay-php/libs/Requests-1.6.1/tests/Session.php deleted file mode 100755 index 676c609..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Session.php +++ /dev/null @@ -1,86 +0,0 @@ - 'testing', - 'X-TestHeader2' => 'requests-test' - ); - $data = array( - 'testdata' => 'value1', - 'test2' => 'value2', - 'test3' => array( - 'foo' => 'bar', - 'abc' => 'xyz' - ) - ); - $options = array( - 'testoption' => 'test', - 'foo' => 'bar' - ); - - $session = new Requests_Session('http://example.com/', $headers, $data, $options); - $this->assertEquals('http://example.com/', $session->url); - $this->assertEquals($headers, $session->headers); - $this->assertEquals($data, $session->data); - $this->assertEquals($options['testoption'], $session->options['testoption']); - - // Test via property access - $this->assertEquals($options['testoption'], $session->testoption); - - // Test setting new property - $session->newoption = 'foobar'; - $options['newoption'] = 'foobar'; - $this->assertEquals($options['newoption'], $session->options['newoption']); - - // Test unsetting property - unset($session->newoption); - $this->assertFalse(isset($session->newoption)); - - // Update property - $session->testoption = 'foobar'; - $options['testoption'] = 'foobar'; - $this->assertEquals($options['testoption'], $session->testoption); - - // Test getting invalid property - $this->assertNull($session->invalidoption); - } - - public function testURLResolution() { - $session = new Requests_Session('http://httpbin.org/'); - - // Set the cookies up - $response = $session->get('/get'); - $this->assertTrue($response->success); - $this->assertEquals('http://httpbin.org/get', $response->url); - - $data = json_decode($response->body, true); - $this->assertNotNull($data); - $this->assertArrayHasKey('url', $data); - $this->assertEquals('http://httpbin.org/get', $data['url']); - } - - public function testSharedCookies() { - $session = new Requests_Session('http://httpbin.org/'); - - $options = array( - 'follow_redirects' => false - ); - $response = $session->get('/cookies/set?requests-testcookie=testvalue', array(), $options); - $this->assertEquals(302, $response->status_code); - - // Check the cookies - $response = $session->get('/cookies'); - $this->assertTrue($response->success); - - // Check the response - $data = json_decode($response->body, true); - $this->assertNotNull($data); - $this->assertArrayHasKey('cookies', $data); - - $cookies = array( - 'requests-testcookie' => 'testvalue' - ); - $this->assertEquals($cookies, $data['cookies']); - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Transport/Base.php b/razorpay-php/libs/Requests-1.6.1/tests/Transport/Base.php deleted file mode 100755 index 8584efb..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Transport/Base.php +++ /dev/null @@ -1,683 +0,0 @@ -transport, 'test'); - $supported = call_user_func($callback); - - if (!$supported) { - $this->markTestSkipped($this->transport . ' is not available'); - return; - } - - $ssl_supported = call_user_func($callback, array('ssl' => true)); - if (!$ssl_supported) { - $this->skip_https = true; - } - } - protected $skip_https = false; - - protected function getOptions($other = array()) { - $options = array( - 'transport' => $this->transport - ); - $options = array_merge($options, $other); - return $options; - } - - public function testSimpleGET() { - $request = Requests::get('http://httpbin.org/get', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - } - - public function testGETWithArgs() { - $request = Requests::get('http://httpbin.org/get?test=true&test2=test', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get?test=true&test2=test', $result['url']); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['args']); - } - - public function testGETWithData() { - $data = array( - 'test' => 'true', - 'test2' => 'test', - ); - $request = Requests::request('http://httpbin.org/get', array(), $data, Requests::GET, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get?test=true&test2=test', $result['url']); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['args']); - } - - public function testGETWithNestedData() { - $this->markTestSkipped('httpbin changed their data format; this test will now fail'); - $data = array( - 'test' => 'true', - 'test2' => array( - 'test3' => 'test', - 'test4' => 'test-too', - ), - ); - $request = Requests::request('http://httpbin.org/get', array(), $data, Requests::GET, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get?test=true&test2%5Btest3%5D=test&test2%5Btest4%5D=test-too', $result['url']); - $this->assertEquals(array('test' => 'true', 'test2[test3]' => 'test', 'test2[test4]' => 'test-too'), $result['args']); - } - - public function testGETWithDataAndQuery() { - $data = array( - 'test2' => 'test', - ); - $request = Requests::request('http://httpbin.org/get?test=true', array(), $data, Requests::GET, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get?test=true&test2=test', $result['url']); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['args']); - } - - public function testGETWithHeaders() { - $headers = array( - 'Requested-At' => time(), - ); - $request = Requests::get('http://httpbin.org/get', $headers, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals($headers['Requested-At'], $result['headers']['Requested-At']); - } - - public function testChunked() { - $request = Requests::get('http://httpbin.org/stream/1', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/stream/1', $result['url']); - $this->assertEmpty($result['args']); - } - - public function testHEAD() { - $request = Requests::head('http://httpbin.org/get', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - $this->assertEquals('', $request->body); - } - - public function testRawPOST() { - $data = 'test'; - $request = Requests::post('http://httpbin.org/post', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('test', $result['data']); - } - - public function testFormPost() { - $data = 'test=true&test2=test'; - $request = Requests::post('http://httpbin.org/post', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testPOSTWithArray() { - $data = array( - 'test' => 'true', - 'test2' => 'test', - ); - $request = Requests::post('http://httpbin.org/post', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testPOSTWithNestedData() { - $data = array( - 'test' => 'true', - 'test2' => array( - 'test3' => 'test', - 'test4' => 'test-too', - ), - ); - $request = Requests::post('http://httpbin.org/post', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2[test3]' => 'test', 'test2[test4]' => 'test-too'), $result['form']); - } - - public function testRawPUT() { - $data = 'test'; - $request = Requests::put('http://httpbin.org/put', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('test', $result['data']); - } - - public function testFormPUT() { - $data = 'test=true&test2=test'; - $request = Requests::put('http://httpbin.org/put', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testPUTWithArray() { - $data = array( - 'test' => 'true', - 'test2' => 'test', - ); - $request = Requests::put('http://httpbin.org/put', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testRawPATCH() { - $data = 'test'; - $request = Requests::patch('http://httpbin.org/patch', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('test', $result['data']); - } - - public function testFormPATCH() { - $data = 'test=true&test2=test'; - $request = Requests::patch('http://httpbin.org/patch', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code, $request->body); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testPATCHWithArray() { - $data = array( - 'test' => 'true', - 'test2' => 'test', - ); - $request = Requests::patch('http://httpbin.org/patch', array(), $data, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']); - } - - public function testDELETE() { - $request = Requests::delete('http://httpbin.org/delete', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/delete', $result['url']); - $this->assertEmpty($result['args']); - } - - public function testDELETEWithData() { - $data = array( - 'test' => 'true', - 'test2' => 'test', - ); - $request = Requests::request('http://httpbin.org/delete', array(), $data, Requests::DELETE, $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/delete?test=true&test2=test', $result['url']); - $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['args']); - } - - public function testRedirects() { - $request = Requests::get('http://httpbin.org/redirect/6', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $this->assertEquals(6, $request->redirects); - } - - public function testRelativeRedirects() { - $request = Requests::get('http://httpbin.org/relative-redirect/6', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $this->assertEquals(6, $request->redirects); - } - - /** - * @expectedException Requests_Exception - * @todo This should also check that the type is "toomanyredirects" - */ - public function testTooManyRedirects() { - $options = array( - 'redirects' => 10, // default, but force just in case - ); - $request = Requests::get('http://httpbin.org/redirect/11', array(), $this->getOptions($options)); - } - - public static function statusCodeSuccessProvider() { - return array( - array(200, true), - array(201, true), - array(202, true), - array(203, true), - array(204, true), - array(205, true), - array(206, true), - array(300, false), - array(301, false), - array(302, false), - array(303, false), - array(304, false), - array(305, false), - array(306, false), - array(307, false), - array(400, false), - array(401, false), - array(402, false), - array(403, false), - array(404, false), - array(405, false), - array(406, false), - array(407, false), - array(408, false), - array(409, false), - array(410, false), - array(411, false), - array(412, false), - array(413, false), - array(414, false), - array(415, false), - array(416, false), - array(417, false), - array(418, false), // RFC 2324 - array(428, false), // RFC 6585 - array(429, false), // RFC 6585 - array(431, false), // RFC 6585 - array(500, false), - array(501, false), - array(502, false), - array(503, false), - array(504, false), - array(505, false), - array(511, false), // RFC 6585 - ); - } - - /** - * @dataProvider statusCodeSuccessProvider - */ - public function testStatusCode($code, $success) { - $url = sprintf('http://httpbin.org/status/%d', $code); - $options = array( - 'follow_redirects' => false, - ); - $request = Requests::get($url, array(), $this->getOptions($options)); - $this->assertEquals($code, $request->status_code); - $this->assertEquals($success, $request->success); - } - - /** - * @dataProvider statusCodeSuccessProvider - */ - public function testStatusCodeThrow($code, $success) { - $url = sprintf('http://httpbin.org/status/%d', $code); - $options = array( - 'follow_redirects' => false, - ); - - if (!$success) { - if ($code >= 400) { - $this->setExpectedException('Requests_Exception_HTTP_' . $code, $code); - } - elseif ($code >= 300 && $code < 400) { - $this->setExpectedException('Requests_Exception'); - } - } - $request = Requests::get($url, array(), $this->getOptions($options)); - $request->throw_for_status(false); - } - - /** - * @dataProvider statusCodeSuccessProvider - */ - public function testStatusCodeThrowAllowRedirects($code, $success) { - $url = sprintf('http://httpbin.org/status/%d', $code); - $options = array( - 'follow_redirects' => false, - ); - - if (!$success) { - if ($code >= 400) { - $this->setExpectedException('Requests_Exception_HTTP_' . $code, $code); - } - } - $request = Requests::get($url, array(), $this->getOptions($options)); - $request->throw_for_status(true); - } - - public function testStatusCodeUnknown(){ - $request = Requests::get('http://httpbin.org/status/599', array(), $this->getOptions()); - $this->assertEquals(599, $request->status_code); - $this->assertEquals(false, $request->success); - } - - /** - * @expectedException Requests_Exception_HTTP_Unknown - */ - public function testStatusCodeThrowUnknown(){ - $request = Requests::get('http://httpbin.org/status/599', array(), $this->getOptions()); - $request->throw_for_status(true); - } - - public function testGzipped() { - $request = Requests::get('http://httpbin.org/gzip', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body); - $this->assertEquals(true, $result->gzipped); - } - - public function testStreamToFile() { - $options = array( - 'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest - ); - $request = Requests::get('http://httpbin.org/get', array(), $this->getOptions($options)); - $this->assertEquals(200, $request->status_code); - $this->assertEmpty($request->body); - - $contents = file_get_contents($options['filename']); - $result = json_decode($contents, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - - unlink($options['filename']); - } - - public function testNonblocking() { - $options = array( - 'blocking' => false - ); - $request = Requests::get('http://httpbin.org/get', array(), $this->getOptions($options)); - $empty = new Requests_Response(); - $this->assertEquals($empty, $request); - } - - /** - * @expectedException Requests_Exception - */ - public function testBadIP() { - $request = Requests::get('http://256.256.256.0/', array(), $this->getOptions()); - } - - public function testHTTPS() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://httpbin.org/get', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - - $result = json_decode($request->body, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - } - - /** - * @expectedException Requests_Exception - */ - public function testExpiredHTTPS() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://testssl-expire.disig.sk/index.en.html', array(), $this->getOptions()); - } - - /** - * @expectedException Requests_Exception - */ - public function testRevokedHTTPS() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://testssl-revoked.disig.sk/index.en.html', array(), $this->getOptions()); - } - - /** - * Test that SSL fails with a bad certificate - * - * This is defined as invalid by - * https://onlinessl.netlock.hu/en/test-center/invalid-ssl-certificate.html - * and is used in testing in PhantomJS. That said, expect this to break. - * - * @expectedException Requests_Exception - */ - public function testBadDomain() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://tv.eurosport.com/', array(), $this->getOptions()); - } - - /** - * Test that the transport supports Server Name Indication with HTTPS - * - * sni.velox.ch is used for SNI testing, and the common name is set to - * `*.sni.velox.ch` as such. Without alternate name support, this will fail - * as `sni.velox.ch` is only in the alternate name - */ - public function testAlternateNameSupport() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://sni.velox.ch/', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - } - - /** - * Test that the transport supports Server Name Indication with HTTPS - * - * sni.velox.ch is used for SNI testing, and the common name is set to - * `*.sni.velox.ch` as such. Without SNI support, this will fail. Also tests - * our wildcard support. - */ - public function testSNISupport() { - if ($this->skip_https) { - $this->markTestSkipped('SSL support is not available.'); - return; - } - - $request = Requests::get('https://abc.sni.velox.ch/', array(), $this->getOptions()); - $this->assertEquals(200, $request->status_code); - } - - /** - * @expectedException Requests_Exception - */ - public function testTimeout() { - $options = array( - 'timeout' => 1, - ); - $request = Requests::get('http://httpbin.org/delay/10', array(), $this->getOptions($options)); - var_dump($request); - } - - public function testMultiple() { - $requests = array( - 'test1' => array( - 'url' => 'http://httpbin.org/get' - ), - 'test2' => array( - 'url' => 'http://httpbin.org/get' - ), - ); - $responses = Requests::request_multiple($requests, $this->getOptions()); - - // test1 - $this->assertNotEmpty($responses['test1']); - $this->assertInstanceOf('Requests_Response', $responses['test1']); - $this->assertEquals(200, $responses['test1']->status_code); - - $result = json_decode($responses['test1']->body, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - - // test2 - $this->assertNotEmpty($responses['test2']); - $this->assertInstanceOf('Requests_Response', $responses['test2']); - $this->assertEquals(200, $responses['test2']->status_code); - - $result = json_decode($responses['test2']->body, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - } - - public function testMultipleWithDifferingMethods() { - $requests = array( - 'get' => array( - 'url' => 'http://httpbin.org/get', - ), - 'post' => array( - 'url' => 'http://httpbin.org/post', - 'type' => Requests::POST, - 'data' => 'test', - ), - ); - $responses = Requests::request_multiple($requests, $this->getOptions()); - - // get - $this->assertEquals(200, $responses['get']->status_code); - - // post - $this->assertEquals(200, $responses['post']->status_code); - $result = json_decode($responses['post']->body, true); - $this->assertEquals('test', $result['data']); - } - - /** - * @depends testTimeout - */ - public function testMultipleWithFailure() { - $requests = array( - 'success' => array( - 'url' => 'http://httpbin.org/get', - ), - 'timeout' => array( - 'url' => 'http://httpbin.org/delay/10', - 'options' => array( - 'timeout' => 1, - ), - ), - ); - $responses = Requests::request_multiple($requests, $this->getOptions()); - $this->assertEquals(200, $responses['success']->status_code); - $this->assertInstanceOf('Requests_Exception', $responses['timeout']); - } - - public function testMultipleUsingCallback() { - $requests = array( - 'get' => array( - 'url' => 'http://httpbin.org/get', - ), - 'post' => array( - 'url' => 'http://httpbin.org/post', - 'type' => Requests::POST, - 'data' => 'test', - ), - ); - $this->completed = array(); - $options = array( - 'complete' => array($this, 'completeCallback'), - ); - $responses = Requests::request_multiple($requests, $this->getOptions($options)); - - $this->assertEquals($this->completed, $responses); - $this->completed = array(); - } - - public function testMultipleUsingCallbackAndFailure() { - $requests = array( - 'success' => array( - 'url' => 'http://httpbin.org/get', - ), - 'timeout' => array( - 'url' => 'http://httpbin.org/delay/10', - 'options' => array( - 'timeout' => 1, - ), - ), - ); - $this->completed = array(); - $options = array( - 'complete' => array($this, 'completeCallback'), - ); - $responses = Requests::request_multiple($requests, $this->getOptions($options)); - - $this->assertEquals($this->completed, $responses); - $this->completed = array(); - } - - public function completeCallback($response, $key) { - $this->completed[$key] = $response; - } - - public function testMultipleToFile() { - $requests = array( - 'get' => array( - 'url' => 'http://httpbin.org/get', - 'options' => array( - 'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest - ), - ), - 'post' => array( - 'url' => 'http://httpbin.org/post', - 'type' => Requests::POST, - 'data' => 'test', - 'options' => array( - 'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest - ), - ), - ); - $responses = Requests::request_multiple($requests, $this->getOptions()); - - // GET request - $contents = file_get_contents($requests['get']['options']['filename']); - $result = json_decode($contents, true); - $this->assertEquals('http://httpbin.org/get', $result['url']); - $this->assertEmpty($result['args']); - unlink($requests['get']['options']['filename']); - - // POST request - $contents = file_get_contents($requests['post']['options']['filename']); - $result = json_decode($contents, true); - $this->assertEquals('http://httpbin.org/post', $result['url']); - $this->assertEquals('test', $result['data']); - unlink($requests['post']['options']['filename']); - } - - public function testHostHeader() { - $request = Requests::get('http://portquiz.positon.org:8080/', array(), $this->getOptions()); - $responseDoc = new DOMDocument; - $responseDoc->loadHTML($request->body); - $portXpath = new DOMXPath($responseDoc); - $portXpathMatches = $portXpath->query('//p/b'); - $this->assertEquals(8080, $portXpathMatches->item(0)->nodeValue); - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/Transport/cURL.php b/razorpay-php/libs/Requests-1.6.1/tests/Transport/cURL.php deleted file mode 100755 index 55390ad..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/Transport/cURL.php +++ /dev/null @@ -1,5 +0,0 @@ - '100 Continue', - 101 => '101 Switching Protocols', - 200 => '200 OK', - 201 => '201 Created', - 202 => '202 Accepted', - 203 => '203 Non-Authoritative Information', - 204 => '204 No Content', - 205 => '205 Reset Content', - 206 => '206 Partial Content', - 300 => '300 Multiple Choices', - 301 => '301 Moved Permanently', - 302 => '302 Found', - 303 => '303 See Other', - 304 => '304 Not Modified', - 305 => '305 Use Proxy', - 306 => '306 (Unused)', - 307 => '307 Temporary Redirect', - 400 => '400 Bad Request', - 401 => '401 Unauthorized', - 402 => '402 Payment Required', - 403 => '403 Forbidden', - 404 => '404 Not Found', - 405 => '405 Method Not Allowed', - 406 => '406 Not Acceptable', - 407 => '407 Proxy Authentication Required', - 408 => '408 Request Timeout', - 409 => '409 Conflict', - 410 => '410 Gone', - 411 => '411 Length Required', - 412 => '412 Precondition Failed', - 413 => '413 Request Entity Too Large', - 414 => '414 Request-URI Too Long', - 415 => '415 Unsupported Media Type', - 416 => '416 Requested Range Not Satisfiable', - 417 => '417 Expectation Failed', - 500 => '500 Internal Server Error', - 501 => '501 Not Implemented', - 502 => '502 Bad Gateway', - 503 => '503 Service Unavailable', - 504 => '504 Gateway Timeout', - 505 => '505 HTTP Version Not Supported', - ); - - public function request($url, $headers = array(), $data = array(), $options = array()) { - $status = self::$messages[$this->code]; - $response = "HTTP/1.0 $status\r\n"; - $response .= "Content-Type: text/plain\r\n"; - if ($this->chunked) { - $response .= "Transfer-Encoding: chunked\r\n"; - } - $response .= $this->raw_headers; - $response .= "Connection: close\r\n\r\n"; - $response .= $this->body; - return $response; - } - - public function request_multiple($requests, $options) { - $responses = array(); - foreach ($requests as $id => $request) { - $handler = new MockTransport(); - $handler->code = $request['options']['mock.code']; - $handler->chunked = $request['options']['mock.chunked']; - $handler->body = $request['options']['mock.body']; - $handler->raw_headers = $request['options']['mock.raw_headers']; - $responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']); - - if (!empty($options['mock.parse'])) { - $request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request)); - $request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id)); - } - } - - return $responses; - } - - public static function test() { - return true; - } -} - -class RawTransport implements Requests_Transport { - public $data = ''; - public function request($url, $headers = array(), $data = array(), $options = array()) { - return $this->data; - } - public function request_multiple($requests, $options) { - foreach ($requests as $id => &$request) { - $handler = new RawTransport(); - $handler->data = $request['options']['raw.data']; - $request = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']); - } - - return $requests; - } - public static function test() { - return true; - } -} diff --git a/razorpay-php/libs/Requests-1.6.1/tests/phpunit.xml.dist b/razorpay-php/libs/Requests-1.6.1/tests/phpunit.xml.dist deleted file mode 100755 index 847b9b6..0000000 --- a/razorpay-php/libs/Requests-1.6.1/tests/phpunit.xml.dist +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Auth - - - Transport - - - ChunkedEncoding.php - Cookies.php - IDNAEncoder.php - IRI.php - Requests.php - Response/Headers.php - SSL.php - - - - - - - - - - . - - - ../library - - - \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/.coveralls.yml b/razorpay-php/libs/Requests-1.7.0/.coveralls.yml old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/.coveralls.yml rename to razorpay-php/libs/Requests-1.7.0/.coveralls.yml diff --git a/razorpay-php/libs/Requests-1.7.0/.gitignore b/razorpay-php/libs/Requests-1.7.0/.gitignore new file mode 100644 index 0000000..3b59626 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/.gitignore @@ -0,0 +1,6 @@ +# Ignore coverage report +tests/coverage/* + +# Ignore composer related files +/composer.lock +/vendor diff --git a/razorpay-php/libs/Requests-1.7.0/.travis.yml b/razorpay-php/libs/Requests-1.7.0/.travis.yml new file mode 100644 index 0000000..07252b6 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/.travis.yml @@ -0,0 +1,58 @@ +language: php +matrix: + fast_finish: true + include: + - php: 5.2 + - php: 5.3 + - php: 5.4 + - php: 5.5 + - php: 5.6 + env: TEST_COVERAGE=1 + - php: 7.0 + - php: hhvm + +# Use new container infrastructure +sudo: false + +cache: + directories: + - $HOME/.cache/pip + - $HOME/.composer/cache + - vendor + +install: + # Setup the test server + - phpenv local 5.5 + - composer install --dev --no-interaction + - TESTPHPBIN=$(phpenv which php) + - phpenv local --unset + + # Setup the proxy + - pip install --user mitmproxy~=0.15 + +before_script: + - PHPBIN=$TESTPHPBIN PORT=8080 vendor/bin/start.sh + - export REQUESTS_TEST_HOST_HTTP="localhost:8080" + + # Work out of the tests directory + - cd tests + - PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9002 utils/proxy/start.sh + - PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9003 AUTH="test:pass" utils/proxy/start.sh + - export REQUESTS_HTTP_PROXY="localhost:9002" + - export REQUESTS_HTTP_PROXY_AUTH="localhost:9003" + - export REQUESTS_HTTP_PROXY_AUTH_USER="test" + - export REQUESTS_HTTP_PROXY_AUTH_PASS="pass" + + # Ensure the HTTPS test instance on Heroku is spun up + - curl -s -I http://requests-php-tests.herokuapp.com/ > /dev/null + +script: + - phpunit --coverage-clover clover.xml + +after_script: + - utils/proxy/stop.sh + - cd .. + - phpenv local 5.5 + - PATH=$PATH vendor/bin/stop.sh + - test $TEST_COVERAGE && bash <(curl -s https://codecov.io/bash) + - phpenv local --unset diff --git a/razorpay-php/libs/Requests-1.7.0/CHANGELOG.md b/razorpay-php/libs/Requests-1.7.0/CHANGELOG.md new file mode 100644 index 0000000..1d62a4c --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/CHANGELOG.md @@ -0,0 +1,315 @@ +Changelog +========= + +1.7.0 +----- + +- Add support for HHVM and PHP 7 + + Requests is now tested against both HHVM and PHP 7, and they are supported as + first-party platforms. + + (props @rmccue, [#106][gh-106], [#176][gh-176]) + +- Transfer & connect timeouts, in seconds & milliseconds + + cURL is unable to handle timeouts under a second in DNS lookups, so we round + those up to ensure 1-999ms isn't counted as an instant failure. + + (props @ozh, @rmccue, [#97][gh-97], [#216][gh-216]) + +- Rework cookie handling to be more thorough. + + Cookies are now restricted to the same-origin by default, expiration is checked. + + (props @catharsisjelly, @rmccue, [#120][gh-120], [#124][gh-124], [#130][gh-130], [#132][gh-132], [#156][gh-156]) + +- Improve testing + + Tests are now run locally to speed them up, as well as further general + improvements to the quality of the testing suite. There are now also + comprehensive proxy tests to ensure coverage there. + + (props @rmccue, [#75][gh-75], [#107][gh-107], [#170][gh-170], [#177][gh-177], [#181][gh-181], [#183][gh-183], [#185][gh-185], [#196][gh-196], [#202][gh-202], [#203][gh-203]) + +- Support custom HTTP methods + + Previously, custom HTTP methods were only supported on sockets; they are now + supported across all transports. + + (props @ocean90, [#227][gh-227]) + +- Add byte limit option + + (props @rmccue, [#172][gh-172]) + +- Support a Requests_Proxy_HTTP() instance for the proxy setting. + + (props @ocean90, [#223][gh-223]) + +- Add progress hook + + (props @rmccue, [#180][gh-180]) + +- Add a before_redirect hook to alter redirects + + (props @rmccue, [#205][gh-205]) + +- Pass cURL info to after_request + + (props @rmccue, [#206][gh-206]) + +- Remove explicit autoload in Composer installation instructions + + (props @SlikNL, [#86][gh-86]) + +- Restrict CURLOPT_PROTOCOLS on `defined()` instead of `version_compare()` + + (props @ozh, [#92][gh-92]) + +- Fix doc - typo in "Authentication" + + (props @remik, [#99][gh-99]) + +- Contextually check for a valid transport + + (props @ozh, [#101][gh-101]) + +- Follow relative redirects correctly + + (props @ozh, [#103][gh-103]) + +- Use cURL's version_number + + (props @mishan, [#104][gh-104]) + +- Removed duplicated option docs + + (props @staabm, [#112][gh-112]) + +- code styling fixed + + (props @imsaintx, [#113][gh-113]) + +- Fix IRI "normalization" + + (props @ozh, [#128][gh-128]) + +- Mention two PHP extension dependencies in the README. + + (props @orlitzky, [#136][gh-136]) + +- Ignore coverage report files + + (props @ozh, [#148][gh-148]) + +- drop obsolete "return" after throw + + (props @staabm, [#150][gh-150]) + +- Updated exception message to specify both http + https + + (props @beutnagel, [#162][gh-162]) + +- Sets `stream_headers` method to public to allow calling it from other +places. + + (props @adri, [#158][gh-158]) + +- Remove duplicated stream_get_meta_data call + + (props @rmccue, [#179][gh-179]) + +- Transmits $errno from stream_socket_client in exception + + (props @laurentmartelli, [#174][gh-174]) + +- Correct methods to use snake_case + + (props @rmccue, [#184][gh-184]) + +- Improve code quality + + (props @rmccue, [#186][gh-186]) + +- Update Build Status image + + (props @rmccue, [#187][gh-187]) + +- Fix/Rationalize transports (v2) + + (props @rmccue, [#188][gh-188]) + +- Surface cURL errors + + (props @ifwe, [#194][gh-194]) + +- Fix for memleak and curl_close() never being called + + (props @kwuerl, [#200][gh-200]) + +- addex how to install with composer + + (props @royopa, [#164][gh-164]) + +- Uppercase the method to ensure compatibility + + (props @rmccue, [#207][gh-207]) + +- Store default certificate path + + (props @rmccue, [#210][gh-210]) + +- Force closing keep-alive connections on old cURL + + (props @rmccue, [#211][gh-211]) + +- Docs: Updated HTTP links with HTTPS links where applicable + + (props @ntwb, [#215][gh-215]) + +- Remove the executable bit + + (props @ocean90, [#224][gh-224]) + +- Change more links to HTTPS + + (props @rmccue, [#217][gh-217]) + +- Bail from cURL when either `curl_init()` OR `curl_exec()` are unavailable + + (props @dd32, [#230][gh-230]) + +- Disable OpenSSL's internal peer_name checking when `verifyname` is disabled. + + (props @dd32, [#239][gh-239]) + +- Only include the port number in the `Host` header when it differs from +default + + (props @dd32, [#238][gh-238]) + +- Respect port if specified for HTTPS connections + + (props @dd32, [#237][gh-237]) + +- Allow paths starting with a double-slash + + (props @rmccue, [#240][gh-240]) + +- Fixes bug in rfc2616 #3.6.1 implementation. + + (props @stephenharris, [#236][gh-236], [#3][gh-3]) + +- CURLOPT_HTTPHEADER在php7接受空数组导致php-fpm奔溃 + + (props @qibinghua, [#219][gh-219]) + +[gh-3]: https://github.com/rmccue/Requests/issues/3 +[gh-75]: https://github.com/rmccue/Requests/issues/75 +[gh-86]: https://github.com/rmccue/Requests/issues/86 +[gh-92]: https://github.com/rmccue/Requests/issues/92 +[gh-97]: https://github.com/rmccue/Requests/issues/97 +[gh-99]: https://github.com/rmccue/Requests/issues/99 +[gh-101]: https://github.com/rmccue/Requests/issues/101 +[gh-103]: https://github.com/rmccue/Requests/issues/103 +[gh-104]: https://github.com/rmccue/Requests/issues/104 +[gh-106]: https://github.com/rmccue/Requests/issues/106 +[gh-107]: https://github.com/rmccue/Requests/issues/107 +[gh-112]: https://github.com/rmccue/Requests/issues/112 +[gh-113]: https://github.com/rmccue/Requests/issues/113 +[gh-120]: https://github.com/rmccue/Requests/issues/120 +[gh-124]: https://github.com/rmccue/Requests/issues/124 +[gh-128]: https://github.com/rmccue/Requests/issues/128 +[gh-130]: https://github.com/rmccue/Requests/issues/130 +[gh-132]: https://github.com/rmccue/Requests/issues/132 +[gh-136]: https://github.com/rmccue/Requests/issues/136 +[gh-148]: https://github.com/rmccue/Requests/issues/148 +[gh-150]: https://github.com/rmccue/Requests/issues/150 +[gh-156]: https://github.com/rmccue/Requests/issues/156 +[gh-158]: https://github.com/rmccue/Requests/issues/158 +[gh-162]: https://github.com/rmccue/Requests/issues/162 +[gh-164]: https://github.com/rmccue/Requests/issues/164 +[gh-170]: https://github.com/rmccue/Requests/issues/170 +[gh-172]: https://github.com/rmccue/Requests/issues/172 +[gh-174]: https://github.com/rmccue/Requests/issues/174 +[gh-176]: https://github.com/rmccue/Requests/issues/176 +[gh-177]: https://github.com/rmccue/Requests/issues/177 +[gh-179]: https://github.com/rmccue/Requests/issues/179 +[gh-180]: https://github.com/rmccue/Requests/issues/180 +[gh-181]: https://github.com/rmccue/Requests/issues/181 +[gh-183]: https://github.com/rmccue/Requests/issues/183 +[gh-184]: https://github.com/rmccue/Requests/issues/184 +[gh-185]: https://github.com/rmccue/Requests/issues/185 +[gh-186]: https://github.com/rmccue/Requests/issues/186 +[gh-187]: https://github.com/rmccue/Requests/issues/187 +[gh-188]: https://github.com/rmccue/Requests/issues/188 +[gh-194]: https://github.com/rmccue/Requests/issues/194 +[gh-196]: https://github.com/rmccue/Requests/issues/196 +[gh-200]: https://github.com/rmccue/Requests/issues/200 +[gh-202]: https://github.com/rmccue/Requests/issues/202 +[gh-203]: https://github.com/rmccue/Requests/issues/203 +[gh-205]: https://github.com/rmccue/Requests/issues/205 +[gh-206]: https://github.com/rmccue/Requests/issues/206 +[gh-207]: https://github.com/rmccue/Requests/issues/207 +[gh-210]: https://github.com/rmccue/Requests/issues/210 +[gh-211]: https://github.com/rmccue/Requests/issues/211 +[gh-215]: https://github.com/rmccue/Requests/issues/215 +[gh-216]: https://github.com/rmccue/Requests/issues/216 +[gh-217]: https://github.com/rmccue/Requests/issues/217 +[gh-219]: https://github.com/rmccue/Requests/issues/219 +[gh-223]: https://github.com/rmccue/Requests/issues/223 +[gh-224]: https://github.com/rmccue/Requests/issues/224 +[gh-227]: https://github.com/rmccue/Requests/issues/227 +[gh-230]: https://github.com/rmccue/Requests/issues/230 +[gh-236]: https://github.com/rmccue/Requests/issues/236 +[gh-237]: https://github.com/rmccue/Requests/issues/237 +[gh-238]: https://github.com/rmccue/Requests/issues/238 +[gh-239]: https://github.com/rmccue/Requests/issues/239 +[gh-240]: https://github.com/rmccue/Requests/issues/240 + +1.6.0 +----- +- [Add multiple request support][#23] - Send multiple HTTP requests with both + fsockopen and cURL, transparently falling back to synchronous when + not supported. + +- [Add proxy support][#70] - HTTP proxies are now natively supported via a + [high-level API][docs/proxy]. Major props to Ozh for his fantastic work + on this. + +- [Verify host name for SSL requests][#63] - Requests is now the first and only + standalone HTTP library to fully verify SSL hostnames even with socket + connections. Thanks to Michael Adams, Dion Hulse, Jon Cave, and Pádraic Brady + for reviewing the crucial code behind this. + +- [Add cookie support][#64] - Adds built-in support for cookies (built entirely + as a high-level API) + +- [Add sessions][#62] - To compliment cookies, [sessions][docs/usage-advanced] + can be created with a base URL and default options, plus a shared cookie jar. + +- Add [PUT][#1], [DELETE][#3], and [PATCH][#2] request support + +- [Add Composer support][#6] - You can now install Requests via the + `rmccue/requests` package on Composer + +[docs/proxy]: http://requests.ryanmccue.info/docs/proxy.html +[docs/usage-advanced]: http://requests.ryanmccue.info/docs/usage-advanced.html + +[#1]: https://github.com/rmccue/Requests/issues/1 +[#2]: https://github.com/rmccue/Requests/issues/2 +[#3]: https://github.com/rmccue/Requests/issues/3 +[#6]: https://github.com/rmccue/Requests/issues/6 +[#9]: https://github.com/rmccue/Requests/issues/9 +[#23]: https://github.com/rmccue/Requests/issues/23 +[#62]: https://github.com/rmccue/Requests/issues/62 +[#63]: https://github.com/rmccue/Requests/issues/63 +[#64]: https://github.com/rmccue/Requests/issues/64 +[#70]: https://github.com/rmccue/Requests/issues/70 + +[View all changes][https://github.com/rmccue/Requests/compare/v1.5.0...v1.6.0] + +1.5.0 +----- +Initial release! \ No newline at end of file diff --git a/razorpay-php/libs/Requests-1.6.1/LICENSE b/razorpay-php/libs/Requests-1.7.0/LICENSE old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/LICENSE rename to razorpay-php/libs/Requests-1.7.0/LICENSE diff --git a/razorpay-php/libs/Requests-1.6.1/README.md b/razorpay-php/libs/Requests-1.7.0/README.md old mode 100755 new mode 100644 similarity index 89% rename from razorpay-php/libs/Requests-1.6.1/README.md rename to razorpay-php/libs/Requests-1.7.0/README.md index 76dc87d..8e99a20 --- a/razorpay-php/libs/Requests-1.6.1/README.md +++ b/razorpay-php/libs/Requests-1.7.0/README.md @@ -1,6 +1,9 @@ Requests for PHP ================ +[![Build Status](https://travis-ci.org/rmccue/Requests.svg?branch=master)](https://travis-ci.org/rmccue/Requests) +[![codecov.io](http://codecov.io/github/rmccue/Requests/coverage.svg?branch=master)](http://codecov.io/github/rmccue/Requests?branch=master) + 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 @@ -55,12 +58,15 @@ Installation If you're using [Composer](https://github.com/composer/composer) to manage dependencies, you can add Requests with it. +```sh +composer require rmccue/requests +``` + +or + { "require": { "rmccue/requests": ">=1.0" - }, - "autoload": { - "psr-0": {"Requests": "library/"} } } @@ -117,15 +123,15 @@ issue](https://github.com/rmccue/Requests/issues/new)! Testing ------- -[![Build Status](https://secure.travis-ci.org/rmccue/Requests.png?branch=master)](http://travis-ci.org/rmccue/Requests) -[![Coverage Status](https://coveralls.io/repos/rmccue/Requests/badge.png?branch=master)][coveralls] 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][coveralls]. +set of tests. We're not quite there yet, but [we're getting close][codecov]. -[coveralls]: https://coveralls.io/r/rmccue/Requests?branch=master +[codecov]: http://codecov.io/github/rmccue/Requests -To run the test suite, simply: +To run the test suite, first check that you have the [PHP +JSON extension ](http://php.net/manual/en/book.json.php) enabled. Then +simply: $ cd tests $ phpunit diff --git a/razorpay-php/libs/Requests-1.6.1/composer.json b/razorpay-php/libs/Requests-1.7.0/composer.json similarity index 91% rename from razorpay-php/libs/Requests-1.6.1/composer.json rename to razorpay-php/libs/Requests-1.7.0/composer.json index 9baeb52..79744ce 100644 --- a/razorpay-php/libs/Requests-1.6.1/composer.json +++ b/razorpay-php/libs/Requests-1.7.0/composer.json @@ -14,7 +14,7 @@ "php": ">=5.2" }, "require-dev": { - "satooshi/php-coveralls": "dev-master" + "requests/test-server": "dev-master" }, "type": "library", "autoload": { diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests.php b/razorpay-php/libs/Requests-1.7.0/library/Requests.php old mode 100755 new mode 100644 similarity index 77% rename from razorpay-php/libs/Requests-1.6.1/library/Requests.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests.php index cc75641..bb26618 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests.php @@ -54,20 +54,41 @@ class Requests { */ const DELETE = 'DELETE'; + /** + * OPTIONS method + * + * @var string + */ + const OPTIONS = 'OPTIONS'; + + /** + * TRACE method + * + * @var string + */ + const TRACE = 'TRACE'; + /** * PATCH method * - * @link http://tools.ietf.org/html/rfc5789 + * @link https://tools.ietf.org/html/rfc5789 * @var string */ const PATCH = 'PATCH'; + /** + * Default size of buffer size to read streams + * + * @var integer + */ + const BUFFER_SIZE = 1160; + /** * Current version of Requests * * @var string */ - const VERSION = '1.6.1'; + const VERSION = '1.7'; /** * Registered transport classes @@ -81,9 +102,19 @@ class Requests { * * Use {@see get_transport()} instead * - * @var string|null + * @var array + */ + public static $transport = array(); + + /** + * Default certificate path. + * + * @see Requests::get_certificate_path() + * @see Requests::set_certificate_path() + * + * @var string */ - public static $transport = null; + protected static $certificate_path; /** * This is a static class, do not instantiate it @@ -147,11 +178,16 @@ public static function add_transport($transport) { * @throws Requests_Exception If no valid transport is found (`notransport`) * @return Requests_Transport */ - protected static function get_transport() { + protected static function get_transport($capabilities = array()) { // Caching code, don't bother testing coverage // @codeCoverageIgnoreStart - if (self::$transport !== null) { - return new self::$transport(); + // array of capabilities as a string to be used as an array key + ksort($capabilities); + $cap_string = serialize($capabilities); + + // Don't search for a transport if it's already been done for these $capabilities + if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { + return new self::$transport[$cap_string](); } // @codeCoverageIgnoreEnd @@ -164,20 +200,21 @@ protected static function get_transport() { // Find us a working transport foreach (self::$transports as $class) { - if (!class_exists($class)) + if (!class_exists($class)) { continue; + } - $result = call_user_func(array($class, 'test')); + $result = call_user_func(array($class, 'test'), $capabilities); if ($result) { - self::$transport = $class; + self::$transport[$cap_string] = $class; break; } } - if (self::$transport === null) { + if (self::$transport[$cap_string] === null) { throw new Requests_Exception('No working transports found', 'notransport', self::$transports); } - return new self::$transport(); + return new self::$transport[$cap_string](); } /**#@+ @@ -207,6 +244,13 @@ public static function head($url, $headers = array(), $options = array()) { public static function delete($url, $headers = array(), $options = array()) { return self::request($url, $headers, null, self::DELETE, $options); } + + /** + * Send a TRACE request + */ + public static function trace($url, $headers = array(), $options = array()) { + return self::request($url, $headers, null, self::TRACE, $options); + } /**#@-*/ /**#@+ @@ -230,13 +274,20 @@ public static function put($url, $headers = array(), $data = array(), $options = return self::request($url, $headers, $data, self::PUT, $options); } + /** + * Send an OPTIONS request + */ + public static function options($url, $headers = array(), $data = array(), $options = array()) { + return self::request($url, $headers, $data, self::OPTIONS, $options); + } + /** * Send a PATCH request * * Note: Unlike {@see post} and {@see put}, `$headers` is required, as the * specification recommends that should send an ETag * - * @link http://tools.ietf.org/html/rfc5789 + * @link https://tools.ietf.org/html/rfc5789 */ public static function patch($url, $headers, $data = array(), $options = array()) { return self::request($url, $headers, $data, self::PATCH, $options); @@ -253,7 +304,11 @@ public static function patch($url, $headers, $data = array(), $options = array() * options: * * - `timeout`: How long should we wait for a response? - * (integer, seconds, default: 10) + * Note: for cURL, a minimum of 1 second applies, as DNS resolution + * operates at second-resolution only. + * (float, seconds with a millisecond precision, default: 10, example: 0.01) + * - `connect_timeout`: How long should we wait while trying to connect? + * (float, seconds with a millisecond precision, default: 10, example: 0.01) * - `useragent`: Useragent to send to the server * (string, default: php-requests/$version) * - `follow_redirects`: Should we follow 3xx redirects? @@ -268,7 +323,9 @@ public static function patch($url, $headers, $data = array(), $options = array() * for Basic authentication * (Requests_Auth|array|boolean, default: false) * - `proxy`: Proxy details to use for proxy by-passing and authentication - * (Requests_Proxy|array|boolean, default: false) + * (Requests_Proxy|array|string|boolean, default: false) + * - `max_bytes`: Limit for the response body size. + * (integer|boolean, default: false) * - `idn`: Enable IDN parsing * (boolean, default: true) * - `transport`: Custom transport. Either a class name, or a @@ -284,12 +341,15 @@ public static function patch($url, $headers, $data = array(), $options = array() * (string|boolean, default: library/Requests/Transport/cacert.pem) * - `verifyname`: Should we verify the common name in the SSL certificate? * (boolean: default, true) + * - `data_format`: How should we send the `$data` parameter? + * (string, one of 'query' or 'body', default: 'query' for + * HEAD/GET/DELETE, 'body' for POST/PUT/OPTIONS/PATCH) * * @throws Requests_Exception On invalid URLs (`nonhttp`) * * @param string $url URL to request * @param array $headers Extra headers to send with the request - * @param array $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests * @param string $type HTTP request type (use Requests constants) * @param array $options Options for the request (see description for more information) * @return Requests_Response @@ -312,7 +372,9 @@ public static function request($url, $headers = array(), $data = array(), $type } } else { - $transport = self::get_transport(); + $need_ssl = (0 === stripos($url, 'https://')); + $capabilities = array('ssl' => $need_ssl); + $transport = self::get_transport($capabilities); } $response = $transport->request($url, $headers, $data, $options); @@ -343,9 +405,6 @@ public static function request($url, $headers = array(), $data = array(), $type * - `type`: HTTP request type (use Requests constants). Same as the `$type` * parameter to {@see Requests::request} * (string, default: `Requests::GET`) - * - `data`: Associative array of options. Same as the `$options` parameter - * to {@see Requests::request} - * (array, default: see {@see Requests::request}) * - `cookies`: Associative array of cookie name to value, or cookie jar. * (array|Requests_Cookie_Jar) * @@ -443,7 +502,9 @@ public static function request_multiple($requests, $options = array()) { protected static function get_default_options($multirequest = false) { $defaults = array( 'timeout' => 10, + 'connect_timeout' => 10, 'useragent' => 'php-requests/' . self::VERSION, + 'protocol_version' => 1.1, 'redirected' => 0, 'redirects' => 10, 'follow_redirects' => true, @@ -453,10 +514,11 @@ protected static function get_default_options($multirequest = false) { 'auth' => false, 'proxy' => false, 'cookies' => false, + 'max_bytes' => false, 'idn' => true, 'hooks' => null, 'transport' => null, - 'verify' => dirname( __FILE__ ) . '/Requests/Transport/cacert.pem', + 'verify' => Requests::get_certificate_path(), 'verifyname' => true, ); if ($multirequest !== false) { @@ -465,19 +527,41 @@ protected static function get_default_options($multirequest = false) { return $defaults; } + /** + * Get default certificate path. + * + * @return string Default certificate path. + */ + public static function get_certificate_path() { + if ( ! empty( Requests::$certificate_path ) ) { + return Requests::$certificate_path; + } + + return dirname(__FILE__) . '/Requests/Transport/cacert.pem'; + } + + /** + * Set default certificate path. + * + * @param string $path Certificate path, pointing to a PEM file. + */ + public static function set_certificate_path( $path ) { + Requests::$certificate_path = $path; + } + /** * Set the default values * * @param string $url URL to request * @param array $headers Extra headers to send with the request - * @param array $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests * @param string $type HTTP request type * @param array $options Options for the request * @return array $options */ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$options) { - if (!preg_match('/^http(s)?:\/\//i', $url)) { - throw new Requests_Exception('Only HTTP requests are handled.', 'nonhttp', $url); + if (!preg_match('/^http(s)?:\/\//i', $url, $matches)) { + throw new Requests_Exception('Only HTTP(S) requests are handled.', 'nonhttp', $url); } if (empty($options['hooks'])) { @@ -491,7 +575,7 @@ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$optio $options['auth']->register($options['hooks']); } - if (!empty($options['proxy'])) { + if (is_string($options['proxy']) || is_array($options['proxy'])) { $options['proxy'] = new Requests_Proxy_HTTP($options['proxy']); } if ($options['proxy'] !== false) { @@ -513,6 +597,18 @@ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$optio $iri->host = Requests_IDNAEncoder::encode($iri->ihost); $url = $iri->uri; } + + // Massage the type to ensure we support it. + $type = strtoupper($type); + + if (!isset($options['data_format'])) { + if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) { + $options['data_format'] = 'query'; + } + else { + $options['data_format'] = 'body'; + } + } } /** @@ -555,11 +651,12 @@ protected static function parse_response($headers, $url, $req_headers, $req_data // Unfold headers (replace [CRLF] 1*( SP | HT ) with SP) as per RFC 2616 (section 2.2) $headers = preg_replace('/\n[ \t]/', ' ', $headers); $headers = explode("\n", $headers); - preg_match('#^HTTP/1\.\d[ \t]+(\d+)#i', array_shift($headers), $matches); + preg_match('#^HTTP/(1\.\d)[ \t]+(\d+)#i', array_shift($headers), $matches); if (empty($matches)) { throw new Requests_Exception('Response could not be parsed', 'noversion', $headers); } - $return->status_code = (int) $matches[1]; + $return->protocol_version = (float) $matches[1]; + $return->status_code = (int) $matches[2]; if ($return->status_code >= 200 && $return->status_code < 300) { $return->success = true; } @@ -585,19 +682,28 @@ protected static function parse_response($headers, $url, $req_headers, $req_data $options['hooks']->dispatch('requests.before_redirect_check', array(&$return, $req_headers, $req_data, $options)); - if ((in_array($return->status_code, array(300, 301, 302, 303, 307)) || $return->status_code > 307 && $return->status_code < 400) && $options['follow_redirects'] === true) { + if ($return->is_redirect() && $options['follow_redirects'] === true) { if (isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { if ($return->status_code === 303) { - $options['type'] = Requests::GET; + $options['type'] = self::GET; } $options['redirected']++; $location = $return->headers['location']; - if (strpos ($location, '/') === 0) { + if (strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { // relative redirect, for compatibility make it absolute $location = Requests_IRI::absolutize($url, $location); $location = $location->uri; } - $redirected = self::request($location, $req_headers, $req_data, false, $options); + + $hook_args = array( + &$location, + &$req_headers, + &$req_data, + &$options, + $return + ); + $options['hooks']->dispatch('requests.before_redirect', $hook_args); + $redirected = self::request($location, $req_headers, $req_data, $options['type'], $options); $redirected->history[] = $return; return $redirected; } @@ -618,13 +724,17 @@ protected static function parse_response($headers, $url, $req_headers, $req_data * Internal use only. Converts a raw HTTP response to a Requests_Response * while still executing a multiple request. * - * @param string $headers Full response text including headers and body + * @param string $response Full response text including headers and body (will be overwritten with Response instance) * @param array $request Request data as passed into {@see Requests::request_multiple()} * @return null `$response` is either set to a Requests_Response instance, or a Requests_Exception object */ public static function parse_multiple(&$response, $request) { try { - $response = self::parse_response($response, $request['url'], $request['headers'], $request['data'], $request['options']); + $url = $request['url']; + $headers = $request['headers']; + $data = $request['data']; + $options = $request['options']; + $response = self::parse_response($response, $url, $headers, $data, $options); } catch (Requests_Exception $e) { $response = $e; @@ -634,20 +744,22 @@ public static function parse_multiple(&$response, $request) { /** * Decoded a chunked body as per RFC 2616 * - * @see http://tools.ietf.org/html/rfc2616#section-3.6.1 + * @see https://tools.ietf.org/html/rfc2616#section-3.6.1 * @param string $data Chunked body * @return string Decoded body */ protected static function decode_chunked($data) { - if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($data))) { + if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { return $data; } + + $decoded = ''; $encoded = $data; while (true) { - $is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches ); + $is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); if (!$is_chunked) { // Looks like it's not chunked after all return $data; @@ -660,7 +772,7 @@ protected static function decode_chunked($data) { } $chunk_length = strlen($matches[0]); - $decoded .= $part = substr($encoded, $chunk_length, $length); + $decoded .= substr($encoded, $chunk_length, $length); $encoded = substr($encoded, $chunk_length + $length + 2); if (trim($encoded) === '0' || empty($encoded)) { @@ -682,7 +794,7 @@ protected static function decode_chunked($data) { public static function flatten($array) { $return = array(); foreach ($array as $key => $value) { - $return[] = "$key: $value"; + $return[] = sprintf('%s: %s', $key, $value); } return $return; } @@ -690,6 +802,7 @@ public static function flatten($array) { /** * Convert a key => value array to a 'key: value' array for headers * + * @codeCoverageIgnore * @deprecated Misspelling of {@see Requests::flatten} * @param array $array Dictionary of header values * @return array List of headers @@ -704,7 +817,6 @@ public static function flattern($array) { * Implements gzip, compress and deflate. Guesses which it is by attempting * to decode. * - * @todo Make this smarter by defaulting to whatever the headers say first * @param string $data Compressed data in one of the above formats * @return string Decompressed string */ @@ -740,12 +852,12 @@ public static function decompress($data) { * Warning: Magic numbers within. Due to the potential different formats that the compressed * data may be returned in, some "magic offsets" are needed to ensure proper decompression * takes place. For a simple progmatic way to determine the magic offset in use, see: - * http://core.trac.wordpress.org/ticket/18273 + * https://core.trac.wordpress.org/ticket/18273 * * @since 2.8.1 - * @link http://core.trac.wordpress.org/ticket/18273 - * @link http://au2.php.net/manual/en/function.gzinflate.php#70875 - * @link http://au2.php.net/manual/en/function.gzinflate.php#77336 + * @link https://core.trac.wordpress.org/ticket/18273 + * @link https://secure.php.net/manual/en/function.gzinflate.php#70875 + * @link https://secure.php.net/manual/en/function.gzinflate.php#77336 * * @param string $gzData String to decompress. * @return string|bool False on failure. @@ -753,23 +865,26 @@ public static function decompress($data) { public static function compatible_gzinflate($gzData) { // Compressed data might contain a full zlib header, if so strip it for // gzinflate() - if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) { + if (substr($gzData, 0, 3) == "\x1f\x8b\x08") { $i = 10; - $flg = ord( substr($gzData, 3, 1) ); - if ( $flg > 0 ) { - if ( $flg & 4 ) { - list($xlen) = unpack('v', substr($gzData, $i, 2) ); + $flg = ord(substr($gzData, 3, 1)); + if ($flg > 0) { + if ($flg & 4) { + list($xlen) = unpack('v', substr($gzData, $i, 2)); $i = $i + 2 + $xlen; } - if ( $flg & 8 ) + if ($flg & 8) { $i = strpos($gzData, "\0", $i) + 1; - if ( $flg & 16 ) + } + if ($flg & 16) { $i = strpos($gzData, "\0", $i) + 1; - if ( $flg & 2 ) + } + if ($flg & 2) { $i = $i + 2; + } } - $decompressed = self::compatible_gzinflate( substr( $gzData, $i ) ); - if ( false !== $decompressed ) { + $decompressed = self::compatible_gzinflate(substr($gzData, $i)); + if (false !== $decompressed) { return $decompressed; } } @@ -780,60 +895,62 @@ public static function compatible_gzinflate($gzData) { // java.util.zip.Deflater, Ruby’s Zlib::Deflate, and .NET's // System.IO.Compression.DeflateStream. // - // See http://decompres.blogspot.com/ for a quick explanation of this + // See https://decompres.blogspot.com/ for a quick explanation of this // data type $huffman_encoded = false; // low nibble of first byte should be 0x08 - list( , $first_nibble ) = unpack( 'h', $gzData ); + list(, $first_nibble) = unpack('h', $gzData); // First 2 bytes should be divisible by 0x1F - list( , $first_two_bytes ) = unpack( 'n', $gzData ); + list(, $first_two_bytes) = unpack('n', $gzData); - if ( 0x08 == $first_nibble && 0 == ( $first_two_bytes % 0x1F ) ) + if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { $huffman_encoded = true; + } - if ( $huffman_encoded ) { - if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 2 ) ) ) ) + if ($huffman_encoded) { + if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { return $decompressed; + } } - if ( "\x50\x4b\x03\x04" == substr( $gzData, 0, 4 ) ) { + if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { // ZIP file format header // Offset 6: 2 bytes, General-purpose field // Offset 26: 2 bytes, filename length // Offset 28: 2 bytes, optional field length // Offset 30: Filename field, followed by optional field, followed // immediately by data - list( , $general_purpose_flag ) = unpack( 'v', substr( $gzData, 6, 2 ) ); + list(, $general_purpose_flag) = unpack('v', substr($gzData, 6, 2)); // If the file has been compressed on the fly, 0x08 bit is set of // the general purpose field. We can use this to differentiate // between a compressed document, and a ZIP file - $zip_compressed_on_the_fly = ( 0x08 == (0x08 & $general_purpose_flag ) ); + $zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag)); - if ( ! $zip_compressed_on_the_fly ) { + if (!$zip_compressed_on_the_fly) { // Don't attempt to decode a compressed zip file return $gzData; } // Determine the first byte of data, based on the above ZIP header // offsets: - $first_file_start = array_sum( unpack( 'v2', substr( $gzData, 26, 4 ) ) ); - if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 30 + $first_file_start ) ) ) ) { + $first_file_start = array_sum(unpack('v2', substr($gzData, 26, 4))); + if (false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { return $decompressed; } return false; } // Finally fall back to straight gzinflate - if ( false !== ( $decompressed = @gzinflate( $gzData ) ) ) { + if (false !== ($decompressed = @gzinflate($gzData))) { return $decompressed; } // Fallback for all above failing, not expected, but included for // debugging and preventing regressions and to track stats - if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 2 ) ) ) ) { + if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { return $decompressed; } diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Auth.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Auth.php old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Auth.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Auth.php diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Auth/Basic.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Auth/Basic.php old mode 100755 new mode 100644 similarity index 95% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Auth/Basic.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Auth/Basic.php index b5f420e..a355cfd --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Auth/Basic.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Auth/Basic.php @@ -74,7 +74,7 @@ public function curl_before_send(&$handle) { * @param string $out HTTP header string */ public function fsockopen_header(&$out) { - $out .= "Authorization: Basic " . base64_encode($this->getAuthString()) . "\r\n"; + $out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString())); } /** diff --git a/razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie.php new file mode 100644 index 0000000..00fbbc7 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie.php @@ -0,0 +1,500 @@ +name = $name; + $this->value = $value; + $this->attributes = $attributes; + $default_flags = array( + '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(); + } + + /** + * 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 Requests_IRI $uri URI to check + * @return boolean Whether the cookie is valid for the given URI + */ + public function uri_matches(Requests_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 $string Domain to check + * @return boolean Whether the cookie is valid for the given domain + */ + public function domain_matches($string) { + if (!isset($this->attributes['domain'])) { + // Cookies created manually; cookies created by Requests will set + // the domain to the requested domain + return true; + } + + $domain_string = $this->attributes['domain']; + if ($domain_string === $string) { + // The domain string and the string 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($string) <= strlen($domain_string)) { + // For obvious reasons, the string cannot be a suffix if the domain + // is shorter than the domain string + return false; + } + + if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { + // The domain string should be a suffix of the string. + return false; + } + + $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); + if (substr($prefix, -1) !== '.') { + // The last character of the string that is not included in the + // domain string should be a %x2E (".") character. + return false; + } + + // The string 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}$#', $string); + } + + /** + * 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; + } + + $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': + // 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 Cookie header + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::format_for_header} + * @return string + */ + public function formatForHeader() { + return $this->format_for_header(); + } + + /** + * 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 = array(); + 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; + } + + /** + * Format a cookie for a Set-Cookie header + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::format_for_set_cookie} + * @return string + */ + public function formatForSetCookie() { + return $this->format_for_set_cookie(); + } + + /** + * Get the cookie value + * + * Attributes and other data can be accessed via methods. + */ + public function __toString() { + return $this->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 value (from a Set-Cookie header) + * @return Requests_Cookie Parsed cookie object + */ + public static function parse($string, $name = '', $reference_time = null) { + $parts = explode(';', $string); + $kvparts = array_shift($parts); + + if (!empty($name)) { + $value = $string; + } + 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 key are handled case-insensitively + $attributes = new Requests_Utility_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 Requests_Cookie($name, $value, $attributes, array(), $reference_time); + } + + /** + * Parse all Set-Cookie headers from request headers + * + * @param Requests_Response_Headers $headers Headers to parse from + * @param 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(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { + $cookie_headers = $headers->getValues('Set-Cookie'); + if (empty($cookie_headers)) { + return array(); + } + + $cookies = array(); + 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; + } + + /** + * Parse all Set-Cookie headers from request headers + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::parse_from_headers} + * @return string + */ + public static function parseFromHeaders(Requests_Response_Headers $headers) { + return self::parse_from_headers($headers); + } +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie/Jar.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie/Jar.php similarity index 76% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie/Jar.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie/Jar.php index 6d2f53f..69be0fb 100644 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Cookie/Jar.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Cookie/Jar.php @@ -35,7 +35,7 @@ public function __construct($cookies = array()) { * @param string|Requests_Cookie $cookie * @return Requests_Cookie */ - public function normalizeCookie($cookie, $key = null) { + public function normalize_cookie($cookie, $key = null) { if ($cookie instanceof Requests_Cookie) { return $cookie; } @@ -43,6 +43,17 @@ public function normalizeCookie($cookie, $key = null) { return Requests_Cookie::parse($cookie, $key); } + /** + * Normalise cookie data into a Requests_Cookie + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie_Jar::normalize_cookie} + * @return Requests_Cookie + */ + public function normalizeCookie($cookie, $key = null) { + return $this->normalize_cookie($cookie, $key); + } + /** * Check if the given item exists * @@ -60,8 +71,9 @@ public function offsetExists($key) { * @return string Item value */ public function offsetGet($key) { - if (!isset($this->cookies[$key])) + if (!isset($this->cookies[$key])) { return null; + } return $this->cookies[$key]; } @@ -121,12 +133,24 @@ public function register(Requests_Hooker $hooks) { * @param string $type * @param array $options */ - public function before_request(&$url, &$headers, &$data, &$type, &$options) { + public function before_request($url, &$headers, &$data, &$type, &$options) { + if (!$url instanceof Requests_IRI) { + $url = new Requests_IRI($url); + } + if (!empty($this->cookies)) { $cookies = array(); foreach ($this->cookies as $key => $cookie) { - $cookie = $this->normalizeCookie($cookie, $key); - $cookies[] = $cookie->formatForHeader(); + $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); @@ -139,7 +163,12 @@ public function before_request(&$url, &$headers, &$data, &$type, &$options) { * @var Requests_Response $response */ public function before_redirect_check(Requests_Response &$return) { - $cookies = Requests_Cookie::parseFromHeaders($return->headers); + $url = $return->url; + if (!$url instanceof Requests_IRI) { + $url = new Requests_IRI($url); + } + + $cookies = Requests_Cookie::parse_from_headers($return->headers, $url); $this->cookies = array_merge($this->cookies, $cookies); $return->cookies = $this; } diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Exception.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception.php old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Exception.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Exception.php diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Exception/HTTP.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP.php old mode 100755 new mode 100644 similarity index 87% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Exception/HTTP.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP.php index dc8954f..9ac6a87 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Exception/HTTP.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP.php @@ -31,7 +31,7 @@ class Requests_Exception_HTTP extends Requests_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 $reason Reason phrase + * @param string|null $reason Reason phrase * @param mixed $data Associated data */ public function __construct($reason = null, $data = null) { @@ -53,10 +53,14 @@ public function getReason() { /** * Get the correct exception class for a given error code * - * @param int $code HTTP status 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 'Requests_Exception_HTTP_Unknown'; + } + $class = sprintf('Requests_Exception_HTTP_%d', $code); if (class_exists($class)) { return $class; diff --git a/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP/304.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP/304.php new file mode 100644 index 0000000..6799033 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Exception/HTTP/304.php @@ -0,0 +1,27 @@ +type = $type; + } + + if ($code !== null) { + $this->code = $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 + */ + public function getReason() { + return $this->reason; + } + +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Hooker.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Hooker.php old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Hooker.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Hooker.php diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Hooks.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Hooks.php old mode 100755 new mode 100644 similarity index 92% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Hooks.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Hooks.php index 7a99b9b..2e61c73 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Hooks.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Hooks.php @@ -13,6 +13,13 @@ * @subpackage Utilities */ class Requests_Hooks implements Requests_Hooker { + /** + * Registered callbacks for each hook + * + * @var array + */ + protected $hooks = array(); + /** * Constructor */ diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/IDNAEncoder.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/IDNAEncoder.php old mode 100755 new mode 100644 similarity index 94% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/IDNAEncoder.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/IDNAEncoder.php index 53cdd0a..ebbe211 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/IDNAEncoder.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/IDNAEncoder.php @@ -7,14 +7,14 @@ * * @package Requests * @subpackage Utilities - * @see http://tools.ietf.org/html/rfc3490 IDNA specification - * @see http://tools.ietf.org/html/rfc3492 Punycode/Bootstrap specification + * @see https://tools.ietf.org/html/rfc3490 IDNA specification + * @see https://tools.ietf.org/html/rfc3492 Punycode/Bootstrap specification */ class Requests_IDNAEncoder { /** * ACE prefix used for IDNA * - * @see http://tools.ietf.org/html/rfc3490#section-5 + * @see https://tools.ietf.org/html/rfc3490#section-5 * @var string */ const ACE_PREFIX = 'xn--'; @@ -22,7 +22,7 @@ class Requests_IDNAEncoder { /**#@+ * Bootstrap constant for Punycode * - * @see http://tools.ietf.org/html/rfc3492#section-5 + * @see https://tools.ietf.org/html/rfc3492#section-5 * @var int */ const BOOTSTRAP_BASE = 36; @@ -237,6 +237,7 @@ public static function punycode_encode($input) { $h = $b = 0; // see loop # copy them to the output in order $codepoints = self::utf8_to_codepoints($input); + $extended = array(); foreach ($codepoints as $char) { if ($char < 128) { @@ -303,7 +304,6 @@ public static function punycode_encode($input) { } # output the code point for digit t + ((q - t) mod (base - t)) $digit = $t + (($q - $t) % (self::BOOTSTRAP_BASE - $t)); - //printf('needed delta is %d, encodes as "%s"' . PHP_EOL, $delta, self::digit_to_char($digit)); $output .= self::digit_to_char($digit); # let q = (q - t) div (base - t) $q = floor(($q - $t) / (self::BOOTSTRAP_BASE - $t)); @@ -311,10 +311,8 @@ public static function punycode_encode($input) { } # output the code point for digit q $output .= self::digit_to_char($q); - //printf('needed delta is %d, encodes as "%s"' . PHP_EOL, $delta, self::digit_to_char($q)); # let bias = adapt(delta, h + 1, test h equals b?) $bias = self::adapt($delta, $h + 1, $h === $b); - //printf('bias becomes %d' . PHP_EOL, $bias); # let delta = 0 $delta = 0; # increment h @@ -335,7 +333,7 @@ public static function punycode_encode($input) { /** * Convert a digit to its respective character * - * @see http://tools.ietf.org/html/rfc3492#section-5 + * @see https://tools.ietf.org/html/rfc3492#section-5 * @throws Requests_Exception On invalid digit (`idna.invalid_digit`) * * @param int $digit Digit in the range 0-35 @@ -355,7 +353,7 @@ protected static function digit_to_char($digit) { /** * Adapt the bias * - * @see http://tools.ietf.org/html/rfc3492#section-6.1 + * @see https://tools.ietf.org/html/rfc3492#section-6.1 * @param int $delta * @param int $numpoints * @param bool $firsttime diff --git a/razorpay-php/libs/Requests-1.7.0/library/Requests/IPv6.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/IPv6.php new file mode 100644 index 0000000..204dbd7 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/IPv6.php @@ -0,0 +1,190 @@ + FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 + * + * @author Alexander Merz + * @author elfrink at introweb dot nl + * @author Josh Peck + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @param string $ip An IPv6 address + * @return string The uncompressed IPv6 address + */ + public static function uncompress($ip) { + if (substr_count($ip, '::') !== 1) { + return $ip; + } + + list($ip1, $ip2) = explode('::', $ip); + $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':'); + $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':'); + + if (strpos($ip2, '.') !== false) { + $c2++; + } + // :: + if ($c1 === -1 && $c2 === -1) { + $ip = '0:0:0:0:0:0:0:0'; + } + // ::xxx + else if ($c1 === -1) { + $fill = str_repeat('0:', 7 - $c2); + $ip = str_replace('::', $fill, $ip); + } + // xxx:: + else if ($c2 === -1) { + $fill = str_repeat(':0', 7 - $c1); + $ip = str_replace('::', $fill, $ip); + } + // xxx::xxx + else { + $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); + $ip = str_replace('::', $fill, $ip); + } + return $ip; + } + + /** + * Compresses an IPv6 address + * + * RFC 4291 allows you to compress consecutive zero pieces in an address to + * '::'. This method expects a valid IPv6 address and compresses consecutive + * zero pieces to '::'. + * + * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 + * 0:0:0:0:0:0:0:1 -> ::1 + * + * @see uncompress() + * @param string $ip An IPv6 address + * @return string The compressed IPv6 address + */ + public static function compress($ip) { + // Prepare the IP to be compressed + $ip = self::uncompress($ip); + $ip_parts = self::split_v6_v4($ip); + + // Replace all leading zeros + $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); + + // Find bunches of zeros + if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) { + $max = 0; + $pos = null; + foreach ($matches[0] as $match) { + if (strlen($match[0]) > $max) { + $max = strlen($match[0]); + $pos = $match[1]; + } + } + + $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); + } + + if ($ip_parts[1] !== '') { + return implode(':', $ip_parts); + } + else { + return $ip_parts[0]; + } + } + + /** + * Splits an IPv6 address into the IPv6 and IPv4 representation parts + * + * RFC 4291 allows you to represent the last two parts of an IPv6 address + * using the standard IPv4 representation + * + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 + * + * @param string $ip An IPv6 address + * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part + */ + protected static function split_v6_v4($ip) { + if (strpos($ip, '.') !== false) { + $pos = strrpos($ip, ':'); + $ipv6_part = substr($ip, 0, $pos); + $ipv4_part = substr($ip, $pos + 1); + return array($ipv6_part, $ipv4_part); + } + else { + return array($ip, ''); + } + } + + /** + * Checks an IPv6 address + * + * Checks if the given IP is a valid IPv6 address + * + * @param string $ip An IPv6 address + * @return bool true if $ip is a valid IPv6 address + */ + public static function check_ipv6($ip) { + $ip = self::uncompress($ip); + list($ipv6, $ipv4) = self::split_v6_v4($ip); + $ipv6 = explode(':', $ipv6); + $ipv4 = explode('.', $ipv4); + if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) { + foreach ($ipv6 as $ipv6_part) { + // The section can't be empty + if ($ipv6_part === '') { + return false; + } + + // Nor can it be over four characters + if (strlen($ipv6_part) > 4) { + return false; + } + + // Remove leading zeros (this is safe because of the above) + $ipv6_part = ltrim($ipv6_part, '0'); + if ($ipv6_part === '') { + $ipv6_part = '0'; + } + + // Check the value is valid + $value = hexdec($ipv6_part); + if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { + return false; + } + } + if (count($ipv4) === 4) { + foreach ($ipv4 as $ipv4_part) { + $value = (int) $ipv4_part; + if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) { + return false; + } + } + } + return true; + } + else { + return false; + } + } +} diff --git a/razorpay-php/libs/Requests-1.7.0/library/Requests/IRI.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/IRI.php new file mode 100644 index 0000000..8dc2fa2 --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/IRI.php @@ -0,0 +1,1084 @@ + array( + 'port' => 674 + ), + 'dict' => array( + 'port' => 2628 + ), + 'file' => array( + 'ihost' => 'localhost' + ), + 'http' => array( + 'port' => 80, + ), + 'https' => array( + 'port' => 443, + ), + ); + + /** + * Return the entire IRI when you try and read the object as a string + * + * @return string + */ + public function __toString() { + return $this->get_iri(); + } + + /** + * Overload __set() to provide access via properties + * + * @param string $name Property name + * @param mixed $value Property value + */ + public function __set($name, $value) { + if (method_exists($this, 'set_' . $name)) { + call_user_func(array($this, 'set_' . $name), $value); + } + elseif ( + $name === 'iauthority' + || $name === 'iuserinfo' + || $name === 'ihost' + || $name === 'ipath' + || $name === 'iquery' + || $name === 'ifragment' + ) { + call_user_func(array($this, 'set_' . substr($name, 1)), $value); + } + } + + /** + * Overload __get() to provide access via properties + * + * @param string $name Property name + * @return mixed + */ + public function __get($name) { + // isset() returns false for null, we don't want to do that + // Also why we use array_key_exists below instead of isset() + $props = get_object_vars($this); + + if ( + $name === 'iri' || + $name === 'uri' || + $name === 'iauthority' || + $name === 'authority' + ) { + $method = 'get_' . $name; + $return = $this->$method(); + } + elseif (array_key_exists($name, $props)) { + $return = $this->$name; + } + // host -> ihost + elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) { + $name = $prop; + $return = $this->$prop; + } + // ischeme -> scheme + elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) { + $name = $prop; + $return = $this->$prop; + } + else { + trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); + $return = null; + } + + if ($return === null && isset($this->normalization[$this->scheme][$name])) { + return $this->normalization[$this->scheme][$name]; + } + else { + return $return; + } + } + + /** + * Overload __isset() to provide access via properties + * + * @param string $name Property name + * @return bool + */ + public function __isset($name) { + return (method_exists($this, 'get_' . $name) || isset($this->$name)); + } + + /** + * Overload __unset() to provide access via properties + * + * @param string $name Property name + */ + public function __unset($name) { + if (method_exists($this, 'set_' . $name)) { + call_user_func(array($this, 'set_' . $name), ''); + } + } + + /** + * Create a new IRI object, from a specified string + * + * @param string|null $iri + */ + public function __construct($iri = null) { + $this->set_iri($iri); + } + + /** + * Create a new IRI object by resolving a relative IRI + * + * Returns false if $base is not absolute, otherwise an IRI. + * + * @param IRI|string $base (Absolute) Base IRI + * @param IRI|string $relative Relative IRI + * @return IRI|false + */ + public static function absolutize($base, $relative) { + if (!($relative instanceof Requests_IRI)) { + $relative = new Requests_IRI($relative); + } + if (!$relative->is_valid()) { + return false; + } + elseif ($relative->scheme !== null) { + return clone $relative; + } + + if (!($base instanceof Requests_IRI)) { + $base = new Requests_IRI($base); + } + if ($base->scheme === null || !$base->is_valid()) { + return false; + } + + if ($relative->get_iri() !== '') { + if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) { + $target = clone $relative; + $target->scheme = $base->scheme; + } + else { + $target = new Requests_IRI; + $target->scheme = $base->scheme; + $target->iuserinfo = $base->iuserinfo; + $target->ihost = $base->ihost; + $target->port = $base->port; + if ($relative->ipath !== '') { + if ($relative->ipath[0] === '/') { + $target->ipath = $relative->ipath; + } + elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') { + $target->ipath = '/' . $relative->ipath; + } + elseif (($last_segment = strrpos($base->ipath, '/')) !== false) { + $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; + } + else { + $target->ipath = $relative->ipath; + } + $target->ipath = $target->remove_dot_segments($target->ipath); + $target->iquery = $relative->iquery; + } + else { + $target->ipath = $base->ipath; + if ($relative->iquery !== null) { + $target->iquery = $relative->iquery; + } + elseif ($base->iquery !== null) { + $target->iquery = $base->iquery; + } + } + $target->ifragment = $relative->ifragment; + } + } + else { + $target = clone $base; + $target->ifragment = null; + } + $target->scheme_normalization(); + return $target; + } + + /** + * Parse an IRI into scheme/authority/path/query/fragment segments + * + * @param string $iri + * @return array + */ + protected function parse_iri($iri) { + $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); + $has_match = preg_match('/^((?P[^:\/?#]+):)?(\/\/(?P[^\/?#]*))?(?P[^?#]*)(\?(?P[^#]*))?(#(?P.*))?$/', $iri, $match); + if (!$has_match) { + throw new Requests_Exception('Cannot parse supplied IRI', 'iri.cannot_parse', $iri); + } + + if ($match[1] === '') { + $match['scheme'] = null; + } + if (!isset($match[3]) || $match[3] === '') { + $match['authority'] = null; + } + if (!isset($match[5])) { + $match['path'] = ''; + } + if (!isset($match[6]) || $match[6] === '') { + $match['query'] = null; + } + if (!isset($match[8]) || $match[8] === '') { + $match['fragment'] = null; + } + return $match; + } + + /** + * Remove dot segments from a path + * + * @param string $input + * @return string + */ + protected function remove_dot_segments($input) { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { + // A: If the input buffer begins with a prefix of "../" or "./", + // then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", + // where "." is a complete path segment, then replace that prefix + // with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) { + $input = substr($input, 2); + } + elseif ($input === '/.') { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", + // where ".." is a complete path segment, then replace that prefix + // with "/" in the input buffer and remove the last segment and its + // preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) { + $input = substr($input, 3); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove + // that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of + // the output buffer, including the initial "/" character (if any) + // and any subsequent characters up to, but not including, the next + // "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + /** + * Replace invalid character with percent encoding + * + * @param string $string Input string + * @param string $extra_chars Valid characters not in iunreserved or + * iprivate (this is ASCII-only) + * @param bool $iprivate Allow iprivate + * @return string + */ + protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) { + // Normalize as many pct-encoded sections as possible + $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string); + + // Replace invalid percent characters + $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); + + // Add unreserved and % to $extra_chars (the latter is safe because all + // pct-encoded sections are now valid). + $extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; + + // Now replace any bytes that aren't allowed with their pct-encoded versions + $position = 0; + $strlen = strlen($string); + while (($position += strspn($string, $extra_chars, $position)) < $strlen) { + $value = ord($string[$position]); + + // Start position + $start = $position; + + // By default we are valid + $valid = true; + + // No one byte sequences are valid due to the while. + // Two byte sequence: + if (($value & 0xE0) === 0xC0) { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else { + $valid = false; + $length = 1; + $remaining = 0; + } + + if ($remaining) { + if ($position + $length <= $strlen) { + for ($position++; $remaining; $position++) { + $value = ord($string[$position]); + + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) { + $character |= ($value & 0x3F) << (--$remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte: + else { + $valid = false; + $position--; + break; + } + } + } + else { + $position = $strlen - 1; + $valid = false; + } + } + + // Percent encode anything invalid or not in ucschar + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of ucschar codepoints + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + || ( + // Everything else not in ucschar + $character > 0xD7FF && $character < 0xF900 + || $character < 0xA0 + || $character > 0xEFFFD + ) + && ( + // Everything not in iprivate, if it applies + !$iprivate + || $character < 0xE000 + || $character > 0x10FFFD + ) + ) { + // If we were a character, pretend we weren't, but rather an error. + if ($valid) { + $position--; + } + + for ($j = $start; $j <= $position; $j++) { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); + $j += 2; + $position += 2; + $strlen += 2; + } + } + } + + return $string; + } + + /** + * Callback function for preg_replace_callback. + * + * Removes sequences of percent encoded bytes that represent UTF-8 + * encoded characters in iunreserved + * + * @param array $match PCRE match + * @return string Replacement + */ + protected function remove_iunreserved_percent_encoded($match) { + // As we just have valid percent encoded sequences we can just explode + // and ignore the first member of the returned array (an empty string). + $bytes = explode('%', $match[0]); + + // Initialize the new string (this is what will be returned) and that + // there are no bytes remaining in the current sequence (unsurprising + // at the first byte!). + $string = ''; + $remaining = 0; + + // Loop over each and every byte, and set $value to its value + for ($i = 1, $len = count($bytes); $i < $len; $i++) { + $value = hexdec($bytes[$i]); + + // If we're the first byte of sequence: + if (!$remaining) { + // Start position + $start = $i; + + // By default we are valid + $valid = true; + + // One byte sequence: + if ($value <= 0x7F) { + $character = $value; + $length = 1; + } + // Two byte sequence: + elseif (($value & 0xE0) === 0xC0) { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else { + $valid = false; + $remaining = 0; + } + } + // Continuation byte: + else { + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) { + $remaining--; + $character |= ($value & 0x3F) << ($remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: + else { + $valid = false; + $remaining = 0; + $i--; + } + } + + // If we've reached the end of the current byte sequence, append it to Unicode::$data + if (!$remaining) { + // Percent encode anything invalid or not in iunreserved + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of iunreserved codepoints + || $character < 0x2D + || $character > 0xEFFFD + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + // Everything else not in iunreserved (this is all BMP) + || $character === 0x2F + || $character > 0x39 && $character < 0x41 + || $character > 0x5A && $character < 0x61 + || $character > 0x7A && $character < 0x7E + || $character > 0x7E && $character < 0xA0 + || $character > 0xD7FF && $character < 0xF900 + ) { + for ($j = $start; $j <= $i; $j++) { + $string .= '%' . strtoupper($bytes[$j]); + } + } + else { + for ($j = $start; $j <= $i; $j++) { + $string .= chr(hexdec($bytes[$j])); + } + } + } + } + + // If we have any bytes left over they are invalid (i.e., we are + // mid-way through a multi-byte sequence) + if ($remaining) { + for ($j = $start; $j < $len; $j++) { + $string .= '%' . strtoupper($bytes[$j]); + } + } + + return $string; + } + + protected function scheme_normalization() { + if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { + $this->iuserinfo = null; + } + if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { + $this->ihost = null; + } + if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { + $this->port = null; + } + if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { + $this->ipath = ''; + } + if (isset($this->ihost) && empty($this->ipath)) { + $this->ipath = '/'; + } + if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { + $this->iquery = null; + } + if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { + $this->ifragment = null; + } + } + + /** + * Check if the object represents a valid IRI. This needs to be done on each + * call as some things change depending on another part of the IRI. + * + * @return bool + */ + public function is_valid() { + $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; + if ($this->ipath !== '' && + ( + $isauthority && $this->ipath[0] !== '/' || + ( + $this->scheme === null && + !$isauthority && + strpos($this->ipath, ':') !== false && + (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) + ) + ) + ) { + return false; + } + + return true; + } + + /** + * Set the entire IRI. Returns true on success, false on failure (if there + * are any invalid characters). + * + * @param string $iri + * @return bool + */ + protected function set_iri($iri) { + static $cache; + if (!$cache) { + $cache = array(); + } + + if ($iri === null) { + return true; + } + if (isset($cache[$iri])) { + list($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return) = $cache[$iri]; + return $return; + } + + $parsed = $this->parse_iri((string) $iri); + + $return = $this->set_scheme($parsed['scheme']) + && $this->set_authority($parsed['authority']) + && $this->set_path($parsed['path']) + && $this->set_query($parsed['query']) + && $this->set_fragment($parsed['fragment']); + + $cache[$iri] = array($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return); + return $return; + } + + /** + * Set the scheme. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $scheme + * @return bool + */ + protected function set_scheme($scheme) { + if ($scheme === null) { + $this->scheme = null; + } + elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) { + $this->scheme = null; + return false; + } + else { + $this->scheme = strtolower($scheme); + } + return true; + } + + /** + * Set the authority. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $authority + * @return bool + */ + protected function set_authority($authority) { + static $cache; + if (!$cache) { + $cache = array(); + } + + if ($authority === null) { + $this->iuserinfo = null; + $this->ihost = null; + $this->port = null; + return true; + } + if (isset($cache[$authority])) { + list($this->iuserinfo, + $this->ihost, + $this->port, + $return) = $cache[$authority]; + + return $return; + } + + $remaining = $authority; + if (($iuserinfo_end = strrpos($remaining, '@')) !== false) { + $iuserinfo = substr($remaining, 0, $iuserinfo_end); + $remaining = substr($remaining, $iuserinfo_end + 1); + } + else { + $iuserinfo = null; + } + if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) { + $port = substr($remaining, $port_start + 1); + if ($port === false || $port === '') { + $port = null; + } + $remaining = substr($remaining, 0, $port_start); + } + else { + $port = null; + } + + $return = $this->set_userinfo($iuserinfo) && + $this->set_host($remaining) && + $this->set_port($port); + + $cache[$authority] = array($this->iuserinfo, + $this->ihost, + $this->port, + $return); + + return $return; + } + + /** + * Set the iuserinfo. + * + * @param string $iuserinfo + * @return bool + */ + protected function set_userinfo($iuserinfo) { + if ($iuserinfo === null) { + $this->iuserinfo = null; + } + else { + $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); + $this->scheme_normalization(); + } + + return true; + } + + /** + * Set the ihost. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $ihost + * @return bool + */ + protected function set_host($ihost) { + if ($ihost === null) { + $this->ihost = null; + return true; + } + if (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') { + if (Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) { + $this->ihost = '[' . Requests_IPv6::compress(substr($ihost, 1, -1)) . ']'; + } + else { + $this->ihost = null; + return false; + } + } + else { + $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); + + // Lowercase, but ignore pct-encoded sections (as they should + // remain uppercase). This must be done after the previous step + // as that can add unescaped characters. + $position = 0; + $strlen = strlen($ihost); + while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) { + if ($ihost[$position] === '%') { + $position += 3; + } + else { + $ihost[$position] = strtolower($ihost[$position]); + $position++; + } + } + + $this->ihost = $ihost; + } + + $this->scheme_normalization(); + + return true; + } + + /** + * Set the port. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $port + * @return bool + */ + protected function set_port($port) { + if ($port === null) { + $this->port = null; + return true; + } + + if (strspn($port, '0123456789') === strlen($port)) { + $this->port = (int) $port; + $this->scheme_normalization(); + return true; + } + + $this->port = null; + return false; + } + + /** + * Set the ipath. + * + * @param string $ipath + * @return bool + */ + protected function set_path($ipath) { + static $cache; + if (!$cache) { + $cache = array(); + } + + $ipath = (string) $ipath; + + if (isset($cache[$ipath])) { + $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; + } + else { + $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); + $removed = $this->remove_dot_segments($valid); + + $cache[$ipath] = array($valid, $removed); + $this->ipath = ($this->scheme !== null) ? $removed : $valid; + } + $this->scheme_normalization(); + return true; + } + + /** + * Set the iquery. + * + * @param string $iquery + * @return bool + */ + protected function set_query($iquery) { + if ($iquery === null) { + $this->iquery = null; + } + else { + $this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); + $this->scheme_normalization(); + } + return true; + } + + /** + * Set the ifragment. + * + * @param string $ifragment + * @return bool + */ + protected function set_fragment($ifragment) { + if ($ifragment === null) { + $this->ifragment = null; + } + else { + $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); + $this->scheme_normalization(); + } + return true; + } + + /** + * Convert an IRI to a URI (or parts thereof) + * + * @param string|bool IRI to convert (or false from {@see get_iri}) + * @return string|false URI if IRI is valid, false otherwise. + */ + protected function to_uri($string) { + if (!is_string($string)) { + return false; + } + + static $non_ascii; + if (!$non_ascii) { + $non_ascii = implode('', range("\x80", "\xFF")); + } + + $position = 0; + $strlen = strlen($string); + while (($position += strcspn($string, $non_ascii, $position)) < $strlen) { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); + $position += 3; + $strlen += 2; + } + + return $string; + } + + /** + * Get the complete IRI + * + * @return string + */ + protected function get_iri() { + if (!$this->is_valid()) { + return false; + } + + $iri = ''; + if ($this->scheme !== null) { + $iri .= $this->scheme . ':'; + } + if (($iauthority = $this->get_iauthority()) !== null) { + $iri .= '//' . $iauthority; + } + $iri .= $this->ipath; + if ($this->iquery !== null) { + $iri .= '?' . $this->iquery; + } + if ($this->ifragment !== null) { + $iri .= '#' . $this->ifragment; + } + + return $iri; + } + + /** + * Get the complete URI + * + * @return string + */ + protected function get_uri() { + return $this->to_uri($this->get_iri()); + } + + /** + * Get the complete iauthority + * + * @return string + */ + protected function get_iauthority() { + if ($this->iuserinfo === null && $this->ihost === null && $this->port === null) { + return null; + } + + $iauthority = ''; + if ($this->iuserinfo !== null) { + $iauthority .= $this->iuserinfo . '@'; + } + if ($this->ihost !== null) { + $iauthority .= $this->ihost; + } + if ($this->port !== null) { + $iauthority .= ':' . $this->port; + } + return $iauthority; + } + + /** + * Get the complete authority + * + * @return string + */ + protected function get_authority() { + $iauthority = $this->get_iauthority(); + if (is_string($iauthority)) { + return $this->to_uri($iauthority); + } + else { + return $iauthority; + } + } +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Proxy.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Proxy.php similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Proxy.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Proxy.php diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Proxy/HTTP.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Proxy/HTTP.php similarity index 83% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Proxy/HTTP.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Proxy/HTTP.php index 1311f6f..6b4aba8 100644 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Proxy/HTTP.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Proxy/HTTP.php @@ -67,7 +67,7 @@ public function __construct($args = null) { $this->use_authentication = true; } else { - throw new Requests_Exception( 'Invalid number of arguments', 'proxyhttpbadargs'); + throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs'); } } } @@ -87,7 +87,7 @@ public function register(Requests_Hooks &$hooks) { $hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket')); $hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path')); - if( $this->use_authentication ) { + if ($this->use_authentication) { $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); } } @@ -112,9 +112,9 @@ public function curl_before_send(&$handle) { * Alter remote socket information before opening socket connection * * @since 1.6 - * @param string $out HTTP header string + * @param string $remote_socket Socket connection string */ - public function fsockopen_remote_socket( &$remote_socket ) { + public function fsockopen_remote_socket(&$remote_socket) { $remote_socket = $this->proxy; } @@ -122,9 +122,10 @@ public function fsockopen_remote_socket( &$remote_socket ) { * Alter remote path before getting stream data * * @since 1.6 - * @param string $out HTTP header string + * @param string $path Path to send in HTTP request string ("GET ...") + * @param string $url Full URL we're requesting */ - public function fsockopen_remote_host_path( &$path, $url ) { + public function fsockopen_remote_host_path(&$path, $url) { $path = $url; } @@ -134,8 +135,8 @@ public function fsockopen_remote_host_path( &$path, $url ) { * @since 1.6 * @param string $out HTTP header string */ - public function fsockopen_header( &$out ) { - $out .= "Proxy-Authorization: Basic " . base64_encode($this->get_auth_string()) . "\r\n"; + public function fsockopen_header(&$out) { + $out .= sprintf("Proxy-Authorization: Basic %s\r\n", base64_encode($this->get_auth_string())); } /** diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Response.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Response.php old mode 100755 new mode 100644 similarity index 74% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Response.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Response.php index 684d2d6..3152fb6 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Response.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Response.php @@ -18,61 +18,88 @@ class Requests_Response { */ public function __construct() { $this->headers = new Requests_Response_Headers(); + $this->cookies = new Requests_Cookie_Jar(); } /** * Response body + * * @var string */ public $body = ''; /** * Raw HTTP data from the transport + * * @var string */ public $raw = ''; /** * Headers, as an associative array - * @var array + * + * @var Requests_Response_Headers Array-like object representing headers */ public $headers = array(); /** * Status code, false if non-blocking + * * @var integer|boolean */ public $status_code = false; + /** + * Protocol version, false if non-blocking + * @var float|boolean + */ + public $protocol_version = false; + /** * Whether the request succeeded or not + * * @var boolean */ public $success = false; /** * Number of redirects the request used + * * @var integer */ public $redirects = 0; /** * URL requested + * * @var string */ public $url = ''; /** * Previous requests (from redirects) + * * @var array Array of Requests_Response objects */ public $history = array(); /** * Cookies from the request + * + * @var Requests_Cookie_Jar Array-like object representing a cookie jar */ public $cookies = array(); + /** + * Is the response a redirect? + * + * @return boolean True if redirect (3xx status), false if not. + */ + public function is_redirect() { + $code = $this->status_code; + return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400; + } + /** * Throws an exception if the request was not successful * @@ -81,15 +108,14 @@ public function __construct() { * @param boolean $allow_redirects Set to false to throw on a 3xx as well */ public function throw_for_status($allow_redirects = true) { - if ($this->status_code >= 300 && $this->status_code < 400) { + if ($this->is_redirect()) { if (!$allow_redirects) { throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this); } } - elseif (!$this->success) { $exception = Requests_Exception_HTTP::get_class($this->status_code); throw new $exception(null, $this); } } -} \ No newline at end of file +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Response/Headers.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Response/Headers.php old mode 100755 new mode 100644 similarity index 94% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Response/Headers.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Response/Headers.php index aa90725..cc6a208 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Response/Headers.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Response/Headers.php @@ -25,8 +25,9 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona */ public function offsetGet($key) { $key = strtolower($key); - if (!isset($this->data[$key])) + if (!isset($this->data[$key])) { return null; + } return $this->flatten($this->data[$key]); } @@ -61,8 +62,9 @@ public function offsetSet($key, $value) { */ public function getValues($key) { $key = strtolower($key); - if (!isset($this->data[$key])) + if (!isset($this->data[$key])) { return null; + } return $this->data[$key]; } @@ -77,8 +79,9 @@ public function getValues($key) { * @return string Flattened value */ public function flatten($value) { - if (is_array($value)) + if (is_array($value)) { $value = implode(',', $value); + } return $value; } diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/SSL.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/SSL.php old mode 100755 new mode 100644 similarity index 95% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/SSL.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/SSL.php index 1ddd894..2b03768 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/SSL.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/SSL.php @@ -22,11 +22,11 @@ class Requests_SSL { * names, leading things like 'https://www.github.com/' to be invalid. * Instead * - * @see http://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1 + * @see https://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1 * * @throws Requests_Exception On not obtaining a match for the host (`fsockopen.ssl.no_match`) * @param string $host Host name to verify against - * @param resource $context Stream context + * @param array $cert Certificate data from openssl_x509_parse() * @return bool */ public static function verify_certificate($host, $cert) { @@ -44,8 +44,9 @@ public static function verify_certificate($host, $cert) { $altnames = explode(',', $cert['extensions']['subjectAltName']); foreach ($altnames as $altname) { $altname = trim($altname); - if (strpos($altname, 'DNS:') !== 0) + if (strpos($altname, 'DNS:') !== 0) { continue; + } $has_dns_alt = true; diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Session.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Session.php old mode 100755 new mode 100644 similarity index 92% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Session.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Session.php index bdcb1dd..af14bbe --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Session.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Session.php @@ -81,8 +81,9 @@ public function __construct($url = null, $headers = array(), $data = array(), $o * @return mixed|null Property value, null if none found */ public function __get($key) { - if (isset($this->options[$key])) + if (isset($this->options[$key])) { return $this->options[$key]; + } return null; } @@ -112,7 +113,9 @@ public function __isset($key) { * @param string $key Property key */ public function __unset($key) { - $this->options[$key] = null; + if (isset($this->options[$key])) { + unset($this->options[$key]); + } } /**#@+ @@ -172,7 +175,7 @@ public function put($url, $headers = array(), $data = array(), $options = array( * Note: Unlike {@see post} and {@see put}, `$headers` is required, as the * specification recommends that should send an ETag * - * @link http://tools.ietf.org/html/rfc5789 + * @link https://tools.ietf.org/html/rfc5789 */ public function patch($url, $headers, $data = array(), $options = array()) { return $this->request($url, $headers, $data, Requests::PATCH, $options); @@ -191,7 +194,7 @@ public function patch($url, $headers, $data = array(), $options = array()) { * * @param string $url URL to request * @param array $headers Extra headers to send with the request - * @param array $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests * @param string $type HTTP request type (use Requests constants) * @param array $options Options for the request (see {@see Requests::request}) * @return Requests_Response @@ -236,9 +239,18 @@ protected function merge_request($request, $merge_options = true) { $request['url'] = Requests_IRI::absolutize($this->url, $request['url']); $request['url'] = $request['url']->uri; } + + if (empty($request['headers'])) { + $request['headers'] = array(); + } $request['headers'] = array_merge($this->headers, $request['headers']); - if (is_array($request['data']) && is_array($this->data)) { + if (empty($request['data'])) { + if (is_array($this->data)) { + $request['data'] = $this->data; + } + } + elseif (is_array($request['data']) && is_array($this->data)) { $request['data'] = array_merge($this->data, $request['data']); } @@ -248,6 +260,7 @@ protected function merge_request($request, $merge_options = true) { // Disallow forcing the type, as that's a per request setting unset($request['options']['type']); } + return $request; } -} \ No newline at end of file +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport.php old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Transport.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Transport.php diff --git a/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/cURL.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/cURL.php new file mode 100644 index 0000000..4429edb --- /dev/null +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/cURL.php @@ -0,0 +1,542 @@ +version = $curl['version_number']; + $this->handle = curl_init(); + + curl_setopt($this->handle, CURLOPT_HEADER, false); + curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); + if ($this->version >= self::CURL_7_10_5) { + curl_setopt($this->handle, CURLOPT_ENCODING, ''); + } + if (defined('CURLOPT_PROTOCOLS')) { + curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + } + if (defined('CURLOPT_REDIR_PROTOCOLS')) { + curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + } + } + + /** + * Destructor + */ + public function __destruct() { + if (is_resource($this->handle)) { + curl_close($this->handle); + } + } + + /** + * Perform a request + * + * @throws Requests_Exception On a cURL error (`curlerror`) + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + * @return string Raw HTTP result + */ + public function request($url, $headers = array(), $data = array(), $options = array()) { + $this->hooks = $options['hooks']; + + $this->setup_handle($url, $headers, $data, $options); + + $options['hooks']->dispatch('curl.before_send', array(&$this->handle)); + + if ($options['filename'] !== false) { + $this->stream_handle = fopen($options['filename'], 'wb'); + } + + $this->response_data = ''; + $this->response_bytes = 0; + $this->response_byte_limit = false; + if ($options['max_bytes'] !== false) { + $this->response_byte_limit = $options['max_bytes']; + } + + if (isset($options['verify'])) { + if ($options['verify'] === false) { + curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); + } + elseif (is_string($options['verify'])) { + curl_setopt($this->handle, CURLOPT_CAINFO, $options['verify']); + } + } + + if (isset($options['verifyname']) && $options['verifyname'] === false) { + curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); + } + + curl_exec($this->handle); + $response = $this->response_data; + + $options['hooks']->dispatch('curl.after_send', array()); + + if (curl_errno($this->handle) === 23 || curl_errno($this->handle) === 61) { + // Reset encoding and try again + curl_setopt($this->handle, CURLOPT_ENCODING, 'none'); + + $this->response_data = ''; + $this->response_bytes = 0; + curl_exec($this->handle); + $response = $this->response_data; + } + + $this->process_response($response, $options); + + // Need to remove the $this reference from the curl handle. + // Otherwise Requests_Transport_cURL wont be garbage collected and the curl_close() will never be called. + curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); + curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); + + return $this->headers; + } + + /** + * Send multiple requests simultaneously + * + * @param array $requests Request data + * @param array $options Global options + * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well) + */ + public function request_multiple($requests, $options) { + // If you're not requesting, we can't get any responses ¯\_(ツ)_/¯ + if (empty($requests)) { + return array(); + } + + $multihandle = curl_multi_init(); + $subrequests = array(); + $subhandles = array(); + + $class = get_class($this); + foreach ($requests as $id => $request) { + $subrequests[$id] = new $class(); + $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']); + $request['options']['hooks']->dispatch('curl.before_multi_add', array(&$subhandles[$id])); + curl_multi_add_handle($multihandle, $subhandles[$id]); + } + + $completed = 0; + $responses = array(); + + $request['options']['hooks']->dispatch('curl.before_multi_exec', array(&$multihandle)); + + do { + $active = false; + + do { + $status = curl_multi_exec($multihandle, $active); + } + while ($status === CURLM_CALL_MULTI_PERFORM); + + $to_process = array(); + + // Read the information as needed + while ($done = curl_multi_info_read($multihandle)) { + $key = array_search($done['handle'], $subhandles, true); + if (!isset($to_process[$key])) { + $to_process[$key] = $done; + } + } + + // Parse the finished requests before we start getting the new ones + foreach ($to_process as $key => $done) { + $options = $requests[$key]['options']; + if (CURLE_OK !== $done['result']) { + //get error string for handle. + $reason = curl_error($done['handle']); + $exception = new Requests_Exception_Transport_cURL( + $reason, + Requests_Exception_Transport_cURL::EASY, + $done['handle'], + $done['result'] + ); + $responses[$key] = $exception; + $options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key])); + } + else { + $responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options); + + $options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key])); + } + + curl_multi_remove_handle($multihandle, $done['handle']); + curl_close($done['handle']); + + if (!is_string($responses[$key])) { + $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); + } + $completed++; + } + } + while ($active || $completed < count($subrequests)); + + $request['options']['hooks']->dispatch('curl.after_multi_exec', array(&$multihandle)); + + curl_multi_close($multihandle); + + return $responses; + } + + /** + * Get the cURL handle for use in a multi-request + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + * @return resource Subrequest's cURL handle + */ + public function &get_subrequest_handle($url, $headers, $data, $options) { + $this->setup_handle($url, $headers, $data, $options); + + if ($options['filename'] !== false) { + $this->stream_handle = fopen($options['filename'], 'wb'); + } + + $this->response_data = ''; + $this->response_bytes = 0; + $this->response_byte_limit = false; + if ($options['max_bytes'] !== false) { + $this->response_byte_limit = $options['max_bytes']; + } + $this->hooks = $options['hooks']; + + return $this->handle; + } + + /** + * Setup the cURL handle for the given data + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + */ + protected function setup_handle($url, $headers, $data, $options) { + $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); + + // Force closing the connection for old versions of cURL (<7.22). + if ( ! isset( $headers['Connection'] ) ) { + $headers['Connection'] = 'close'; + } + + $headers = Requests::flatten($headers); + + if (!empty($data)) { + $data_format = $options['data_format']; + + if ($data_format === 'query') { + $url = self::format_get($url, $data); + $data = ''; + } + elseif (!is_string($data)) { + $data = http_build_query($data, null, '&'); + } + } + + switch ($options['type']) { + case Requests::POST: + curl_setopt($this->handle, CURLOPT_POST, true); + curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); + break; + case Requests::HEAD: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + curl_setopt($this->handle, CURLOPT_NOBODY, true); + break; + case Requests::TRACE: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + break; + case Requests::PATCH: + case Requests::PUT: + case Requests::DELETE: + case Requests::OPTIONS: + default: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + if (!empty($data)) { + curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); + } + } + + // cURL requires a minimum timeout of 1 second when using the system + // DNS resolver, as it uses `alarm()`, which is second resolution only. + // There's no way to detect which DNS resolver is being used from our + // end, so we need to round up regardless of the supplied timeout. + // + // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609 + $timeout = max($options['timeout'], 1); + + if (is_int($timeout) || $this->version < self::CURL_7_16_2) { + curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); + } + else { + curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); + } + + if (is_int($options['connect_timeout']) || $this->version < self::CURL_7_16_2) { + curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options['connect_timeout'])); + } + else { + curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options['connect_timeout'] * 1000)); + } + curl_setopt($this->handle, CURLOPT_URL, $url); + curl_setopt($this->handle, CURLOPT_REFERER, $url); + curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); + if (!empty($headers)) { + curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); + } + if ($options['protocol_version'] === 1.1) { + curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + } + else { + curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + } + + if (true === $options['blocking']) { + curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); + curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body')); + curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); + } + } + + /** + * Process a response + * + * @param string $response Response data from the body + * @param array $options Request options + * @return string HTTP response data including headers + */ + public function process_response($response, $options) { + if ($options['blocking'] === false) { + $fake_headers = ''; + $options['hooks']->dispatch('curl.after_request', array(&$fake_headers)); + return false; + } + if ($options['filename'] !== false) { + fclose($this->stream_handle); + $this->headers = trim($this->headers); + } + else { + $this->headers .= $response; + } + + if (curl_errno($this->handle)) { + $error = sprintf( + 'cURL error %s: %s', + curl_errno($this->handle), + curl_error($this->handle) + ); + throw new Requests_Exception($error, 'curlerror', $this->handle); + } + $this->info = curl_getinfo($this->handle); + + $options['hooks']->dispatch('curl.after_request', array(&$this->headers, &$this->info)); + return $this->headers; + } + + /** + * Collect the headers as they are received + * + * @param resource $handle cURL resource + * @param string $headers Header string + * @return integer Length of provided header + */ + public function stream_headers($handle, $headers) { + // Why do we do this? cURL will send both the final response and any + // interim responses, such as a 100 Continue. We don't need that. + // (We may want to keep this somewhere just in case) + if ($this->done_headers) { + $this->headers = ''; + $this->done_headers = false; + } + $this->headers .= $headers; + + if ($headers === "\r\n") { + $this->done_headers = true; + } + return strlen($headers); + } + + /** + * Collect data as it's received + * + * @since 1.6.1 + * + * @param resource $handle cURL resource + * @param string $data Body data + * @return integer Length of provided data + */ + public function stream_body($handle, $data) { + $this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit)); + $data_length = strlen($data); + + // Are we limiting the response size? + if ($this->response_byte_limit) { + if ($this->response_bytes === $this->response_byte_limit) { + // Already at maximum, move on + return $data_length; + } + + if (($this->response_bytes + $data_length) > $this->response_byte_limit) { + // Limit the length + $limited_length = ($this->response_byte_limit - $this->response_bytes); + $data = substr($data, 0, $limited_length); + } + } + + if ($this->stream_handle) { + fwrite($this->stream_handle, $data); + } + else { + $this->response_data .= $data; + } + + $this->response_bytes += strlen($data); + return $data_length; + } + + /** + * Format a URL given GET data + * + * @param string $url + * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query} + * @return string URL with data + */ + protected static function format_get($url, $data) { + if (!empty($data)) { + $url_parts = parse_url($url); + if (empty($url_parts['query'])) { + $query = $url_parts['query'] = ''; + } + else { + $query = $url_parts['query']; + } + + $query .= '&' . http_build_query($data, null, '&'); + $query = trim($query, '&'); + + if (empty($url_parts['query'])) { + $url .= '?' . $query; + } + else { + $url = str_replace($url_parts['query'], $query, $url); + } + } + return $url; + } + + /** + * Whether this transport is valid + * + * @codeCoverageIgnore + * @return boolean True if the transport is valid, false otherwise. + */ + public static function test($capabilities = array()) { + if (!function_exists('curl_init') || !function_exists('curl_exec')) { + return false; + } + + // If needed, check that our installed curl version supports SSL + if (isset($capabilities['ssl']) && $capabilities['ssl']) { + $curl_version = curl_version(); + if (!(CURL_VERSION_SSL & $curl_version['features'])) { + return false; + } + } + + return true; + } +} diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cacert.pem b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/cacert.pem old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cacert.pem rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/cacert.pem diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/fsockopen.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/fsockopen.php old mode 100755 new mode 100644 similarity index 62% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/fsockopen.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/fsockopen.php index 275e959..21cb56d --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/fsockopen.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Transport/fsockopen.php @@ -13,6 +13,13 @@ * @subpackage Transport */ class Requests_Transport_fsockopen implements Requests_Transport { + /** + * Second to microsecond conversion + * + * @var integer + */ + const SECOND_IN_MICROSECONDS = 1000000; + /** * Raw HTTP data * @@ -23,10 +30,17 @@ class Requests_Transport_fsockopen implements Requests_Transport { /** * Stream metadata * - * @var array Associative array of properties, see {@see http://php.net/stream_get_meta_data} + * @var array Associative array of properties, see {@see https://secure.php.net/stream_get_meta_data} */ public $info; + /** + * What's the maximum number of bytes we should keep? + * + * @var int|bool Byte count, or false if no limit. + */ + protected $max_bytes = false; + protected $connect_error = ''; /** @@ -45,14 +59,20 @@ public function request($url, $headers = array(), $data = array(), $options = ar $options['hooks']->dispatch('fsockopen.before_request'); $url_parts = parse_url($url); + if (empty($url_parts)) { + throw new Requests_Exception('Invalid URL.', 'invalidurl', $url); + } $host = $url_parts['host']; $context = stream_context_create(); $verifyname = false; + $case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers); // HTTPS support if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { $remote_socket = 'ssl://' . $host; - $url_parts['port'] = 443; + if (!isset($url_parts['port'])) { + $url_parts['port'] = 443; + } $context_options = array( 'verify_peer' => true, @@ -72,12 +92,14 @@ public function request($url, $headers = array(), $data = array(), $options = ar if (isset($options['verify'])) { if ($options['verify'] === false) { $context_options['verify_peer'] = false; - } elseif (is_string($options['verify'])) { + } + elseif (is_string($options['verify'])) { $context_options['cafile'] = $options['verify']; } } if (isset($options['verifyname']) && $options['verifyname'] === false) { + $context_options['verify_peer_name'] = false; $verifyname = false; } @@ -87,8 +109,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar $remote_socket = 'tcp://' . $host; } - $proxy = isset( $options['proxy'] ); - $proxy_auth = $proxy && isset( $options['proxy_username'] ) && isset( $options['proxy_password'] ); + $this->max_bytes = $options['max_bytes']; if (!isset($url_parts['port'])) { $url_parts['port'] = 80; @@ -99,78 +120,73 @@ public function request($url, $headers = array(), $data = array(), $options = ar $options['hooks']->dispatch('fsockopen.remote_socket', array(&$remote_socket)); - $fp = stream_socket_client($remote_socket, $errno, $errstr, $options['timeout'], STREAM_CLIENT_CONNECT, $context); + $socket = stream_socket_client($remote_socket, $errno, $errstr, ceil($options['connect_timeout']), STREAM_CLIENT_CONNECT, $context); restore_error_handler(); - if ($verifyname) { - if (!$this->verify_certificate_from_context($host, $context)) { - throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match'); - } + if ($verifyname && !$this->verify_certificate_from_context($host, $context)) { + throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match'); } - if (!$fp) { + if (!$socket) { if ($errno === 0) { // Connection issue throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error'); } - else { - throw new Requests_Exception($errstr, 'fsockopenerror'); - return; - } + + throw new Requests_Exception($errstr, 'fsockopenerror', null, $errno); + } + + $data_format = $options['data_format']; + + if ($data_format === 'query') { + $path = self::format_get($url_parts, $data); + $data = ''; + } + else { + $path = self::format_get($url_parts, array()); } + $options['hooks']->dispatch('fsockopen.remote_host_path', array(&$path, $url)); + $request_body = ''; - $out = ''; - switch ($options['type']) { - case Requests::POST: - case Requests::PUT: - case Requests::PATCH: - if (isset($url_parts['path'])) { - $path = $url_parts['path']; - if (isset($url_parts['query'])) { - $path .= '?' . $url_parts['query']; - } - } - else { - $path = '/'; - } + $out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']); - $options['hooks']->dispatch( 'fsockopen.remote_host_path', array( &$path, $url ) ); - $out = $options['type'] . " $path HTTP/1.0\r\n"; + if ($options['type'] !== Requests::TRACE) { + if (is_array($data)) { + $request_body = http_build_query($data, null, '&'); + } + else { + $request_body = $data; + } - if (is_array($data)) { - $request_body = http_build_query($data, null, '&'); - } - else { - $request_body = $data; - } - if (empty($headers['Content-Length'])) { + if (!empty($data)) { + if (!isset($case_insensitive_headers['Content-Length'])) { $headers['Content-Length'] = strlen($request_body); } - if (empty($headers['Content-Type'])) { + + if (!isset($case_insensitive_headers['Content-Type'])) { $headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; } - break; - case Requests::HEAD: - case Requests::GET: - case Requests::DELETE: - $path = self::format_get($url_parts, $data); - $options['hooks']->dispatch('fsockopen.remote_host_path', array(&$path, $url)); - $out = $options['type'] . " $path HTTP/1.0\r\n"; - break; + } + } + + if (!isset($case_insensitive_headers['Host'])) { + $out .= sprintf('Host: %s', $url_parts['host']); + + if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) { + $out .= ':' . $url_parts['port']; + } + $out .= "\r\n"; } - $out .= "Host: {$url_parts['host']}"; - if ($url_parts['port'] !== 80) { - $out .= ":{$url_parts['port']}"; + if (!isset($case_insensitive_headers['User-Agent'])) { + $out .= sprintf("User-Agent: %s\r\n", $options['useragent']); } - $out .= "\r\n"; - $out .= "User-Agent: {$options['useragent']}\r\n"; $accept_encoding = $this->accept_encoding(); - if (!empty($accept_encoding)) { - $out .= "Accept-Encoding: $accept_encoding\r\n"; + if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) { + $out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding); } $headers = Requests::flatten($headers); @@ -185,63 +201,93 @@ public function request($url, $headers = array(), $data = array(), $options = ar $out .= "\r\n"; } - $out .= "Connection: Close\r\n\r\n" . $request_body; + if (!isset($case_insensitive_headers['Connection'])) { + $out .= "Connection: Close\r\n"; + } + + $out .= "\r\n" . $request_body; $options['hooks']->dispatch('fsockopen.before_send', array(&$out)); - fwrite($fp, $out); - $options['hooks']->dispatch('fsockopen.after_send', array(&$fake_headers)); + fwrite($socket, $out); + $options['hooks']->dispatch('fsockopen.after_send', array($out)); if (!$options['blocking']) { - fclose($fp); + fclose($socket); $fake_headers = ''; $options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers)); return ''; } - stream_set_timeout($fp, $options['timeout']); - $this->info = stream_get_meta_data($fp); - - $this->headers = ''; - $this->info = stream_get_meta_data($fp); - if (!$options['filename']) { - while (!feof($fp)) { - $this->info = stream_get_meta_data($fp); - if ($this->info['timed_out']) { - throw new Requests_Exception('fsocket timed out', 'timeout'); - } - - $this->headers .= fread($fp, 1160); - } + $timeout_sec = (int) floor($options['timeout']); + if ($timeout_sec == $options['timeout']) { + $timeout_msec = 0; } else { + $timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS; + } + stream_set_timeout($socket, $timeout_sec, $timeout_msec); + + $response = $body = $headers = ''; + $this->info = stream_get_meta_data($socket); + $size = 0; + $doingbody = false; + $download = false; + if ($options['filename']) { $download = fopen($options['filename'], 'wb'); - $doingbody = false; - $response = ''; - while (!feof($fp)) { - $this->info = stream_get_meta_data($fp); - if ($this->info['timed_out']) { - throw new Requests_Exception('fsocket timed out', 'timeout'); + } + + while (!feof($socket)) { + $this->info = stream_get_meta_data($socket); + if ($this->info['timed_out']) { + throw new Requests_Exception('fsocket timed out', 'timeout'); + } + + $block = fread($socket, Requests::BUFFER_SIZE); + if (!$doingbody) { + $response .= $block; + if (strpos($response, "\r\n\r\n")) { + list($headers, $block) = explode("\r\n\r\n", $response, 2); + $doingbody = true; + } + } + + // Are we in body mode now? + if ($doingbody) { + $options['hooks']->dispatch('request.progress', array($block, $size, $this->max_bytes)); + $data_length = strlen($block); + if ($this->max_bytes) { + // Have we already hit a limit? + if ($size === $this->max_bytes) { + continue; + } + if (($size + $data_length) > $this->max_bytes) { + // Limit the length + $limited_length = ($this->max_bytes - $size); + $block = substr($block, 0, $limited_length); + } } - $block = fread($fp, 1160); - if ($doingbody) { + $size += strlen($block); + if ($download) { fwrite($download, $block); } else { - $response .= $block; - if (strpos($response, "\r\n\r\n")) { - list($this->headers, $block) = explode("\r\n\r\n", $response, 2); - $doingbody = true; - fwrite($download, $block); - } + $body .= $block; } } + } + $this->headers = $headers; + + if ($download) { fclose($download); } - fclose($fp); + else { + $this->headers .= "\r\n\r\n" . $body; + } + fclose($socket); - $options['hooks']->dispatch('fsockopen.after_request', array(&$this->headers)); + $options['hooks']->dispatch('fsockopen.after_request', array(&$this->headers, &$this->info)); return $this->headers; } @@ -298,13 +344,14 @@ protected static function accept_encoding() { * Format a URL given GET data * * @param array $url_parts - * @param array|object $data Data to build query using, see {@see http://php.net/http_build_query} + * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query} * @return string URL with data */ protected static function format_get($url_parts, $data) { if (!empty($data)) { - if (empty($url_parts['query'])) + if (empty($url_parts['query'])) { $url_parts['query'] = ''; + } $url_parts['query'] .= '&' . http_build_query($data, null, '&'); $url_parts['query'] = trim($url_parts['query'], '&'); @@ -347,7 +394,7 @@ public function connect_error_handler($errno, $errstr) { * names, leading things like 'https://www.github.com/' to be invalid. * Instead * - * @see http://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1 + * @see https://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1 * * @throws Requests_Exception On failure to connect via TLS (`fsockopen.ssl.connect_error`) * @throws Requests_Exception On not obtaining a match for the host (`fsockopen.ssl.no_match`) @@ -376,17 +423,20 @@ public function verify_certificate_from_context($host, $context) { * @return boolean True if the transport is valid, false otherwise. */ public static function test($capabilities = array()) { - if (!function_exists('fsockopen')) + if (!function_exists('fsockopen')) { return false; + } // If needed, check that streams support SSL - if (isset( $capabilities['ssl'] ) && $capabilities['ssl']) { - if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) + if (isset($capabilities['ssl']) && $capabilities['ssl']) { + if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) { return false; + } // Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156 - if (defined('HHVM_VERSION')) + if (defined('HHVM_VERSION')) { return false; + } } return true; diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/CaseInsensitiveDictionary.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/CaseInsensitiveDictionary.php similarity index 84% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/CaseInsensitiveDictionary.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/CaseInsensitiveDictionary.php index f6e1496..2c97893 100644 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/CaseInsensitiveDictionary.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/CaseInsensitiveDictionary.php @@ -20,6 +20,17 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato */ protected $data = array(); + /** + * Creates a case insensitive dictionary. + * + * @param array $data Dictionary/map to convert to case-insensitive + */ + public function __construct(array $data = array()) { + foreach ($data as $key => $value) { + $this->offsetSet($key, $value); + } + } + /** * Check if the given item exists * @@ -39,8 +50,9 @@ public function offsetExists($key) { */ public function offsetGet($key) { $key = strtolower($key); - if (!isset($this->data[$key])) + if (!isset($this->data[$key])) { return null; + } return $this->data[$key]; } diff --git a/razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/FilteredIterator.php b/razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/FilteredIterator.php similarity index 89% rename from razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/FilteredIterator.php rename to razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/FilteredIterator.php index 41e2a3d..76a29e7 100644 --- a/razorpay-php/libs/Requests-1.6.1/library/Requests/Utility/FilteredIterator.php +++ b/razorpay-php/libs/Requests-1.7.0/library/Requests/Utility/FilteredIterator.php @@ -13,6 +13,13 @@ * @subpackage Utilities */ class Requests_Utility_FilteredIterator extends ArrayIterator { + /** + * Callback to run as a filter + * + * @var callable + */ + protected $callback; + /** * Create a new iterator * diff --git a/razorpay-php/libs/Requests-1.6.1/package.xml.tpl b/razorpay-php/libs/Requests-1.7.0/package.xml.tpl old mode 100755 new mode 100644 similarity index 100% rename from razorpay-php/libs/Requests-1.6.1/package.xml.tpl rename to razorpay-php/libs/Requests-1.7.0/package.xml.tpl diff --git a/razorpay-php/src/Addon.php b/razorpay-php/src/Addon.php new file mode 100644 index 0000000..d587ec3 --- /dev/null +++ b/razorpay-php/src/Addon.php @@ -0,0 +1,21 @@ +getEntityUrl(); + + return $this->request('DELETE', $entityUrl . $this->id); + } +} diff --git a/razorpay-php/src/Api.php b/razorpay-php/src/Api.php index 6db95b0..ba13d43 100644 --- a/razorpay-php/src/Api.php +++ b/razorpay-php/src/Api.php @@ -16,7 +16,7 @@ class Api */ public static $appsDetails = array(); - const VERSION = '2.0.0'; + const VERSION = '2.5.0'; /** * @param string $key @@ -30,7 +30,6 @@ public function __construct($key, $secret) /* * Set Headers - * */ public function setHeader($header, $value) { diff --git a/razorpay-php/src/Customer.php b/razorpay-php/src/Customer.php index 55232de..45cd6d4 100644 --- a/razorpay-php/src/Customer.php +++ b/razorpay-php/src/Customer.php @@ -12,6 +12,11 @@ public function fetch($id) return parent::fetch($id); } + public function all($options = array()) + { + return parent::all($options); + } + public function create($attributes = array()) { return parent::create($attributes); diff --git a/razorpay-php/src/Entity.php b/razorpay-php/src/Entity.php index 6172dad..bb26439 100644 --- a/razorpay-php/src/Entity.php +++ b/razorpay-php/src/Entity.php @@ -19,21 +19,28 @@ protected function fetch($id) { $entityUrl = $this->getEntityUrl(); - if ($id === null) - { - $path = explode('\\', get_class($this)); - $class = strtolower(array_pop($path)); + $this->validateIdPresence($id); - $message = 'The ' . $class . ' id provided is null'; + $relativeUrl = $entityUrl . $id; - $code = Errors\ErrorCode::BAD_REQUEST_ERROR; + return $this->request('GET', $relativeUrl); + } - throw new Errors\BadRequestError($message, $code, 500); + protected function validateIdPresence($id) + { + if ($id !== null) + { + return; } - $relativeUrl = $entityUrl . $id; + $path = explode('\\', get_class($this)); + $class = strtolower(array_pop($path)); - return $this->request('GET', $relativeUrl); + $message = 'The ' . $class . ' id provided is null'; + + $code = Errors\ErrorCode::BAD_REQUEST_ERROR; + + throw new Errors\BadRequestError($message, $code, 500); } protected function all($options = array()) @@ -48,10 +55,30 @@ protected function getEntityUrl() $fullClassName = get_class($this); $pos = strrpos($fullClassName, '\\'); $className = substr($fullClassName, $pos + 1); - $className = lcfirst($className); + $className = $this->snakeCase($className); return $className.'s/'; } + protected function snakeCase($input) + { + $delimiter = '_'; + $output = preg_replace('/\s+/u', '', ucwords($input)); + $output = preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $output); + $output = strtolower($output); + return $output; + } + + /** + * Makes a HTTP request using Request class and assuming the API returns + * formatted entity or collection result, wraps the returned JSON as entity + * and returns. + * + * @param string $method + * @param string $relativeUrl + * @param array $data + * + * @return Entity + */ protected function request($method, $relativeUrl, $data = null) { $request = new Request(); @@ -71,6 +98,14 @@ protected function request($method, $relativeUrl, $data = null) } } + /** + * Given the JSON response of an API call, wraps it to corresponding entity + * class or a collection and returns the same. + * + * @param array $data + * + * @return Entity + */ protected static function buildEntity($data) { $entities = static::getDefinedEntitiesArray(); @@ -105,7 +140,8 @@ protected static function getDefinedEntitiesArray() 'refund', 'order', 'customer', - 'token'); + 'token', + 'settlement'); } protected static function getEntityClass($name) @@ -189,4 +225,4 @@ protected function convertToArray($attributes) return $array; } -} \ No newline at end of file +} diff --git a/razorpay-php/src/Invoice.php b/razorpay-php/src/Invoice.php index f7f699c..23551c8 100644 --- a/razorpay-php/src/Invoice.php +++ b/razorpay-php/src/Invoice.php @@ -2,23 +2,114 @@ namespace Razorpay\Api; +use Requests; + +/** + * Invoice entity gets used for both Payment Links and Invoices system. + * Few of the methods are only meaningful for Invoices system and calling those + * for against/for a Payment Link would throw Bad request error. + */ class Invoice extends Entity { /** - * @param $id Invoice id + * Creates invoice of any type(invoice|link|ecod). + * + * @param array $attributes + * + * @return Invoice */ - public function fetch($id) + public function create($attributes = array()) { - return parent::fetch($id); + return parent::create($attributes); } - public function create($attributes = array()) + /** + * Fetches invoice entity with given id + * + * @param string $id + * + * @return Invoice + */ + public function fetch($id) { - return parent::create($attributes); + return parent::fetch($id); } + /** + * Fetches multiple invoices with given query options + * + * @param array $options + * + * @return Collection + */ public function all($options = array()) { return parent::all($options); } + + /** + * Cancels issued invoice + * + * @return Invoice + */ + public function cancel() + { + $url = $this->getEntityUrl() . $this->id . '/cancel'; + + return $this->request(Requests::POST, $url); + } + + /** + * Send/re-send notification for invoice by given medium + * + * @param $medium - sms|email + * + * @return array + */ + public function notifyBy($medium) + { + $url = $this->getEntityUrl() . $this->id . '/notify_by/' . $medium; + $r = new Request(); + + return $r->request(Requests::POST, $url); + } + + /** + * Patches given invoice with new attributes + * + * @param array $attributes + * + * @return Invoice + */ + public function edit($attributes = array()) + { + $url = $this->getEntityUrl() . $this->id; + + return $this->request(Requests::PATCH, $url, $attributes); + } + + /** + * Issues drafted invoice + * + * @return Invoice + */ + public function issue() + { + $url = $this->getEntityUrl() . $this->id . '/issue'; + + return $this->request(Requests::POST, $url); + } + + /** + * Deletes drafted invoice + * + * @return Invoice + */ + public function delete() + { + $url = $this->getEntityUrl() . $this->id; + $r = new Request(); + + return $r->request(Requests::DELETE, $url); + } } diff --git a/razorpay-php/src/Payment.php b/razorpay-php/src/Payment.php index 067fbed..0d8a44d 100644 --- a/razorpay-php/src/Payment.php +++ b/razorpay-php/src/Payment.php @@ -2,6 +2,8 @@ namespace Razorpay\Api; +use Requests; + class Payment extends Entity { /** @@ -17,6 +19,20 @@ public function all($options = array()) return parent::all($options); } + /** + * Patches given payment with new attributes + * + * @param array $attributes + * + * @return Payment + */ + public function edit($attributes = array()) + { + $url = $this->getEntityUrl() . $this->id; + + return $this->request(Requests::PATCH, $url, $attributes); + } + /** * @param $id Payment id */ @@ -39,6 +55,13 @@ public function capture($attributes = array()) return $this->request('POST', $relativeUrl, $attributes); } + public function transfer($attributes = array()) + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/transfers'; + + return $this->request('POST', $relativeUrl, $attributes); + } + public function refunds() { $refund = new Refund; @@ -47,4 +70,20 @@ public function refunds() return $refund->all($options); } + + public function transfers() + { + $transfer = new Transfer(); + + $transfer->payment_id = $this->id; + + return $transfer->all(); + } + + public function bankTransfer() + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/bank_transfer'; + + return $this->request('GET', $relativeUrl); + } } diff --git a/razorpay-php/src/Plan.php b/razorpay-php/src/Plan.php new file mode 100644 index 0000000..69cb2e1 --- /dev/null +++ b/razorpay-php/src/Plan.php @@ -0,0 +1,21 @@ +register('curl.before_send', array($this, 'setCurlSslOpts')); + $options = array( 'auth' => array(Api::getKey(), Api::getSecret()), - 'timeout' => 60 + 'hook' => $hooks, + 'timeout' => 60, ); $headers = $this->getRequestHeaders(); @@ -46,6 +60,11 @@ public function request($method, $url, $data = array()) return json_decode($response->body, true); } + public function setCurlSslOpts($curl) + { + curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1); + } + /** * Adds an additional header to all API requests * @param string $key Header key diff --git a/razorpay-php/src/Settlement.php b/razorpay-php/src/Settlement.php new file mode 100644 index 0000000..fa76738 --- /dev/null +++ b/razorpay-php/src/Settlement.php @@ -0,0 +1,42 @@ +getEntityUrl() . 'report/combined'; + + return $this->request('GET', $relativeUrl, $options); + } +} + diff --git a/razorpay-php/src/Subscription.php b/razorpay-php/src/Subscription.php new file mode 100644 index 0000000..fb6f426 --- /dev/null +++ b/razorpay-php/src/Subscription.php @@ -0,0 +1,35 @@ +getEntityUrl() . $this->id . '/cancel'; + + return $this->request('POST', $relativeUrl, $attributes); + } + + public function createAddon($attributes = array()) + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/addons'; + + return $this->request('POST', $relativeUrl, $attributes); + } +} diff --git a/razorpay-php/src/Transfer.php b/razorpay-php/src/Transfer.php new file mode 100644 index 0000000..150a1b2 --- /dev/null +++ b/razorpay-php/src/Transfer.php @@ -0,0 +1,62 @@ +payment_id) === true) + { + $relativeUrl = 'payments/' . $this->payment_id. '/transfers'; + + return $this->request('GET', $relativeUrl, $options); + } + + return parent::all($options); + } + + /** + * Create a direct transfer from merchant's account to + * any of the linked accounts, without linking it to a + * payment + */ + public function create($attributes = array()) + { + return parent::create($attributes); + } + + public function edit($attributes = null) + { + $entityUrl = $this->getEntityUrl() . $this->id; + + return $this->request('PATCH', $entityUrl, $attributes); + } + + /** + * Create a reversal for a transfer + */ + public function reverse($attributes = array()) + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/reversals'; + + return $this->request('POST', $relativeUrl, $attributes); + } + + /** + * Fetches all reversals + */ + public function reversals($attributes = array()) + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/reversals'; + + return $this->request('GET', $relativeUrl, $attributes); + } +} diff --git a/razorpay-php/src/Utility.php b/razorpay-php/src/Utility.php index 93afb18..22e588f 100644 --- a/razorpay-php/src/Utility.php +++ b/razorpay-php/src/Utility.php @@ -8,32 +8,50 @@ class Utility public function verifyPaymentSignature($attributes) { - $expectedSignature = $attributes['razorpay_signature']; - $orderId = $attributes['razorpay_order_id']; + $actualSignature = $attributes['razorpay_signature']; + $paymentId = $attributes['razorpay_payment_id']; - $payload = $orderId . '|' . $paymentId; + if (isset($attributes['razorpay_order_id']) === true) + { + $orderId = $attributes['razorpay_order_id']; + + $payload = $orderId . '|' . $paymentId; + } + else if (isset($attributes['razorpay_subscription_id']) === true) + { + $subscriptionId = $attributes['razorpay_subscription_id']; + + $payload = $paymentId . '|' . $subscriptionId; + } + else + { + throw new Errors\SignatureVerificationError( + 'Either razorpay_order_id or razorpay_subscription_id must be present.'); + } + + $secret = Api::getSecret(); - return self::verifySignature($payload, $expectedSignature); + self::verifySignature($payload, $actualSignature, $secret); } - public function verifyWebhookSignature($payload, $expectedSignature) + public function verifyWebhookSignature($payload, $actualSignature, $secret) { - return self::verifySignature($payload, $expectedSignature); + self::verifySignature($payload, $actualSignature, $secret); } - public function verifySignature($payload, $expectedSignature) + public function verifySignature($payload, $actualSignature, $secret) { - $actualSignature = hash_hmac(self::SHA256, $payload, Api::getSecret()); + $expectedSignature = hash_hmac(self::SHA256, $payload, $secret); // Use lang's built-in hash_equals if exists to mitigate timing attacks if (function_exists('hash_equals')) { - $verified = hash_equals($actualSignature, $expectedSignature); + $verified = hash_equals($expectedSignature, $actualSignature); } else { - $verified = $this->hashEquals($actualSignature, $expectedSignature); + $verified = $this->hashEquals($expectedSignature, $actualSignature); } if ($verified === false) @@ -43,7 +61,7 @@ public function verifySignature($payload, $expectedSignature) } } - private function hashEquals($actualSignature, $expectedSignature) + private function hashEquals($expectedSignature, $actualSignature) { if (strlen($expectedSignature) === strlen($actualSignature)) { diff --git a/razorpay-php/src/VirtualAccount.php b/razorpay-php/src/VirtualAccount.php new file mode 100644 index 0000000..cd46d00 --- /dev/null +++ b/razorpay-php/src/VirtualAccount.php @@ -0,0 +1,39 @@ +getEntityUrl() . $this->id; + + $data = array( + 'status' => 'closed' + ); + + return $this->request('PATCH', $relativeUrl, $data); + } + + public function payments() + { + $relativeUrl = $this->getEntityUrl() . $this->id . '/payments'; + + return $this->request('GET', $relativeUrl); + } +} \ No newline at end of file diff --git a/razorpay-php/version.txt b/razorpay-php/version.txt index db6fb4a..437459c 100644 --- a/razorpay-php/version.txt +++ b/razorpay-php/version.txt @@ -1 +1 @@ -1.2.8 +2.5.0 diff --git a/razorpay-quick-payments.php b/razorpay-quick-payments.php index fe7e214..18f8f3a 100644 --- a/razorpay-quick-payments.php +++ b/razorpay-quick-payments.php @@ -4,7 +4,7 @@ * Plugin Name: Razorpay Quick Payments * Plugin URI: https://github.com/razorpay/razorpay-quick-payments * Description: Quick Payments for Wordpress, by Razorpay. - * Version: 1.0.1 + * Version: 1.1.0 * Author: Team Razorpay * Author URI: https://razorpay.com/about/ * License: GPL2 @@ -166,13 +166,25 @@ function razorpayOrderCreationResponse() // Stores the data as a cached variable temporarily $_SESSION['rzp_QP_order_id'] = $razorpayOrder['id']; + $mod_version = get_plugin_data(plugin_dir_path(__FILE__) . 'razorpay-quick-payments.php')['Version']; + + $wp_version = get_bloginfo( 'version' ); + $razorpayArgs = array( 'key' => $this->keyID, 'name' => $name, 'amount' => $amount, 'currency' => 'INR', 'description' => $productInfo, - 'order_id' => $razorpayOrder['id'] + 'order_id' => $razorpayOrder['id'], + 'notes' => [ + 'quick_payment_order_id' => $orderID + ], + '_' => [ + 'integration' => 'Quick Payment', + 'integration_version' => $mod_version, + 'integration_parent_version' => $wp_version, + ], ); } } diff --git a/templates/razorpay-settings-templates.php b/templates/razorpay-settings-templates.php index 73a38d9..1a37678 100644 --- a/templates/razorpay-settings-templates.php +++ b/templates/razorpay-settings-templates.php @@ -141,10 +141,13 @@ function displayPaymentAction() { $default = get_option('payment_action_field'); + $selected_capture = ($default == 'capture') ? 'selected' : '' ; + $selected_authorize = ($default == 'authorize') ? 'selected' : '' ; + $paymentAction = << - - + +