# P2P Transfer

## Get Transfer Data

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

This API endpoint will return p2p transfer charges and user data.&#x20;

#### Query Parameters

| Name     | Type   | Description                    |
| -------- | ------ | ------------------------------ |
| wallet   | string | wallet key, default is wallet1 |
| reciever | string | username                       |

#### 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": {
        "wallet_data": {
            "wallet_balance": <wallet_balance>,
            "transfer_charges": {
                "transfer_charge": "<transfer_charge>",
                "max_transfer_amount": "<max_transfer_amount>",
                "min_transfer_amount": "<min_transfer_amount>",
                "transfer_charge_type": "<transfer_charge_type>"
            },
            "currency_data": {
                "decimals": <decimals>,
                "symbol_placement": "<symbol_placement>",
                "symbol": "<symbol>",
                "rate": <multiple_rate>
            }
        },
        "userdata": {
            "username": "<reciever_username>",
            "name": "<name>",
            "profile_image": "<profile_image_url>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

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

```

**PHP**

```javascript
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/p2p/transfer/',
  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       | FIeld    | Description                                                                                         |
| ----------- | ---------------- | -------- | --------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |          | P2P transactions are disabled, Please contact your administrator.                                   |
| 400         | Validation Error | wallet   | P2P transactions are disabled for this wallet, Please contact your administrator or invalid wallet. |
| 400         | Validation Error | reciever | <p>This field is required.</p><p>Reciever not found.</p><p>Self transfer not allowed.</p>           |

## P2P Transfer

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

This API endpoint will perform a p2p transfer.

#### 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                 | string | wallet key        |
| transfer\_amount       | string | transfer amount   |
| reciever               | string | reciever username |
| form\_key              | string | form key          |
| token\_checksum\_field | string | token checksum    |
| token\_field           | string | mail 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**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/p2p/transfer/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'wallet': '<wallet_key>',
    'transfer_amount': '<amount>',
    'reciever': '<reciever_username>',
    'form_key': '<form_key>',
    'token_checksum_field': '<token_checksum>',
    'token_field': '<token>'
  }
};
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/p2p/transfer/',
  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' => '<wallet_key>','transfer_amount' => '<amount>','reciever' => '<reciever_username>','form_key' => '<form_key>','token_checksum_field' => '<token_cheksum>','token_field' => '<token>'),
  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                 | <p>This field is required.</p><p>This field may not be blank.</p><p>P2P transactions are disabled for this wallet, Please contact your administrator or invalid wallet.</p>                                                                                                                                                         |
| 400         | Validation Error | transfer\_amount       | <p>This field is required.</p><p>This field may not be blank.</p><p>Minimum transaction amount is \<min\_amount>.</p><p>Transaction Limit is \<max\_amount>.</p><p>Ensure this field has no more than 7 characters.</p><p>Only integers are allowed.</p><p>Entered amount is greater than wallet balance.</p><p>Invalid amount.</p> |
| 400         | Validation Error | reciever               | <p>This field is required.</p><p>This field may not be blank.</p><p>Reciever user not found.</p><p>Self transfer not allowed.</p>                                                                                                                                                                                                   |
| 400         | Validation Error | form\_key              | <p>This field is required.</p><p>This field may not be blank.</p><p>You have another form running, Please reload.</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><p>Only numeric characters are allowed.</p>                                                                                                                                                                                           |
| 401         | Request Failed   |                        | P2P transactions are disabled, Please contact your administrator.                                                                                                                                                                                                                                                                   |
