PHPackages                             instamojo/instamojo-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. instamojo/instamojo-php

ActiveLibrary[API Development](/categories/api)

instamojo/instamojo-php
=======================

This is composer wrapper for instamojo-php

1.0(5y ago)62374.9k—5.9%91[8 issues](https://github.com/Instamojo/instamojo-php/issues)[4 PRs](https://github.com/Instamojo/instamojo-php/pulls)MITPHPPHP &gt;=5.3.0CI failing

Since Mar 30Pushed 4y ago34 watchersCompare

[ Source](https://github.com/Instamojo/instamojo-php)[ Packagist](https://packagist.org/packages/instamojo/instamojo-php)[ Docs](https://github.com/instamojo/instamojo-php/)[ RSS](/packages/instamojo-instamojo-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (9)Used By (0)

Instamojo PHP API [![Latest Stable Version](https://camo.githubusercontent.com/9f3d9024bddb4b99ed01418a61b26308b5e70d608433c01c2b85efab4ae397c8/68747470733a2f2f706f7365722e707567782e6f72672f696e7374616d6f6a6f2f696e7374616d6f6a6f2d7068702f762f737461626c65)](https://packagist.org/packages/instamojo/instamojo-php) [![License](https://camo.githubusercontent.com/ee8aa875adeec43fa45eb8168a1a27365eacd7dc783c61da7c7a38ccc62636b1/68747470733a2f2f706f7365722e707567782e6f72672f696e7374616d6f6a6f2f696e7374616d6f6a6f2d7068702f6c6963656e7365)](https://opensource.org/licenses/MIT)
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#instamojo-php-api--)

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)).

```
$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/)
---------------------------------------------------

[](#installing-via-composer)

```
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
-----

[](#usage)

```
$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
-------------

[](#documentation)

See the Documentation for datailed instructions

- [ v1.1 Documentation ](https://docs.instamojo.com/v1.1)
- [ v2 Documentation ](https://docs.instamojo.com/v2)

Table of Content
----------------

[](#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

[](#-create-a-new-payment-request)

```
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

[](#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](https://docs.instamojo.com/page/seamless-checkout).

### Payment Request Creation Parameters

[](#payment-request-creation-parameters)

### Required

[](#required)

- `purpose`: Purpose of the payment request.
- `amount`: The amount for the request. The minimum amount is 9. And the maximum is 200000.

### Optional

[](#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
--------------------------------------------------------------------------------------------------------

[](#-get-the-status-or-details-of-a-payment-request)

```
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
---------------------------------------------------------------------------------------

[](#-get-a-list-of-all-payment-requests)

```
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.

```
getPaymentRequests($limit=null, $page=null)
```

For example:

```
$response = $api->getPaymentRequests(50, 1);
```

 Get a list of all Payments
-------------------------------------------------------------------------------

[](#-get-a-list-of-all-payments)

```
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.

```
getPayments($limit=null, $page=null)
```

For example:

```
$response = $api->getPayments(50, 1);
```

 Get the details of a Payment
---------------------------------------------------------------------------------

[](#-get-the--details-of-a-payment)

```
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
-----------------------------------------------------------------------

[](#-create-a-gateway-order)

```
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
---------------------------------------------------------------------------------------------------------------

[](#-create-a-gateway-order-for-payment-request)

```
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
----------------------------------------------------------------------------------------

[](#-get-the-details-of-a-gateway-order)

```
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
--------------------------------------------------------------------------------------

[](#-get-a-list-of-all-gateway-order)

```
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.

```
getGatewayOrders($limit=null, $page=null)
```

For example:

```
$response = $api->getGatewayOrders(50, 1);
```

 Create a Refund for a payment
-----------------------------------------------------------------------------------

[](#-create-a-refund-for-a-payment)

```
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

[](#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
--------------------------------------------------------------------------

[](#-get-the-details-of-a-refund)

```
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

[](#-get-a-list-of-all-refunds)

```
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.

```
getRefunds($limit=null, $page=null)
```

For example:

```
$response = $api->getRefunds(50, 1);
```

 Common FAQ's
---------------------------------------------

[](#-common-faqs)

- [ How to get your client Id and Client secret ](https://support.instamojo.com/hc/en-us/articles/212214265-How-do-I-get-my-Client-ID-and-Client-Secret-)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 53% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~377 days

Total

5

Last Release

2079d ago

Major Versions

0.4 → 1.02020-09-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/28936c6e64651912d0a64d64cd6bb21747b0906c025d0a8579e34ac36de1d2a4?d=identicon)[ashwch](/maintainers/ashwch)

![](https://www.gravatar.com/avatar/3af7a29d7e1e0880ce27802c9eaa650c1f4fb65c93fd2a9cdf03acc19c448877?d=identicon)[instamojo](/maintainers/instamojo)

---

Top Contributors

[![ashwch](https://avatars.githubusercontent.com/u/1311161?v=4)](https://github.com/ashwch "ashwch (79 commits)")[![rishimukherjee](https://avatars.githubusercontent.com/u/1550303?v=4)](https://github.com/rishimukherjee "rishimukherjee (13 commits)")[![hiway](https://avatars.githubusercontent.com/u/23116?v=4)](https://github.com/hiway "hiway (11 commits)")[![ved-squareboat](https://avatars.githubusercontent.com/u/68990089?v=4)](https://github.com/ved-squareboat "ved-squareboat (9 commits)")[![deepanshsachdeva](https://avatars.githubusercontent.com/u/5393801?v=4)](https://github.com/deepanshsachdeva "deepanshsachdeva (9 commits)")[![sb-vinayak](https://avatars.githubusercontent.com/u/65220692?v=4)](https://github.com/sb-vinayak "sb-vinayak (5 commits)")[![vijithv](https://avatars.githubusercontent.com/u/7094498?v=4)](https://github.com/vijithv "vijithv (4 commits)")[![indradhanush](https://avatars.githubusercontent.com/u/2682729?v=4)](https://github.com/indradhanush "indradhanush (4 commits)")[![sarthakk97](https://avatars.githubusercontent.com/u/47442052?v=4)](https://github.com/sarthakk97 "sarthakk97 (4 commits)")[![saich](https://avatars.githubusercontent.com/u/350338?v=4)](https://github.com/saich "saich (3 commits)")[![nikhilsquareboat](https://avatars.githubusercontent.com/u/45254157?v=4)](https://github.com/nikhilsquareboat "nikhilsquareboat (3 commits)")[![mojodhanesh](https://avatars.githubusercontent.com/u/46320665?v=4)](https://github.com/mojodhanesh "mojodhanesh (2 commits)")[![yashgoenka-im](https://avatars.githubusercontent.com/u/60094949?v=4)](https://github.com/yashgoenka-im "yashgoenka-im (2 commits)")[![ChaudhariAmolSopan](https://avatars.githubusercontent.com/u/397048?v=4)](https://github.com/ChaudhariAmolSopan "ChaudhariAmolSopan (1 commits)")

---

Tags

integrationswrappersphpapiwrapperinstamojo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/instamojo-instamojo-php/health.svg)

```
[![Health](https://phpackages.com/badges/instamojo-instamojo-php/health.svg)](https://phpackages.com/packages/instamojo-instamojo-php)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
