diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..c10ae70
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,10 @@
+version: 2
+jobs:
+ build:
+ working_directory : ~/tmp
+ docker:
+ - image : circleci/php:7.3.8
+ steps:
+ - checkout
+ - run: composer install
+ - run: vendor/bin/phpunit --testdox
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d08ff8b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.idea
+
+/vendor/
diff --git a/Instamojo.php b/Instamojo.php
deleted file mode 100644
index 2393a9b..0000000
--- a/Instamojo.php
+++ /dev/null
@@ -1,468 +0,0 @@
-setUsername($username);
- $this->setPassword($password);
- $this->setID($id);
- }
-
- /**
- * Default destructor.
- */
- public function __destruct(){
- if($this->curl != null) curl_close($this->curl);
- }
-
- /**
- * Get the version of the API wrapper.
- * @return string Version of the API wrapper.
- */
- public function getVersion(){
- return self::version;
- }
-
- private function allowed_currency($currency){
- if(in_array($currency, $this->currencies)) return true;
- return false;
- }
-
- /**
- * Set teh Username.
- * @param string $username Instamojo username of the user.
- */
- private function setUsername($username){
- $this->username = (string) $username;
- }
-
- /**
- * Set the password.
- * @param string $password Instamojo username of the password.
- */
- private function setPassword($password){
- $this->password = (string) $password;
- }
-
- /**
- * Set the ID.
- * @param string $id Instamojo APP_ID provided by Instamojo.
- */
-
- private function setID($id){
- $this->APP_ID = (string) $id;
- }
-
- /**
- * Create the absolute path for the request.
- * @param string $url The base URL (Here it is used by API_URL)
- * @param string $path The relative path.
- */
- private function buildPath($url, $path){
- return $url . $path;
- }
-
- /**
- * Request the instamojo API.
- * @param string $path The relative path.
- * @param string $method POST/GET/POST/DELETE
- * @param array $data Data to be passed.
- */
- private function apiRequest($path, $method, array $data = null){
- $path = (string) $path;
- $method = (string) $method;
- $data = (array) $data;
-
- $headers = array("X-App-Id: $this->APP_ID");
-
- if($this->APP_TOKEN){
- $headers[] = "X-Auth-Token: $this->APP_TOKEN";
- }
-
- $request_path = $this->buildPath(self::API_URL, $path);
-
- $options = array();
- $options[CURLOPT_HTTPHEADER] = $headers;
- $options[CURLOPT_RETURNTRANSFER] = true;
- $options[CURLOPT_URL] = $request_path;
-
- if($method == 'POST'){
- $data_string = "";
-
- foreach ($data as $key => $value) {
- $data_string .= $key.'='.$value.'&';
- }
-
- $data_string = rtrim($data_string, '&');
-
- $options[CURLOPT_POST] = count($data);
- $options[CURLOPT_POSTFIELDS] = $data_string;
- }
-
- else if($method == 'GET'){
- // Nothing to be done here.
- }
-
- else if($method == 'PUT'){
-
- }
-
- else if($method == 'DELETE'){
- $options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
- }
-
- else if($method == 'PATCH'){
- $data_string = "";
-
- foreach ($data as $key => $value) {
- $data_string .= $key.'='.$value.'&';
- }
-
- $data_string = rtrim($data_string, '&');
-
- $options[CURLOPT_POST] = count($data);
- $options[CURLOPT_POSTFIELDS] = $data_string;
- $options[CURLOPT_CUSTOMREQUEST] = 'PATCH';
- }
-
- $this->curl = curl_init();
- curl_setopt_array($this->curl, $options);
- $response = curl_exec($this->curl);
- $headers = curl_getinfo($this->curl);
-
- $errorNumber = curl_errno($this->curl);
- $errorMessage = curl_error($this->curl);
-
- return array('response' => $response, 'headers' => $headers, 'error' => $errorMessage, 'errno' => $errorNumber);
- }
-
-
- /**
- * Authenticate the application.
- * @return array PHP array of the JSON response.
- */
- public function apiAuth(){
- $response = $this->apiRequest('auth/', 'POST', $data = array('username' => $this->username, 'password' => $this->password));
- $json = @json_decode($response['response'], true);
-
- if($response['errno']) throw new Exception("Exception: " . $response['error']);
- if(!$json["success"]) throw new Exception("Application authentication failed. Check credentials");
-
- $this->APP_TOKEN = $json["token"];
- return $json;
- }
-
- /**
- * List all the offers of the user.
- * @return array PHP array of the JSON response.
- */
- public function listAllOffers(){
- if(!$this->APP_TOKEN) throw new Exception("Please authenticate your application.");
- $response = $this->apiRequest('offer/', 'GET');
- $json = @json_decode($response['response'], true);
- if(!$json['success']) throw new Exception("Error in listing all offers.");
- return $json;
- }
-
- /**
- * List the complete offer details of the offer id mentioned in $slug.
- * @param array $slug The offer id.
- * @return array PHP array of the JSON response.
- */
- public function listOneOfferDetail($slug){
- if(!$this->APP_TOKEN) throw new Exception("Please authenticate your application.");
- $response = $this->apiRequest("offer/$slug/", 'GET');
- $json = @json_decode($response['response'], true);
- if(!$json['success']) throw new Exception("Error in listing offer of $slug.");
- return $json;
- }
-
- /**
- * Used to get an upload URL for the files to be uploaded, i.e. The cover image and the File.
- * @return array PHP array of the JSON response.
- */
- public function getUploadUrl(){
- if(!$this->APP_TOKEN) throw new Exception("Please authenticate your application.");
- $response = $this->apiRequest('offer/get_file_upload_url/', 'GET');
- $json = @json_decode($response['response'], true);
- if(!$json['success']) throw new Exception("Cannot get an URL.");
- return $json["upload_url"];
- }
-
- /**
- * Deletes the authentication toekn recieved from Instamojo.
- */
- public function deleteAuthToken(){
- if(!$this->APP_TOKEN) throw new Exception("No token loaded, unable to delete.");
- $response = $this->apiRequest("auth/$this->APP_TOKEN/", 'DELETE');
- $json = @json_decode($response['response'], true);
- if(!$json['success']) throw new Exception("Could not delete auth token.");
- $this->APP_TOKEN = null;
- }
-
- /**
- * Archives(Deletes) the offer whos id is supplied.
- * @param string $slug Id of the offer.
- */
- public function archiveOffer($slug){
- if(!$this->APP_TOKEN) throw new Exception("No token loaded, unable to archive.");
- $response = $this->apiRequest("offer/$slug/", 'DELETE');
- $json = @json_decode($response['response'], true);
- if(!$json['success']) throw new Exception("Could not archive offer.");
- }
-
- /**
- * Title, keep concise since slug is auto-generated
- * from the title [max: 200 char, required]
- * @param string $title Title of the offer.
- */
- public function setTitle($title){
- if(strlen($title) > 200) throw new Exception("Title size not more than 200 allowed.");
- $this->title = (string) $title;
- }
-
- /**
- * Detailed description of the offer, can contain markdown.
- * @param string $description Description of the offer.
- */
- public function setDescription($description){
- $this->description = (string) $description;
- }
-
- /**
- * Currency of the offer. Can be INR or USD.
- * @param string $currency Currency of the offer.
- */
- public function setCurrency($currency){
- if(!$this->allowed_currency($currency)) throw new Exception("Invalid currency.");
- $this->currency = (string) $currency;
- }
-
- /**
- * Price of the offer as a decimal (up to 2 decimal places)
- * @param string $base_price Base price of the offer.
- */
- public function setBasePrice($base_price){
- if(!(is_numeric($base_price) && (int)$base_price >= 0)) throw new Exception("The base_price should be a positive number or zero.");
- $this->base_price = (string) $base_price;
- }
-
- /**
- * Keep zero for unlimited quantity,
- * any other positive number will limit sales/claims of the offer
- * and make it unavailable afterwards.
- * @param string $quantity of the offer. 0 for unlimited.
- */
- public function setQuantity($quantity){
- if(!(is_numeric($quantity) && (int)$quantity == $quantity && (int)$quantity >= 0))
- throw new Exception("The quantity should be a positive number or zero.");
- $this->quantity = (string) $quantity;
- }
-
- /**
- * Required for events, date-time when the event begins.
- * Format: YYYY-MM-DD HH:mm
- * @param string $start_date Start date of the offer.
- */
- public function setStartDate($start_date){
- $this->start_date = $start_date;
- }
-
- /**
- * Required for events, date-time when the event begins.
- * Format: YYYY-MM-DD HH:mm
- * @param string $end_date End date of the offer.
- */
- public function setEndDate($end_date){
- $this->end_date = $end_date;
- }
-
- /**
- * Timezone of the event. Example: Asia/Kolkata
- * @param string $timezone Timezone of the offer.
- */
- public function setTimeZone($timezone){
- $this->timezone = $timezone;
- }
-
- /**
- * Required for events, location where the event will be held.
- * @param string $venue Venue of the offer.
- */
- public function setVenue($venue){
- $this->venue = $venue;
- }
-
- /**
- * You can set this to a thank-you page on your site.
- * Buyers will be redirected here after successful payment.
- * @param string $redirect_url The URL to be redirected to after a buyer downloads the digital file.
- */
- public function setRedirectURL($redirect_url){
- $this->redirect_url = $redirect_url;
- }
-
- /**
- * A note to be displayed to buyer after successful
- * payment. This will also be sent via email and
- * in the receipt/ticket that is sent as attachment
- * to the email.
- */
- public function setNote($note){
- $this->note = $note;
- }
-
- /**
- * Path to the file you want to sell.
- * @param string $file_path Path to the file.
- */
- public function setFilePath($file_path){
- $this->file_path = $file_path;
- }
-
- /**
- * Path to the cover image.
- * @param string $cover_path Path to the cover image.
- */
- public function setCoverPath($cover_path){
- $this->cover_path = $cover_path;
- }
-
- /**
- * A utility function to send POST request to the URL recieved from
- * getUploadUrl() and upload a file.
- * @param string $file_upload_url The URL recieved from getUploadUrl().
- * @param string $file_path The path to the file in your computer.
- * @return JSON The JSON recieved from the request.
- */
- private function getFileUploadJson($file_upload_url, $file_path){
- $file_path = realpath($file_path);
- $file_name = basename($file_path);
- $ch = curl_init();
- $data = array('fileUpload' => '@'.$file_path);
- curl_setopt($ch, CURLOPT_URL, $file_upload_url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $uploadJson = curl_exec($ch);
- return $uploadJson;
- }
-
- /**
- * Utility function to build the data array which will be used
- * to send data for creating offer through apiRequest().
- * @return array The array to be used later to send data about the offer to Instamojo API.
- */
- private function buildDataArray(){
- $data = array();
- if(!$this->title) throw new Exception("title is a must for creating an offer.");
- $data['title'] = $this->title;
- if(!$this->description) throw new Exception("description is a must for creating an offer.");
- $data['description'] = $this->description;
- if(!$this->currency) throw new Exception("currency is a must for creating an offer.");
- $data['currency'] = $this->currency;
- if(!$this->base_price && $this->base_price != '0') throw new Exception("base_price is a must for creating an offer.");
- $data['base_price'] = $this->base_price;
- if($this->quantity)
- $data['quantity'] = $this->quantity;
- if($this->start_date)
- $data['start_date'] = $this->start_date;
- if($this->end_date)
- $data['end_date'] = $this->end_date;
- if($this->timezone)
- $data['timezone'] = $this->timezone;
- if($this->venue)
- $data['venue'] = $this->venue;
- if($this->redirect_url)
- $data['redirect_url'] = $this->redirect_url;
- if($this->note)
- $data['note'] = $this->note;
- if(!$this->file_path) throw new Exception("file is a must for creating an offer.");
-
- $upload_url = $this->getUploadUrl();
- $file_upload_json = $this->getFileUploadJson($upload_url, $this->file_path);
- $data['file_upload_json'] = $file_upload_json;
-
- if($this->cover_path){
- $upload_url = $this->getUploadUrl();
- $cover_upload_json = $this->getFileUploadJson($upload_url, $this->cover_path);
- $data['cover_image_json'] = $cover_upload_json;
- }
- return $data;
- }
-
- /**
- * Function to create an instamojo offer.
- * @return JSON The response resieved from Instamojo API.
- */
- public function createOffer(){
- $offer_array = $this->buildDataArray();
- $request = $this->apiRequest('offer/', 'POST', $data = $offer_array);
- $json = @json_decode($request['response'], true);
- if(!$json['success']) throw new Exception("Connot create offer.");
- return $request;
- }
-
- /**
- * Function to to edit an offer.
- * @param string $slug The offer ID.
- * @return JSON The response recieved from Instamojo API.
- */
- public function editOffer($slug){
- $offer_array = $this->buildDataArray();
- $request = $this->apiRequest("offer/$slug/", 'PATCH', $data = $offer_array);
- $json = @json_decode($request['response'], true);
- if(!$json['success']) throw new Exception("Connot edit offer.");
- return $request;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..202dd1c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Instamojo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/OLD_API.md b/OLD_API.md
new file mode 100644
index 0000000..324ff9e
--- /dev/null
+++ b/OLD_API.md
@@ -0,0 +1,148 @@
+# Instamojo Old PHP API
+
+**Note**: If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `'https://test.instamojo.com/api/1.1/'` as third argument to the `Instamojo` class while initializing it. API key and Auth token for the same can be obtained from https://test.instamojo.com/developers/ (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)).
+
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN, 'https://test.instamojo.com/api/1.1/');
+```
+
+
+## Installing via [Composer](https://getcomposer.org/)
+```bash
+$ php composer.phar require instamojo/instamojo-php
+```
+
+**Note**: If you're not using Composer then directly include the contents of `src` directory in your project.
+
+
+## Usage
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN);
+```
+
+### Create a product
+
+```php
+try {
+ $response = $api->linkCreate(array(
+ 'title'=>'Hello API',
+ 'description'=>'Create a new product easily',
+ 'base_price'=>100,
+ 'cover_image'=>'/path/to/photo.jpg'
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the product that was just created.
+
+### Edit a product
+
+```php
+try {
+ $response = $api->linkEdit(
+ 'hello-api', // You must specify the slug of the product
+ array(
+ 'title'=>'A New Title',
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+### List all products
+
+```php
+try {
+ $response = $api->linksList();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+### List all Payments
+
+```php
+try {
+ $response = $api->paymentsList();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+### Get Details of a Payment using Payment ID
+
+```php
+try {
+ $response = $api->paymentDetail('[PAYMENT ID]');
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+## Available Functions
+
+You have these functions to interact with the API:
+
+ * `linksList()` List all products created by authenticated User.
+ * `linkDetail($slug)` Get details of product specified by its unique slug.
+ * `linkCreate(array $link)` Create a new product.
+ * `linkEdit($slug, array $link)` Edit an existing product.
+ * `linkDelete($slug)` Archive a product - Archived producrs cannot be generally accessed by the API. User can still view them on the Dashboard at instamojo.com.
+ * `paymentsList()` List all Payments linked to User's account.
+ * `paymentDetail($payment_id)` Get details of a Payment specified by its unique Payment ID. You may receive the Payment ID via `paymentsList()` or via URL Redirect function or as a part of Webhook data.
+
+## Product Creation Parameters
+
+### Required
+
+ * `title` - Title of the product, be concise.
+ * `description` - Describe what your customers will get, you can add terms and conditions and any other relevant information here. Markdown is supported, popular media URLs like Youtube, Flickr are auto-embedded.
+ * `base_price` - Price of the product. This may be 0, if you want to offer it for free.
+
+### File and Cover Image
+ * `file_upload` - Full path to the file you want to sell. This file will be available only after successful payment.
+ * `cover_image` - Full path to the IMAGE you want to upload as a cover image.
+
+### Quantity
+ * `quantity` - Set to 0 for unlimited sales. If you set it to say 10, a total of 10 sales will be allowed after which the product will be made unavailable.
+
+### Post Purchase Note
+ * `note` - A post-purchase note, will only displayed after successful payment. Will also be included in the ticket/ receipt that is sent as attachment to the email sent to buyer. This will not be shown if the payment fails.
+
+### Event
+ * `start_date` - Date-time when the event is beginning. Format: `YYYY-MM-DD HH:mm`
+ * `end_date` - Date-time when the event is ending. Format: `YYYY-MM-DD HH:mm`
+ * `venue` - Address of the place where the event will be held.
+ * `timezone` - Timezone of the venue. Example: Asia/Kolkata
+
+### Redirects and Webhooks
+ * `redirect_url` - This can be a Thank-You page on your website. Buyers will be redirected to this page after successful payment.
+ * `webhook_url` - Set this to a URL that can accept POST requests made by Instamojo server after successful payment.
+ * `enable_pwyw` - set this to True, if you want to enable Pay What You Want. Default is False.
+ * `enable_sign` - set this to True, if you want to enable Link Signing. Default is False. For more information regarding this, and to avail this feature write to support at instamojo.com.
+
+---
+
+## [Request a Payment](RAP.md)
+
+---
+
+## [Refunds](REFUNDS.md)
+
+---
+
+Further documentation is available at https://www.instamojo.com/developers/
\ No newline at end of file
diff --git a/README.md b/README.md
index 19b1eec..87b4c5d 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,364 @@
-This is a PHP wrapper for the instamojo API.
\ No newline at end of file
+# Instamojo PHP API [](https://packagist.org/packages/instamojo/instamojo-php) [](https://opensource.org/licenses/MIT)
+
+Assists you to programmatically create, edit and delete Links on Instamojo in PHP.
+
+**Note**: If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `true` as third argument to the `Instamojo` class while initializing it. `client_id` and `client_secret` token for the same can be obtained from (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)).
+
+```php
+$authType = "app/user" /**Depend on app or user based authentication**/
+
+$api = Instamojo\Instamojo::init($authType,[
+ "client_id" => 'XXXXXQAZ',
+ "client_secret" => 'XXXXQWE',
+ "username" => 'FOO', /** In case of user based authentication**/
+ "password" => 'XXXXXXXX' /** In case of user based authentication**/
+
+ ],true); /** true for sandbox enviorment**/
+
+```
+
+## Installing via [Composer](https://getcomposer.org/)
+
+```bash
+php composer.phar require instamojo/instamojo-php
+```
+
+**Note**: If you're not using Composer then directly include the contents of `src` directory in your project.
+
+## Usage
+
+```php
+$api = Instamojo\Instamojo::init($authType,[
+ "client_id" => 'XXXXXQAZ',
+ "client_secret" => 'XXXXQWE',
+ "username" => 'FOO', /** In case of user based authentication**/
+ "password" => 'XXXXXXXX' /** In case of user based authentication**/
+
+ ]);
+```
+
+## Documentation
+
+See the Documentation for datailed instructions
+
+ * v1.1 Documentation
+ * v2 Documentation
+
+## Table of Content
+* [Create a payment request](#create_payment)
+* [Get status of Payment request](#get_status_of_payment_request)
+* [Get list of all Payment requests](#get_payment_request_list)
+* [Get list of all Payments](#get_list_of_all_payments)
+* [Get Details of a payment](#get_details_of_a_payment)
+* [Create Gateway order](#create_gateway_order)
+* [Create Gateway order for Payment request](#create_gateway_order_for_payment_request)
+* [Get Gateway order details](#get_gateway_order_details)
+* [Get list of Gateway orders](#get_list_of_gateway_orders)
+* [Create refund for payments](#create_refund_for_payment)
+* [Get details of a refund](#get_refund_details)
+* [Get list of refunds](#get_list_of_refunds)
+* [Common FAQ's](#faqs)
+
+
+### Create a new Payment Request
+
+```php
+try {
+ $response = $api->createPaymentRequest(array(
+ "purpose" => "FIFA 16",
+ "amount" => "3499",
+ "send_email" => true,
+ "email" => "foo@example.com",
+ "redirect_url" => "http://www.example.com/handle_redirect.php"
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment Request that was just created with `longurl` key provide you instamojo-payment-url.
+
+### Recommended seamless checkout Option
+
+ You can render your Instamojo checkout form and collect payments on your webpage with just the instamojo-payment-url obtained in `createPaymentRequest()` using JS based seamless checkout library. To know more how its work Click here.
+
+### Payment Request Creation Parameters
+
+ ### Required
+
+ * `purpose`: Purpose of the payment request.
+ * `amount`: The amount for the request. The minimum amount is 9. And the maximum is 200000.
+
+ ### Optional
+
+ * `buyer_name`: Name of the payer.
+ * `email`: Email of the payer.
+ * `phone`: Phone number of the payer.
+ * `send_email`: Set this to `true` if you want to send email to the payer if email is specified. If email is not specified then an error is raised. (default
+ value: `false`)
+ * `send_sms`: Set this to `true` if you want to send SMS to the payer if phone is specified. If phone is not specified then an error is raised. (default value:
+ `false`)
+ * `redirect_url`: set this to a thank-you page on your site. Buyers will be redirected here after successful payment.
+ * `webhook`: set this to a URL that can accept POST requests made by Instamojo server after successful payment.
+ * `allow_repeated_payments`: To disallow multiple successful payments on a Payment Request pass `false` for this field. If this is set to `false` then the link is
+ not accessible publicly after first successful payment, though you can still access it using API(default value: `true`).
+ * `partner_fee_type` : Allows you to receive a cut from from payments you facilitate. For fixed fee set this to `fixed`, or for percentage fee set it to
+ `percent`.
+ * `partner_fee` : This describes the fee that you would collect. It can be either a fixed amount, or a percentage of the original amount, depending on the value
+ of `partner_fee_type`.
+ * `mark_fulfilled` : Flag to determine if you want to put the payment on hold until you explicitly fulfil it. If `mark_fulfilled` is `True` the payment will be
+ paid out to the merchant. If `mark_fulfilled` is `False`, then the payment will be put on hold until you explicitly fulfil the payment. See Fulfil a Payment below
+ on how to fulfil a payment.
+ * `expires_at` : Time after which the payment request will be expired in UTC timestamp. Max value is 600 seconds. Default is Null.
+
+
+## Get the status or details of a Payment Request
+
+```php
+try {
+ $response = $api->getPaymentRequestDetails(['PAYMENT REQUEST ID']);
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment Request and the payments related to it.
+Key for payments is `'payments'`.
+
+Here `['PAYMENT REQUEST ID']` is the value of `'id'` key returned by the `createPaymentRequest()` query.
+
+## Get a list of all Payment Requests
+
+```php
+try {
+ $response = $api->getPaymentRequests();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you an array containing Payment Requests created so far. Note that the payments related to individual Payment Request are not returned with this query.
+
+getPaymentRequests() also accepts optional parameters for pagination.
+
+```php
+getPaymentRequests($limit=null, $page=null)
+```
+
+For example:
+
+```php
+$response = $api->getPaymentRequests(50, 1);
+```
+
+## Get a list of all Payments
+
+```php
+try {
+ $response = $api->getPayments();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you an array containing Payments details so far.
+
+getPayments() also accepts optional parameters for pagination.
+
+```php
+getPayments($limit=null, $page=null)
+```
+
+For example:
+
+```php
+$response = $api->getPayments(50, 1);
+```
+
+## Get the details of a Payment
+
+```php
+try {
+ $response = $api->getPaymentDetails(['PAYMENT ID']);
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment.
+
+Here `['PAYMENT ID']` is the value of `'id'` key returned by the `getPayments()` query.
+
+## Create a Gateway Order
+
+```php
+try {
+ $response = $api->createGatewayOrder(array(
+ "name" => "XYZ",
+ "email" => "abc@foo.com",
+ "phone" => "99XXXXXXXX",
+ "amount" => "200",
+ "transaction_id" => 'TXN_ID', /**transaction_id is unique Id**/
+ "currency" => "INR"
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the order in `order` key and payments options in `payment_options` key.
+
+## Create a Gateway Order For payment request
+
+```php
+try {
+ $response = $api->createGatewayOrderForPaymentRequest($payment_request_id, array(
+ "name" => "XYZ",
+ "email" => "abc@foo.com",
+ "phone" => "99XXXXXXXX",
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+`$payment_request_id` id the `id` key obtained in `createPaymentRequest()` method.
+
+This will give you JSON object containing with created `order_id` key.
+
+## Get the details of a Gateway Order
+
+```php
+try {
+ $response = $api->getGatewayOrder(['ORDER ID']);
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Gateway Order.
+
+Here `['ORDER ID']` is the value of `'id'` key returned by the `createGatewayOrder()` query.
+
+## Get a list of all Gateway Order
+
+```php
+try {
+ $response = $api->getGatewayOrders();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you an array containing Gateway Orders details so far.
+
+getGatewayOrders() also accepts optional parameters for pagination.
+
+```php
+getGatewayOrders($limit=null, $page=null)
+```
+
+For example:
+
+```php
+$response = $api->getGatewayOrders(50, 1);
+```
+
+## Create a Refund for a payment
+
+```php
+try {
+ $response = $api->createRefundForPayment($payment_id, array(
+ "type" => "RFD",
+ "body" => "XYZ reason of refund",
+ "refund_amount" => "10",
+ "transaction_id" => "TNX_XYZ"
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing refund details in `refund` key.
+
+ ### Required Parameters
+
+ * `type`: Three letter short-code identifying the reason for refund, string type.
+ * `body`: Additonal text explaining the refund, string type.
+ * `refund_amount`: This field can be used to specify the refund amount, string type.
+ * `transaction_id`: To Prevent duplicate case creations due to replay of APIs, string type.
+
+Valid values for type parameter:
+
+ * RFD: Duplicate/delayed payment.
+ * TNR: Product/service no longer available.
+ * QFL: Customer not satisfied.
+ * QNR: Product lost/damaged.
+ * EWN: Digital download issue.
+ * TAN: Event was canceled/changed.
+ * PTH: Problem not described above.
+
+## Get the details of a Refund
+
+```php
+try {
+ $response = $api->getRefundDetails(['REFUND ID']);
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Refund.
+
+### Get a list of all Refunds
+
+```php
+try {
+ $response = $api->getRefunds();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you an array containing Refunds details so far.
+
+getRefunds() also accepts optional parameters for pagination.
+
+```php
+getRefunds($limit=null, $page=null)
+```
+
+For example:
+
+```php
+$response = $api->getRefunds(50, 1);
+```
+
+## Common FAQ's
+
+* How to get your client Id and Client secret
+
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..f3fbc39
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,48 @@
+{
+ "name": "instamojo/instamojo-php",
+ "type": "library",
+ "description": "This is composer wrapper for instamojo-php",
+ "license": "MIT",
+ "homepage": "https://github.com/instamojo/instamojo-php/",
+ "keywords": [
+ "instamojo",
+ "php",
+ "api",
+ "wrapper"
+ ],
+ "authors": [
+ {
+ "name": "Instamojo and contributors",
+ "email": "dev@instamojo.com",
+ "homepage": "https://github.com/instamojo/instamojo-php/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Instamojo\\": "src/",
+ "Instamojo\\Exceptions\\": "src/Exceptions"
+ },
+ "files": [
+ "src/Utilities.php"
+ ],
+ "classmap": [
+ "src"
+ ]
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Instamojo\\Tests\\": "tests/"
+ }
+ },
+ "support": {
+ "issues": "https://github.com/instamojo/instamojo-php/issues",
+ "docs": "https://github.com/instamojo/instamojo-php/",
+ "email": "support@instamojo.com"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5"
+ }
+}
\ No newline at end of file
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..a6b2312
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,1492 @@
+{
+ "_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": "8d77d02c094b23bfd19cdb4ad25f0b34",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "doctrine/instantiator",
+ "version": "1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/instantiator.git",
+ "reference": "a2c590166b2133a4633738648b6b064edae0814a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
+ "reference": "a2c590166b2133a4633738648b6b064edae0814a",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "doctrine/coding-standard": "^6.0",
+ "ext-pdo": "*",
+ "ext-phar": "*",
+ "phpbench/phpbench": "^0.13",
+ "phpstan/phpstan-phpunit": "^0.11",
+ "phpstan/phpstan-shim": "^0.11",
+ "phpunit/phpunit": "^7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2.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://www.doctrine-project.org/projects/instantiator.html",
+ "keywords": [
+ "constructor",
+ "instantiate"
+ ],
+ "time": "2019-03-17T17:37:11+00:00"
+ },
+ {
+ "name": "myclabs/deep-copy",
+ "version": "1.9.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/myclabs/DeepCopy.git",
+ "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea",
+ "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "replace": {
+ "myclabs/deep-copy": "self.version"
+ },
+ "require-dev": {
+ "doctrine/collections": "^1.0",
+ "doctrine/common": "^2.6",
+ "phpunit/phpunit": "^7.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": "2019-08-09T12:45:53+00:00"
+ },
+ {
+ "name": "phar-io/manifest",
+ "version": "1.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phar-io/manifest.git",
+ "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
+ "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-phar": "*",
+ "phar-io/version": "^2.0",
+ "php": "^5.6 || ^7.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": "Arne Blankerts",
+ "role": "Developer",
+ "email": "arne@blankerts.de"
+ },
+ {
+ "name": "Sebastian Heuer",
+ "role": "Developer",
+ "email": "sebastian@phpeople.de"
+ },
+ {
+ "name": "Sebastian Bergmann",
+ "role": "Developer",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
+ "time": "2018-07-08T19:23:20+00:00"
+ },
+ {
+ "name": "phar-io/version",
+ "version": "2.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phar-io/version.git",
+ "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6",
+ "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.6 || ^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Arne Blankerts",
+ "role": "Developer",
+ "email": "arne@blankerts.de"
+ },
+ {
+ "name": "Sebastian Heuer",
+ "role": "Developer",
+ "email": "sebastian@phpeople.de"
+ },
+ {
+ "name": "Sebastian Bergmann",
+ "role": "Developer",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Library for handling version information and constraints",
+ "time": "2018-07-08T19:19:57+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": "4.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
+ "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
+ "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0",
+ "phpdocumentor/reflection-common": "^1.0.0",
+ "phpdocumentor/type-resolver": "^0.4.0",
+ "webmozart/assert": "^1.0"
+ },
+ "require-dev": {
+ "doctrine/instantiator": "~1.0.5",
+ "mockery/mockery": "^1.0",
+ "phpunit/phpunit": "^6.4"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.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"
+ }
+ ],
+ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
+ "time": "2019-04-30T17:48:53+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.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpspec/prophecy.git",
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
+ "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-4": {
+ "Prophecy\\": "src/Prophecy"
+ }
+ },
+ "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": "2019-06-13T12:50:23+00:00"
+ },
+ {
+ "name": "phpunit/php-code-coverage",
+ "version": "6.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
+ "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
+ "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-xmlwriter": "*",
+ "php": "^7.1",
+ "phpunit/php-file-iterator": "^2.0",
+ "phpunit/php-text-template": "^1.2.1",
+ "phpunit/php-token-stream": "^3.0",
+ "sebastian/code-unit-reverse-lookup": "^1.0.1",
+ "sebastian/environment": "^3.1 || ^4.0",
+ "sebastian/version": "^2.0.1",
+ "theseer/tokenizer": "^1.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.0"
+ },
+ "suggest": {
+ "ext-xdebug": "^2.6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "6.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "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": "2018-10-31T16:06:48+00:00"
+ },
+ {
+ "name": "phpunit/php-file-iterator",
+ "version": "2.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
+ "reference": "050bedf145a257b1ff02746c31894800e5122946"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946",
+ "reference": "050bedf145a257b1ff02746c31894800e5122946",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.1"
+ },
+ "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",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "FilterIterator implementation that filters files based on a list of suffixes.",
+ "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
+ "keywords": [
+ "filesystem",
+ "iterator"
+ ],
+ "time": "2018-09-13T20:33:42+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",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "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": "2.1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-timer.git",
+ "reference": "1038454804406b0b5f5f520358e78c1c2f71501e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e",
+ "reference": "1038454804406b0b5f5f520358e78c1c2f71501e",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Utility class for timing",
+ "homepage": "https://github.com/sebastianbergmann/php-timer/",
+ "keywords": [
+ "timer"
+ ],
+ "time": "2019-06-07T04:22:29+00:00"
+ },
+ {
+ "name": "phpunit/php-token-stream",
+ "version": "3.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-token-stream.git",
+ "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e899757bb3df5ff6e95089132f32cd59aac2220a",
+ "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1-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": "2019-07-25T05:29:42+00:00"
+ },
+ {
+ "name": "phpunit/phpunit",
+ "version": "7.5.14",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/phpunit.git",
+ "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2834789aeb9ac182ad69bfdf9ae91856a59945ff",
+ "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/instantiator": "^1.1",
+ "ext-dom": "*",
+ "ext-json": "*",
+ "ext-libxml": "*",
+ "ext-mbstring": "*",
+ "ext-xml": "*",
+ "myclabs/deep-copy": "^1.7",
+ "phar-io/manifest": "^1.0.2",
+ "phar-io/version": "^2.0",
+ "php": "^7.1",
+ "phpspec/prophecy": "^1.7",
+ "phpunit/php-code-coverage": "^6.0.7",
+ "phpunit/php-file-iterator": "^2.0.1",
+ "phpunit/php-text-template": "^1.2.1",
+ "phpunit/php-timer": "^2.1",
+ "sebastian/comparator": "^3.0",
+ "sebastian/diff": "^3.0",
+ "sebastian/environment": "^4.0",
+ "sebastian/exporter": "^3.1",
+ "sebastian/global-state": "^2.0",
+ "sebastian/object-enumerator": "^3.0.3",
+ "sebastian/resource-operations": "^2.0",
+ "sebastian/version": "^2.0.1"
+ },
+ "conflict": {
+ "phpunit/phpunit-mock-objects": "*"
+ },
+ "require-dev": {
+ "ext-pdo": "*"
+ },
+ "suggest": {
+ "ext-soap": "*",
+ "ext-xdebug": "*",
+ "phpunit/php-invoker": "^2.0"
+ },
+ "bin": [
+ "phpunit"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "7.5-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "The PHP Unit Testing framework.",
+ "homepage": "https://phpunit.de/",
+ "keywords": [
+ "phpunit",
+ "testing",
+ "xunit"
+ ],
+ "time": "2019-07-15T06:24:08+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": "3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/comparator.git",
+ "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
+ "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1",
+ "sebastian/diff": "^3.0",
+ "sebastian/exporter": "^3.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-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": "https://github.com/sebastianbergmann/comparator",
+ "keywords": [
+ "comparator",
+ "compare",
+ "equality"
+ ],
+ "time": "2018-07-12T15:12:46+00:00"
+ },
+ {
+ "name": "sebastian/diff",
+ "version": "3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/diff.git",
+ "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
+ "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5 || ^8.0",
+ "symfony/process": "^2 || ^3.3 || ^4"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-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",
+ "udiff",
+ "unidiff",
+ "unified diff"
+ ],
+ "time": "2019-02-04T06:01:07+00:00"
+ },
+ {
+ "name": "sebastian/environment",
+ "version": "4.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/environment.git",
+ "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
+ "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5"
+ },
+ "suggest": {
+ "ext-posix": "*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.2-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": "2019-05-05T09:05:15+00:00"
+ },
+ {
+ "name": "sebastian/exporter",
+ "version": "3.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/exporter.git",
+ "reference": "06a9a5947f47b3029d76118eb5c22802e5869687"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/06a9a5947f47b3029d76118eb5c22802e5869687",
+ "reference": "06a9a5947f47b3029d76118eb5c22802e5869687",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0",
+ "sebastian/recursion-context": "^3.0"
+ },
+ "require-dev": {
+ "ext-mbstring": "*",
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ },
+ {
+ "name": "Jeff Welch",
+ "email": "whatthejeff@gmail.com"
+ },
+ {
+ "name": "Volker Dusch",
+ "email": "github@wallbash.com"
+ },
+ {
+ "name": "Adam Harvey",
+ "email": "aharvey@php.net"
+ },
+ {
+ "name": "Bernhard Schussek",
+ "email": "bschussek@gmail.com"
+ }
+ ],
+ "description": "Provides the functionality to export PHP variables for visualization",
+ "homepage": "http://www.github.com/sebastianbergmann/exporter",
+ "keywords": [
+ "export",
+ "exporter"
+ ],
+ "time": "2019-08-11T12:43:14+00:00"
+ },
+ {
+ "name": "sebastian/global-state",
+ "version": "2.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/global-state.git",
+ "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4",
+ "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "suggest": {
+ "ext-uopz": "*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.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": "2017-04-27T15:39:26+00:00"
+ },
+ {
+ "name": "sebastian/object-enumerator",
+ "version": "3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/object-enumerator.git",
+ "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5",
+ "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0",
+ "sebastian/object-reflector": "^1.1.1",
+ "sebastian/recursion-context": "^3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.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-08-03T12:35:26+00:00"
+ },
+ {
+ "name": "sebastian/object-reflector",
+ "version": "1.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/object-reflector.git",
+ "reference": "773f97c67f28de00d397be301821b06708fca0be"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be",
+ "reference": "773f97c67f28de00d397be301821b06708fca0be",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Allows reflection of object attributes, including inherited and non-public ones",
+ "homepage": "https://github.com/sebastianbergmann/object-reflector/",
+ "time": "2017-03-29T09:07:27+00:00"
+ },
+ {
+ "name": "sebastian/recursion-context",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/recursion-context.git",
+ "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
+ "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.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": "2017-03-03T06:23:57+00:00"
+ },
+ {
+ "name": "sebastian/resource-operations",
+ "version": "2.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/resource-operations.git",
+ "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
+ "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-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": "2018-10-04T04:07:39+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",
+ "role": "lead",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "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.12.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "550ebaac289296ce228a706d0867afc34687e3f4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4",
+ "reference": "550ebaac289296ce228a706d0867afc34687e3f4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-ctype": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.12-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "time": "2019-08-06T08:03:45+00:00"
+ },
+ {
+ "name": "theseer/tokenizer",
+ "version": "1.1.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/theseer/tokenizer.git",
+ "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9",
+ "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": "^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Arne Blankerts",
+ "email": "arne@blankerts.de",
+ "role": "Developer"
+ }
+ ],
+ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
+ "time": "2019-06-13T22:48:21+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"
+ },
+ "platform-dev": []
+}
diff --git a/docs/v1.1/README.md b/docs/v1.1/README.md
new file mode 100644
index 0000000..46ad921
--- /dev/null
+++ b/docs/v1.1/README.md
@@ -0,0 +1,136 @@
+# Instamojo PHP API [](https://packagist.org/packages/instamojo/instamojo-php) [](https://opensource.org/licenses/MIT)
+
+Assists you to programmatically create, edit and delete Links on Instamojo in PHP.
+
+**Note**: If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `'https://test.instamojo.com/api/1.1/'` as third argument to the `Instamojo` class while initializing it. API key and Auth token for the same can be obtained from https://test.instamojo.com/developers/ (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)).
+
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN, 'https://test.instamojo.com/api/1.1/');
+```
+
+## Installing via [Composer](https://getcomposer.org/)
+```bash
+$ php composer.phar require instamojo/instamojo-php
+```
+
+**Note**: If you're not using Composer then directly include the contents of `src` directory in your project.
+
+
+## Usage
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN);
+```
+
+### Create a new Payment Request
+
+```php
+try {
+ $response = $api->paymentRequestCreate(array(
+ "purpose" => "FIFA 16",
+ "amount" => "3499",
+ "send_email" => true,
+ "email" => "foo@example.com",
+ "redirect_url" => "http://www.example.com/handle_redirect.php"
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment Request that was just created.
+
+
+### Get the status or details of a Payment Request
+
+```php
+try {
+ $response = $api->paymentRequestStatus(['PAYMENT REQUEST ID']);
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment Request and the payments related to it.
+Key for payments is `'payments'`.
+
+Here `['PAYMENT REQUEST ID']` is the value of `'id'` key returned by the `paymentRequestCreate()` query.
+
+
+### Get the status of a Payment related to a Payment Request
+
+```php
+try {
+ $response = $api->paymentRequestPaymentStatus(['PAYMENT REQUEST ID'], ['PAYMENT ID']);
+ print_r($response['purpose']); // print purpose of payment request
+ print_r($response['payment']['status']); // print status of payment
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Payment Request and the payments related to it.
+Key for payments is `'payments'`.
+
+Here `['PAYMENT REQUEST ID']` is the value of `'id'` key returned by the `paymentRequestCreate()` query and
+`['PAYMENT ID']` is the Payment ID received with redirection URL or webhook.
+
+
+### Get a list of all Payment Requests
+
+```php
+try {
+ $response = $api->paymentRequestsList();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+
+This will give you an array containing Payment Requests created so far. Note that the payments related to individual Payment Request are not returned with this query.
+
+`paymentRequestsList()` also accepts an optional array containing keys `'max_created_at'` , `'min_created_at'`, `'min_modified_at'` and `'max_modified_at'` for filtering the list of Payment Requests. Note that it is not required to pass all of the keys.
+
+```php
+$response = $api->paymentRequestsList(array(
+ "max_created_at" => "2015-11-19T10:12:19Z",
+ "min_created_at" => "2015-10-29T12:51:36Z"
+ ));
+```
+
+For details related to supported datetime format check the documentation: https://www.instamojo.com/developers/request-a-payment-api/#toc-filtering-payment-requests
+
+## Available Request a Payment Functions
+
+You have these functions to interact with the Request a Payment API:
+
+ * `paymentRequestCreate(array $payment_request)` Create a new Payment Request.
+ * `paymentRequestStatus($id)` Get details of Payment Request specified by its unique id.
+ * `paymentRequestsList(array $datetime_limits)` Get a list of all Payment Requests. The `$datetime_limits` argument is optional an can be used to filter Payment Requests by their creation and modification date.
+
+## Payment Request Creation Parameters
+
+### Required
+ * `purpose`: Purpose of the payment request. (max-characters: 30)
+ * `amount`: Amount requested (min-value: 9 ; max-value: 200000)
+
+### Optional
+ * `buyer_name`: Name of the payer. (max-characters: 100)
+ * `email`: Email of the payer. (max-characters: 75)
+ * `phone`: Phone number of the payer.
+ * `send_email`: Set this to `true` if you want to send email to the payer if email is specified. If email is not specified then an error is raised. (default value: `false`)
+ * `send_sms`: Set this to `true` if you want to send SMS to the payer if phone is specified. If phone is not specified then an error is raised. (default value: `false`)
+ * `redirect_url`: set this to a thank-you page on your site. Buyers will be redirected here after successful payment.
+ * `webhook`: set this to a URL that can accept POST requests made by Instamojo server after successful payment.
+ * `allow_repeated_payments`: To disallow multiple successful payments on a Payment Request pass `false` for this field. If this is set to `false` then the link is not accessible publicly after first successful payment, though you can still access it using API(default value: `true`).
+
+
+Further documentation is available at https://docs.instamojo.com/v1.1/docs
\ No newline at end of file
diff --git a/docs/v1.1/REFUNDS.md b/docs/v1.1/REFUNDS.md
new file mode 100644
index 0000000..c8bd719
--- /dev/null
+++ b/docs/v1.1/REFUNDS.md
@@ -0,0 +1,97 @@
+## Refunds
+
+**Note**: If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `'https://test.instamojo.com/api/1.1/'` as third argument to the `Instamojo` class while initializing it. API key and Auth token for the same can be obtained from https://test.instamojo.com/developers/ (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)).
+
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN, 'https://test.instamojo.com/api/1.1/');
+```
+
+
+## Installing via [Composer](https://getcomposer.org/)
+```bash
+$ php composer.phar require instamojo/instamojo-php
+```
+
+**Note**: If you're not using Composer then directly include the contents of `src` directory in your project.
+
+
+## Usage
+
+```php
+$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN);
+```
+
+### Create a new Refund
+
+```php
+try {
+ $response = $api->refundCreate(array(
+ 'payment_id'=>'MOJO5c04000J30502939',
+ 'type'=>'QFL',
+ 'body'=>'Customer is not satified.'
+ ));
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Refund that was just created.
+
+
+### Get the details of a Refund
+
+```php
+try {
+ $response = $api->refundDetail('[REFUND ID]');
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you JSON object containing details of the Refund.
+
+Here `['REFUND ID']` is the value of `'id'` key returned by the `refundCreate()` query.
+
+
+### Get a list of all Refunds
+
+```php
+try {
+ $response = $api->refundsList();
+ print_r($response);
+}
+catch (Exception $e) {
+ print('Error: ' . $e->getMessage());
+}
+```
+
+This will give you an array containing Refunds created so far.
+
+## Available Refund Functions
+
+You have these functions to interact with the Refund API:
+
+ * `refundCreate(array $refund)` Create a new Refund.
+ * `refundDetail($id)` Get details of Refund specified by its unique id.
+ * `refundsList()` Get a list of all Refunds.
+
+## Refund Creation Parameters
+
+### Required
+ * `payment_id`: Payment ID for which Refund is being requested.
+ * `type`: A three letter short-code to identify the type of the refund. Check the
+ REST docs for more info on the allowed values.
+ * `body`: Additional explanation related to why this refund is being requested.
+
+### Optional
+ * `refund_amount`: This field can be used to specify the refund amount. For instance, you
+ may want to issue a refund for an amount lesser than what was paid. If
+ this field is not provided then the total transaction amount is going to
+ be used.
+
+Further documentation is available at https://docs.instamojo.com/v1.1/docs
diff --git a/main.php b/main.php
new file mode 100644
index 0000000..6cf51db
--- /dev/null
+++ b/main.php
@@ -0,0 +1,44 @@
+ $_ENV["CLIENT_ID"],
+ "client_secret" => $_ENV["CLIENT_SECRET"]
+
+ ],true);
+
+
+ // $transaction_id = "TEST_".time();
+ // var_dump([
+ // "name" => "XYZ",
+ // "email" => "xyz@squareboat.com",
+ // "phone" => "9999999988",
+ // "amount" => 200,
+ // "transaction_id" => $transaction_id,
+ // "currency" => "INR"
+ // ]);
+
+ $payment_request = $instaobj->createPaymentRequest([
+ 'amount'=>10,
+ 'purpose'=>"Test script"
+ ]);
+ var_dump($payment_request['id']);
+ try{
+ $gateway_order = $instaobj->createGatewayOrderForPaymentRequest(
+ "292e38e570794fa592ccf74cc84c8fda",
+ [
+ "name" => "XYZ",
+ "email" => "xyz@squareboat.com",
+ "phone" => "9999999988",
+ // "amount" => 200,
+ // "transaction_id" => $transaction_id,
+ // "currency" => "INR"
+ ]);
+
+ var_dump(json_encode($gateway_order));
+ }catch(Exception $e){
+ print('Error: ' . $e->getMessage());
+ }
+
+?>
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..22247c0
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+ tests
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Exceptions/ActionForbiddenException.php b/src/Exceptions/ActionForbiddenException.php
new file mode 100644
index 0000000..50b9e52
--- /dev/null
+++ b/src/Exceptions/ActionForbiddenException.php
@@ -0,0 +1,9 @@
+httpErrorCode = $httpErrorCode;
+ $this->errorNumber = $errorNumber;
+ $this->errorMessage = $errorMessage;
+ }
+
+ public function getHttpErrorCode() {
+ return $this->httpErrorCode;
+ }
+
+ public function getErrorNumber() {
+ return $this->errorNumber;
+ }
+
+ public function getErrorMessage() {
+ return $this->errorMessage;
+ }
+}
diff --git a/src/Exceptions/InvalidRequestException.php b/src/Exceptions/InvalidRequestException.php
new file mode 100644
index 0000000..e2dd768
--- /dev/null
+++ b/src/Exceptions/InvalidRequestException.php
@@ -0,0 +1,9 @@
+ 'oauth2/token/',
+ 'payments' => 'v'.self::API_VERSION.'/payments/',
+ 'payment_requests' => 'v'.self::API_VERSION.'/payment_requests/',
+ 'gateway_orders' => 'v'.self::API_VERSION.'/gateway/orders/',
+ 'refunds' => 'v'.self::API_VERSION.'/refunds/',
+ ];
+
+ // Static Variables
+
+ /**
+ * @property string
+ *
+ */
+ private static $apiVersion;
+
+ /**
+ * @property string
+ *
+ */
+ private static $authType;
+
+ /**
+ * @property string
+ *
+ */
+ private static $baseUrl;
+
+ /**
+ * @property string
+ *
+ */
+ private static $clientId;
+
+ /**
+ * @property string
+ *
+ */
+ private static $clientSecret;
+
+ /**
+ * @property string
+ *
+ */
+ private static $username;
+
+ /**
+ * @property string
+ *
+ */
+ private static $password;
+
+ /**
+ * @property string
+ *
+ */
+ private static $accessToken;
+
+ /**
+ * @property string
+ *
+ */
+ private static $refreshToken;
+
+ /**
+ * @property string
+ *
+ */
+ private static $scope;
+
+ /**
+ * @property Instamojo
+ *
+ */
+ private static $thisObj;
+
+ /**
+ * @return string
+ *
+ */
+ public function getAuthType()
+ {
+ return self::$authType;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getClientId()
+ {
+ return self::$clientId;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getClientSecret()
+ {
+ return self::$clientSecret;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getAccessToken()
+ {
+ return self::$accessToken;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getRefreshToken()
+ {
+ return self::$refreshToken;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getBaseUrl()
+ {
+ return self::$baseUrl;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function getScope()
+ {
+ return self::$scope;
+ }
+
+ /**
+ * @return string
+ *
+ */
+ public function __toString()
+ {
+ return sprintf(
+ 'Instamojo {'.
+ '\nauth_type=%s,'.
+ '\nclient_id=%s,'.
+ '\nclient_secret=%s,'.
+ '\nbase_url=%s,'.
+ '\naccess_token=%s'.
+ '\n}',
+ $this->getAuthType(),
+ $this->getClientId(),
+ $this->getClientSecret(),
+ $this->getBaseUrl(),
+ $this->getAccessToken()
+ );
+ }
+
+ /**
+ * __costruct method is defined as private,
+ * so "new Instamojo()" will not work
+ */
+ private function __construct() {}
+
+ /**
+ * Initializes the Instamojo environment with default values
+ * and returns a singleton object of Instamojo class.
+ *
+ * @param $type
+ * @param $params
+ * @param $test
+ *
+ * @return Instamojo
+ */
+ static function init($type='app', $params, $test=false)
+ {
+ self::validateTypeParams($type, $params);
+ self::$authType = $type;
+ self::$clientId = $params['client_id'];
+ self::$clientSecret = $params['client_secret'];
+ self::$username = isset($params['username']) ? $params['username'] : '';
+ self::$password = isset($params['password']) ? $params['password'] : '';
+ self::$baseUrl = Instamojo::PRODUCTION_BASE_URL;
+ self::$scope = isset($params['scope']) ? $params['scope'] : null;
+
+ if ($test) {
+ self::$baseUrl = Instamojo::TEST_BASE_URL;
+ }
+
+ self::$thisObj = new Instamojo();
+
+ $auth_response = self::$thisObj->auth();
+
+ self::$accessToken = $auth_response['access_token'];
+ self::$refreshToken = isset($auth_response['refresh_token']) ? $auth_response['refresh_token'] : '';
+ self::$scope = isset($auth_response['scope']) ? $auth_response['scope'] : '';
+
+ return self::$thisObj;
+ }
+
+ /**
+ * Validates params for Instamojo initialization
+ *
+ * @param $type
+ * @param $params
+ *
+ * @return null
+ *
+ * @throws InvalidRequestException
+ * @throws MissingParameterException
+ *
+ */
+ private static function validateTypeParams($type, $params)
+ {
+ if (!in_array(strtolower($type), Instamojo::VALID_TYPES)) {
+ throw new InvalidRequestException('Invalid init type');
+ }
+
+ if (empty($params['client_id'])) {
+ throw new MissingParameterException('Client Id is missing');
+ }
+
+ if (empty($params['client_secret'])) {
+ throw new MissingParameterException('Client Secret is missing');
+ }
+
+ if (strtolower($type) == 'user') {
+ if (empty($params['username'])) {
+ throw new MissingParameterException('Username is missing');
+ }
+
+ if (empty($params['password'])) {
+ throw new MissingParameterException('Password is missing');
+ }
+ }
+ }
+
+ /**
+ * Initializes baseUrl property of Instamojo class
+ *
+ * @return object
+ */
+ public function withBaseUrl($baseUrl)
+ {
+ self::$baseUrl = $baseUrl;
+ return $this;
+ }
+
+ /**
+ * Build headers for api request
+ *
+ * @return array
+ */
+ private function build_headers($auth=false)
+ {
+ $headers = [];
+
+ if(!$auth && empty(Instamojo::$accessToken)) {
+ throw new InvalidRequestException('Access token not available');
+ }
+
+ $headers[] = 'Authorization: Bearer '.Instamojo::$accessToken;
+
+ return $headers;
+ }
+
+ /**
+ * Requests api data
+ *
+ * @param $method
+ * @param $path
+ * @param $data
+ *
+ * @return array
+ *
+ */
+ private function request_api_data($method, $path, $data=[])
+ {
+ $headers = $this->build_headers(Instamojo::URIS['auth'] == $path);
+
+ $url = self::$baseUrl . $path;
+
+ return api_request($method, $url, $data, $headers);
+ }
+
+ /**
+ * Make auth request
+ *
+ * @return array
+ *
+ * @throws Exception
+ *
+ */
+ public function auth($refresh=false) {
+ $data = [
+ 'client_id' => self::$clientId,
+ 'client_secret' => self::$clientSecret,
+ ];
+
+ if ($refresh) {
+ $data['grant_type'] = 'refresh_token';
+ $data['refresh_token'] = self::$refreshToken;
+ } else {
+ switch(self::$authType) {
+ case 'app':
+ $data['grant_type'] = 'client_credentials';
+ break;
+
+ case 'user':
+ $data['grant_type'] = 'password';
+ $data['username'] = self::$username;
+ $data['password'] = self::$password;
+ break;
+ };
+ }
+
+ if(self::$scope !=null ) {
+
+ $data['scope'] = self::$scope;
+ }
+
+ $response = $this->request_api_data('POST', Instamojo::URIS['auth'], $data);
+
+ // check for access token
+ if (!isset($response['access_token'])) {
+ throw new AuthenticationException();
+ }
+
+ // check refresh token, incase of auth refresh
+ if ($refresh) {
+ if (!isset($response['refresh_token'])) {
+ throw new AuthenticationException();
+ } else {
+ self::$refreshToken = $response['refresh_token'];
+ }
+ }
+
+ self::$accessToken = $response['access_token'];
+
+ return $response;
+ }
+
+ /**
+ * Get payments
+ *
+ * @return array
+ *
+ */
+ public function getPayments($limit=null, $page=null) {
+ $data = [];
+
+ // Check per_page limit
+ if (!is_null($limit)) {
+ $data['limit'] = $limit;
+ }
+
+ // Check page number
+ if (!is_null($page)) {
+ $data['page'] = $page;
+ }
+
+ $response = $this->request_api_data('GET', Instamojo::URIS['payments'], $data);
+
+ return $response['payments'];
+ }
+
+ /**
+ * Get details of payment
+ *
+ * @return object
+ *
+ */
+ public function getPaymentDetails($id) {
+ return $this->request_api_data('GET', Instamojo::URIS['payments'] . $id . '/');
+ }
+
+ /**
+ * Get refund request for a payment
+ *
+ * @param $payment_id
+ * @param $params
+ *
+ * @return array
+ */
+ public function createRefundForPayment($payment_id, $params)
+ {
+ $data = [];
+
+ // transaction id
+ $data['transaction_id'] = (!empty($params['transaction_id'])) ? $params['transaction_id'] : null;
+
+ // refund type
+ $data['type'] = (!empty($params['type'])) ? $params['type'] : null;
+
+ // explaination body
+ $data['body'] = (!empty($params['body'])) ? $params['body'] : null;
+
+ // refund amount
+ $data['refund_amount'] = (!empty($params['refund_amount'])) ? $params['refund_amount'] : null;
+
+ $response = $this->request_api_data('POST', Instamojo::URIS['payments'] . $payment_id . '/refund/', $data);
+
+ return $response;
+ }
+
+ /**
+ * Create payment request
+ *
+ * @param $params
+ *
+ * @return array
+ *
+ */
+ public function createPaymentRequest($params)
+ {
+ $response = $this->request_api_data('POST', Instamojo::URIS['payment_requests'], $params);
+
+ return $response;
+ }
+
+ /**
+ * get payment request
+ *
+ * @param $params
+ *
+ * @return array
+ *
+ */
+ public function getPaymentRequests($limit=null, $page=null)
+ {
+ $data = [];
+
+ // Check per_page limit
+ if (!is_null($limit)) {
+ $data['limit'] = $limit;
+ }
+
+ // Check page number
+ if (!is_null($page)) {
+ $data['page'] = $page;
+ }
+
+ $response = $this->request_api_data('GET', Instamojo::URIS['payment_requests'], $data);
+
+ return $response['payment_requests'];
+ }
+
+ /**
+ * Get gateway order
+ *
+ * @param $id
+ *
+ * @return array
+ *
+ */
+ public function getPaymentRequestDetails($id)
+ {
+
+ $response = $this->request_api_data('GET', Instamojo::URIS['payment_requests'] . $id .'/');
+
+ return $response;
+ }
+
+ /**
+ * Create gateway order
+ *
+ * @param $params
+ *
+ * @return array
+ *
+ */
+ public function createGatewayOrder($params)
+ {
+ $response = $this->request_api_data('POST', Instamojo::URIS['gateway_orders'], $params);
+
+ return $response;
+ }
+
+ /**
+ * Create gateway order for payment request
+ *
+ * @param $payment_request_id
+ * @param $params
+ *
+ * @return array
+ *
+ */
+ public function createGatewayOrderForPaymentRequest($payment_request_id, $params)
+ {
+ // payment request id
+ $data = [
+ 'id' => $payment_request_id
+ ];
+
+ // name
+ $data['name'] = (!empty($params['name'])) ? $params['name'] : null;
+
+ // email
+ $data['email'] = (!empty($params['email'])) ? $params['email'] : null;
+
+ // phone
+ $data['phone'] = (!empty($params['phone'])) ? $params['phone'] : null;
+
+ $response = $this->request_api_data('POST', Instamojo::URIS['gateway_orders'] . 'payment-request/', $data);
+
+ return $response;
+ }
+
+ /**
+ * Get gateway order
+ *
+ * @param $id
+ *
+ * @return array
+ *
+ */
+ public function getGatewayOrder($id)
+ {
+ $response = $this->request_api_data('GET', Instamojo::URIS['gateway_orders'] . 'id:$id/');
+
+ return $response;
+ }
+
+ /**
+ * Get gateway orders list
+ *
+ * @param $limit
+ * @param $page
+ *
+ * @return array
+ *
+ */
+ public function getGatewayOrders($limit=null, $page=null) {
+ $data = [];
+
+ // Check per_page limit
+ if (!is_null($limit)) {
+ $data['limit'] = $limit;
+ }
+
+ // Check page number
+ if (!is_null($page)) {
+ $data['page'] = $page;
+ }
+
+ $response = $this->request_api_data('GET', Instamojo::URIS['gateway_orders'], $data);
+
+ return $response['orders'];
+ }
+
+ /**
+ * Get refunds
+ *
+ * @param $limit
+ * @param $page
+ *
+ * @return array
+ *
+ */
+ public function getRefunds($limit=null, $page=null) {
+
+ $data = [];
+
+ // Check per_page limit
+ if (!is_null($limit)) {
+ $data['limit'] = $limit;
+ }
+
+ // Check page number
+ if (!is_null($page)) {
+ $data['page'] = $page;
+ }
+
+ $response = $this->request_api_data('GET', Instamojo::URIS['refunds'], $data);
+
+ return $response['refunds'];
+ }
+
+ /**
+ * Get details of refund
+ *
+ * @param $id
+ *
+ * @return object
+ *
+ */
+ public function getRefundDetails($id) {
+ return $this->request_api_data('GET', Instamojo::URIS['refunds'] . $id . '/');
+ }
+
+ /**
+ * __clone method is defined as private,
+ * so nobody can clone the instance
+ */
+ private function __clone() {}
+
+ /**
+ * __wakeup method is defined as private,
+ * so nobody can unserialize the instance
+ */
+ private function __wakeup() {}
+
+ /**
+ * __sleep method is defined as private,
+ * so nobody can serialize the instance
+ */
+ private function __sleep() {}
+}
\ No newline at end of file
diff --git a/src/Utilities.php b/src/Utilities.php
new file mode 100644
index 0000000..915f160
--- /dev/null
+++ b/src/Utilities.php
@@ -0,0 +1,103 @@
+ $_ENV["CLIENT_ID"],
+ "client_secret" => $_ENV["CLIENT_SECRET"]
+ ],true);
+
+ $this->assertInstanceOf(Instamojo\Instamojo::class,$instaobj);
+
+ }
+
+ public function test_throw_Exception_on_worng_client_id() {
+
+ $this->expectException(\Instamojo\Exceptions\AuthenticationException::class);
+
+ $instaobj = Instamojo\Instamojo::init('app',[
+ "client_id" => "ABC",
+ "client_secret" => $_ENV["CLIENT_SECRET"]
+ ],true);
+
+ }
+
+
+ public function test_throw_Exception_on_worng_client_secret() {
+
+ $this->expectException(\Instamojo\Exceptions\AuthenticationException::class);
+
+ $instaobj = Instamojo\Instamojo::init('app',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => "ABC"
+ ],true);
+
+ }
+
+ public function test_throw_Exception_user_based_authentication_on_missing_user_name() {
+
+ $this->expectException(\Instamojo\Exceptions\MissingParameterException::class);
+
+ $instaobj = Instamojo\Instamojo::init('user',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => "ABC",
+ "password" => "XXXX"
+ ],true);
+
+ }
+
+ public function test_throw_Exception_user_based_authentication_on_missing_password() {
+
+ $this->expectException(\Instamojo\Exceptions\MissingParameterException::class);
+
+ $instaobj = Instamojo\Instamojo::init('user',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => "ABC",
+ "username" => "test_user"
+ ],true);
+
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/tests/unit/GatewayOrderTest.php b/tests/unit/GatewayOrderTest.php
new file mode 100644
index 0000000..8c8eb3d
--- /dev/null
+++ b/tests/unit/GatewayOrderTest.php
@@ -0,0 +1,107 @@
+instaobj = Instamojo\Instamojo::init('app',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => $_ENV["CLIENT_SECRET"]
+ ],true);
+ }
+
+ public function test_create_a_gateway_order()
+ {
+ $transaction_id = "TEST_".time();
+
+ $gateway_order = $this->instaobj->createGatewayOrder([
+ "name" => "XYZ",
+ "email" => "xyz@squareboat.com",
+ "phone" => "9999999988",
+ "amount" => "200",
+ "transaction_id" => $transaction_id,
+ "currency" => "INR"
+ ]);
+
+ $this->assertArrayHasKey('order',$gateway_order);
+
+ $this->assertArrayHasKey('payment_options',$gateway_order);
+
+ $this->assertEquals($transaction_id,$gateway_order['order']['transaction_id']);
+
+ }
+
+ public function test_create_a_gateway_order_for_payment_request()
+ {
+
+ $gateway_order = $this->instaobj->createGatewayOrderForPaymentRequest(
+ $_ENV['PAYMENT_REQUEST_ID'],
+ [
+ "name" => "XYZ",
+ "email" => "xyz@foo.com",
+ "phone" => "9999999988",
+ ]
+ );
+ $this->assertArrayHasKey('order_id',$gateway_order);
+
+ }
+
+
+ public function test_throw_exception_on_invalid_parameter_on_create_a_gateway_order()
+ {
+ $this->expectException(\Instamojo\Exceptions\ApiException::class);
+ $transaction_id = "TEST_".time();
+
+ $gateway_order = $this->instaobj->createGatewayOrder([
+
+ "amount" => "200",
+ "transaction_id" => $transaction_id,
+ "currency" => "INR"
+ ]);
+
+ }
+
+
+ public function test_get_gateway_orders()
+ {
+ $gateway_orders = $this->instaobj->getGatewayOrders();
+
+ $this->assertTrue(is_array($gateway_orders));
+
+ }
+
+ public function test_get_gateway_orders_with_limit_parameter()
+ {
+ $gateway_orders = $this->instaobj->getGatewayOrders(10,1);
+
+ $this->assertTrue(is_array($gateway_orders));
+ $this->assertTrue( (sizeOf($gateway_orders) <= 10 ) );
+
+ }
+
+ public function test_get_gateway_order_detail()
+ {
+ $gateway_orders = $this->instaobj->getGatewayOrders();
+
+ $this->assertTrue(is_array($gateway_orders));
+
+ if(sizeof($gateway_orders) > 0) {
+
+ $this->assertArrayHasKey('id',$gateway_orders[0]);
+
+ $gateway_order_detail = $this->instaobj->getGatewayOrder($gateway_orders[0]['id']);
+
+ $this->assertArrayHasKey('id',$gateway_order_detail);
+ $this->assertArrayHasKey('transaction_id',$gateway_order_detail);
+ $this->assertArrayHasKey('amount',$gateway_order_detail);
+ $this->assertArrayHasKey('currency',$gateway_order_detail);
+
+ }
+ }
+
+
+}
diff --git a/tests/unit/PaymentsTest.php b/tests/unit/PaymentsTest.php
new file mode 100644
index 0000000..a34234b
--- /dev/null
+++ b/tests/unit/PaymentsTest.php
@@ -0,0 +1,107 @@
+instaobj = Instamojo\Instamojo::init('app',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => $_ENV["CLIENT_SECRET"]
+ ],true);
+
+ }
+
+
+ public function test_list_of_payments()
+ {
+ $payments = $this->instaobj->getPayments();
+
+ $this->assertTrue(is_array($payments));
+ }
+
+ public function test_list_of_payments_limit()
+ {
+ $payments = $this->instaobj->getPayments(10);
+
+ $this->assertTrue(is_array($payments));
+ $this->assertTrue( (sizeOf($payments) <= 10 ) );
+ }
+
+
+ public function test_single_payment_detail()
+ {
+ $payments = $this->instaobj->getPayments();
+
+ if(sizeof($payments) > 0) {
+
+ $this->assertArrayHasKey('id',$payments[0]);
+
+ $payment_detail = $this->instaobj->getPaymentDetails($payments[0]['id']);
+
+ $this->assertArrayHasKey('id',$payment_detail);
+ $this->assertArrayHasKey('title',$payment_detail);
+ $this->assertArrayHasKey('amount',$payment_detail);
+
+ }
+ }
+
+ public function test_create_a_payment_request()
+ {
+ $payment_request = $this->instaobj->createPaymentRequest([
+ 'amount'=>10,
+ 'purpose'=>"Test script"
+ ]);
+
+ $this->assertArrayHasKey('id',$payment_request);
+ $this->assertArrayHasKey('user',$payment_request);
+ $this->assertArrayHasKey('longurl',$payment_request);
+
+ }
+
+ public function test_throw_exception_on_invalid_parameters_on_create_payment_request()
+ {
+ $this->expectException(\Instamojo\Exceptions\ApiException::class);
+
+ $payment_request = $this->instaobj->createPaymentRequest([
+
+ 'purpose'=>"Test script"
+ ]);
+ }
+
+ public function test_get_payment_requests()
+ {
+ $payment_requests = $this->instaobj->getPaymentRequests();
+
+ $this->assertTrue(is_array($payment_requests));
+ }
+
+ public function test_get_payment_requests_with_limit_paramter()
+ {
+ $payment_requests = $this->instaobj->getPaymentRequests(10,1);
+
+ $this->assertTrue(is_array($payment_requests));
+ $this->assertTrue( (sizeOf($payment_requests) <= 10 ) );
+ }
+
+ public function test_get_payment_request_details()
+ {
+ $payment_requests = $this->instaobj->getPaymentRequests();
+
+ if(sizeof($payment_requests) > 0) {
+
+ $this->assertArrayHasKey('id',$payment_requests[0]);
+ $payment_request_detail = $this->instaobj->getPaymentRequestDetails($payment_requests[0]['id']);
+
+ $this->assertArrayHasKey('id',$payment_request_detail);
+ $this->assertArrayHasKey('user',$payment_request_detail);
+ $this->assertArrayHasKey('amount',$payment_request_detail);
+ $this->assertArrayHasKey('longurl',$payment_request_detail);
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/unit/RefundsTest.php b/tests/unit/RefundsTest.php
new file mode 100644
index 0000000..aa9b899
--- /dev/null
+++ b/tests/unit/RefundsTest.php
@@ -0,0 +1,55 @@
+instaobj = Instamojo\Instamojo::init('app',[
+ "client_id" => $_ENV["CLIENT_ID"],
+ "client_secret" => $_ENV["CLIENT_SECRET"],
+ "scope" => "refunds:read"
+ ],true);
+ }
+
+ public function test_list_of_refunds()
+ {
+ $refunds = $this->instaobj->getRefunds();
+
+ $this->assertTrue(is_array($refunds));
+ }
+
+ public function test_list_of_refunds_with_limit_paramter()
+ {
+ $refunds = $this->instaobj->getRefunds(10);
+
+ $this->assertTrue(is_array($refunds));
+ $this->assertTrue( (sizeOf($refunds) <= 10 ) );
+ }
+
+ public function test_get_refund_details()
+ {
+ $refunds = $this->instaobj->getRefunds();
+
+ if(sizeof($refunds) > 0) {
+
+ $this->assertArrayHasKey('id',$refunds[0]);
+ $refund_detail = $this->instaobj->getRefundDetails($refunds[0]['id']);
+
+ $this->assertArrayHasKey('id',$refund_detail);
+ $this->assertArrayHasKey('payment',$refund_detail);
+ $this->assertArrayHasKey('amount',$refund_detail);
+ $this->assertArrayHasKey('buyer',$refund_detail);
+ }
+ }
+
+ public function test_create_refund_for_payment_throw_exception_on_invalid_parameters()
+ {
+ $this->expectException(\Instamojo\Exceptions\ApiException::class);
+ $this->instaobj->createRefundForPayment(NULL,[]);
+ }
+
+}
\ No newline at end of file