# Payment API

### Guidelines

Below are some of the points you must be aware of while calling Swipez APIs:

* All API responses are in JSON format.
* POST requests should include `ContentType: application/json`&#x20;
* All API response have **status, message,** and **data**.
* Swipez uses API keys to allow access to the API. Once you have signed up at our merchant site, you will be able to see your [AccessKey and SecretKey](https://www.swipez.in/merchant/profile/accesskey).

### Rate limiting

The API is rate limited per user. You will receive a 429 HTTP status code if you exceed the rate limit. The rate limit is 30 requests per minute per user and is subject to change.

### Quick Reference

| URL                                                                                          | HTTP Verb | Functionality                        |
| -------------------------------------------------------------------------------------------- | --------- | ------------------------------------ |
| [/api/v1/merchant/payment/received](https://docs.swipez.in/payment-gateway#payment-received) | POST      | To get list of payment transactions. |
| [/api/v1/merchant/payment/status](https://docs.swipez.in/payment-gateway#payment-status)     | POST      | To get status of payment.            |

## Payment received&#x20;

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/payment/received`

This endpoint allows you to get list of payment transactions.

#### Request Body

| Name                | Type   | Description                                                        |
| ------------------- | ------ | ------------------------------------------------------------------ |
| access\_key\_id     | string | Your access key.                                                   |
| secret\_access\_key | string | Your secret key.                                                   |
| from\_date          | string | From date (in the format YYYY-mm-dd) from which you want the data. |
| to\_date            | string | To Date till you want the data                                     |

{% tabs %}
{% tab title="200 " %}

```
{
    "reqtime": "2021-03-02 16:44:10",
    "resptime": "2021-03-02 16:44:10",
    "srvrsp": [
        {
            "customer_name": "Rohit Sharma",
            "email": "rohit@swipez.in",
            "code": "cust-1",
            "transaction_id": "T000002546",
            "invoice_id": "R000029134",
            "amount": "472.00",
            "late_fee": "0.00",
            "paid_date": "2021-02-05 11:12:12",
            "payment_mode": "Online Payment"
        },
        {
            "customer_name": "Virat Kohli",
            "email": "virat@swipez.in",
            "code": "cust-2",
            "transaction_id": "T000002548",
            "invoice_id": "R000029146",
            "amount": "472.00",
            "late_fee": "0.00",
            "paid_date": "2021-02-15 16:35:01",
            "payment_mode": "Online Payment"
        }
    ],
    "errcode": null,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```
curl --location --request POST '<BASE URL>/api/v1/merchant/payment/received' \
--header 'Content-Type: application/json' \
--data-raw '{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"from_date": "2021-02-04",
	"to_date": "2021-03-03"
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/payment/received',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"from_date": "2021-02-04",
	"to_date": "2021-03-03",
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}

## Payment status

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/payment/status`

This endpoint allows you to get status of payment transaction.

#### Request Body

| Name                | Type   | Description                                                                                                                                                  |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| access\_key\_id     | string | Your access key.                                                                                                                                             |
| secret\_access\_key | string | Your secret key.                                                                                                                                             |
| transaction\_type   | string | <p>Transaction type <br>MERCHANT\_TRANS\_ID : Merchant reference no.<br>SWIPEZ\_TRANS\_ID: Swipez transaction ID.<br>SWIPEZ\_REQ\_ID: Swipez invoice id.</p> |
| id                  | string | Value for transaction type                                                                                                                                   |

{% tabs %}
{% tab title="200 To get payment transaction status." %}

```
{
    "reqtime": "2021-03-02 17:03:05",
    "resptime": "2021-03-02 17:03:05",
    "srvrsp": {
        "transaction_id": "X000087677",
        "reference_no": "1694SZ",
        "status": "success",
        "date": "2021-01-21 18:44:23",
        "bank_ref_no": "8548787",
        "mode": "NET_BANKING",
        "amount": "1000.00",
        "billing_name": "Rohit Sharma",
        "billing_email": "rohit@swipez.in",
        "billing_mobile": "9999999999",
        "billing_address": "Behala Manton Super Market, Room 43, Behala",
        "billing_city": "Kolkata",
        "billing_state": "West Bengal",
        "billing_postal_code": "84587",
        "udf1": "",
        "udf2": "",
        "udf3": "",
        "udf4": "",
        "udf5": ""
    },
    "errcode": null,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```
curl --location --request POST '<BASE URL>/api/v1/merchant/payment/status' \
--header 'Content-Type: application/json' \
--data-raw '{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"transaction_type": "SWIPEZ_TRANS_ID",
	"id": "X000028783"
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/payment/status',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"transaction_type": "SWIPEZ_TRANS_ID",
	"id": "X000028783"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swipez.in/payment-gateway/payment-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
