# Prepaid Coupons(Epin)

## Active Coupons

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/get/active-epin/`

This API endpoint will return a list of active coupons.

#### Query Parameters

| Name   | Type   | Description                |
| ------ | ------ | -------------------------- |
| wallet | string | eg: wallet1, wallet2, .... |
| code   | string | coupon code                |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <coupon_id>,
                "pin": "<coupon_pin>",
                "charge": "<coupon_charge>",
                "balance": "<balance>",
                "reusable": <reusable_status>,
                "transferable": <transferable_status>,
                "wallet_type": "<wallet_type>",
                "currecy_data": {
                    "decimals": <decimals>,
                    "symbol_placement": "<symbol_placement>",
                    "symbol": "<currency_symbol>",
                    "rate": <currency_multiple_rate>
                },
                "currency_code": "<currency_code>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/active-epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/get/active-epin/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## Transfer Coupon

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/transfer/epin/`

This API endpoint will transfer a coupon to a user.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| user | string | Username    |
| epin | string | Coupon id   |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/transfer/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'user': '<username>',
    'epin': '<coupon id>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/transfer/epin/',
  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 => array('user' => '<username>','epin' => '<coupon id>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld | Description                                                                                                                                           |
| ----------- | ---------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | user  | <p>User is not found.</p><p>Field may not be blank.</p><p>Self transfer not allowed.</p><p>User already has the maximum number of active coupons.</p> |
| 400         | Validation Error | epin  | <p>Coupon is not found.</p><p>Coupon is not transferable.</p><p>Invalid coupon.</p>                                                                   |

## Share Coupon

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/share/epin/`

This API endpoint will share an amount from coupon to anonymous user.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| email<mark style="color:red;">\*</mark>         | string | user mail address |
| epin<mark style="color:red;">\*</mark>          | string | coupon id         |
| share\_amount<mark style="color:red;">\*</mark> | string | amount to share   |

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

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/share/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'email': '<user_mail>',
    'epin': '<coupon_id>',
    'share_amount': '<amount>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/share/epin/',
  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 => array('email' => '<user_mail>','epin' => '<coupon_id>','share_amount' => '<share_amount>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld         | Description                                                                                                                                                               |
| ----------- | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | email         | <p>This field is required.</p><p>This field may not be blank.</p><p>Enter a valid email address.</p>                                                                      |
| 400         | Validation Error | epin          | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Coupon is not found.</p><p>Coupon is not transferable.</p> |
| 400         | Validation Error | share\_amount | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Insufficient Balance.</p>                                  |

## Delete Coupon

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/user/delete/epin/`

This API endpoint will delete a coupon.\
Use the same endpoint to get refund status without status in query params.&#x20;

#### Query Parameters

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| epin<mark style="color:red;">\*</mark> | string | Coupon id   |
| status                                 | string | 1           |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/user/delete/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Cookie': 'store_user=admin_store; sessionid=2ysk6htgc4b3w2f87zvw9cn4v5rxqkws'
  },
  formData: {}

  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/delete/epin/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld | Description                                                                                                                             |
| ----------- | ---------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | epin  | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Coupon is not found.</p> |

## Generate Coupon

### Get Wallet List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/generate/epin/`

This API endpoint will return the coupon facility enabled wallet list with data.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apiekey             |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "wallet_name": "<wallet_name>",
            "wallet_key": "<wallet>",
            "charges": "<coupon_generate_charge>",
            "ewallet_balance": "<wallet_balance>",
            "active_pins": <active_coupons>,
            "max_active_pins": <maximum_active_coupons>
        },
        ...
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/generate/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/generate/epin/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type     | Description                                                     |
| ----------- | -------------- | --------------------------------------------------------------- |
| 401         | Request Failed | Coupon facility is disabled, Please contact your administrator. |

### Create Coupon

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/generate/epin/`

This API endpoint will create a coupon.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                                     | Type   | Description       |
| -------------------------------------------------------- | ------ | ----------------- |
| wallet\_type<mark style="color:red;">\*</mark>           | string | wallet key        |
| epin\_amount<mark style="color:red;">\*</mark>           | string | amount            |
| number\_of\_pins<mark style="color:red;">\*</mark>       | string | number of coupons |
| transferable<mark style="color:red;">\*</mark>           | string | True or False     |
| reusable<mark style="color:red;">\*</mark>               | string | True or False     |
| token\_field<mark style="color:red;">\*</mark>           | string | Mail token        |
| token\_checksum\_field<mark style="color:red;">\*</mark> | string | token checksum    |
| form\_key<mark style="color:red;">\*</mark>              | string | form post key     |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/generate/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'wallet_type': '<wallet_key>',
    'epin_amount': '<amount>',
    'number_of_pins': '<number_of_coupon>',
    'form_key': '<form_key>',
    'token_checksum_field': '<token_checksum>',
    'token_field': '<token>',
    'transferable': '<True or False>',
    'reusable': '<True or False>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/generate/epin/',
  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 => array('wallet_type' => '<wallet_key>','epin_amount' => '<amount>','number_of_pins' => '<number of coupon>','form_key' => '<form key>','token_checksum_field' => '<token_cheksum>','token_field' => '<token>','transferable' => '<True or False>','reusable' => '<True or False>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld                  | Description                                                                                                                                                                                                                                      |
| ----------- | ---------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 400         | Validation Error | wallet\_type           | <p>This field is required.</p><p>This field may not be blank.</p><p>You don't have sufficient balance to continue with this operation.</p>                                                                                                       |
| 400         | Validation Error | epin\_amount           | <p>Invalid or empty Amount.</p><p>This field is required.</p><p>This field may not be blank.</p><p>Please enter an amount between \<min> and \<max>.</p><p>Only integers are allowed.</p><p>Ensure this field has no more than 7 characters.</p> |
| 400         | Validation Error | number\_of\_pins       | <p>This field is required.</p><p>This field may not be blank.</p><p>This operation exceeds the maximum number of active Coupons.</p><p>Invalid number of Coupon.</p><p>Only numeric characters are allowed.</p>                                  |
| 400         | Validation Error | transferable           | <p>This field is required.</p><p>This field may not be blank.</p><p>Select True or False</p>                                                                                                                                                     |
| 400         | Validation Error | reusable               | <p>This field is required.</p><p>This field may not be blank.</p><p>Select True or False</p>                                                                                                                                                     |
| 400         | Validation Error | token\_checksum\_field | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                                                |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>This field may not be blank.</p><p>Token is not matching.</p>                                                                                                                                                   |
| 400         | Validation Error | form\_key              | You have another form running, Please reload.                                                                                                                                                                                                    |
| 401         | Request Failed   |                        | Coupon facility is disabled, Please contact your administrator.                                                                                                                                                                                  |

## Coupon History

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/epin/history/`

This API endpoint will return the history of used coupons.

#### Query Parameters

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| wallet | string | wallet key, eg: wallet1, wallet2, etc |

#### Headers

| Name                                            | Type   | Description          |
| ----------------------------------------------- | ------ | -------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey               |
| Authorization<mark style="color:red;">\*</mark> | string | Bearere access token |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "charge": "<charge>",
                "currecy_data": {
                    "decimals": <decimals>,
                    "symbol_placement": "<symbol_placement>",
                    "symbol": "<symbol>",
                    "rate": <multiple_rate>
                },
                "currency_code": "<currency_code>",
                "pin": "<coupon_pin>",
                "used_on": "<used_date>"
            }
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url> 
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/epin/history/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/epin/history/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```


---

# 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://api.epixelsoftware.help/prepaid-coupons-epin.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.
