> For the complete documentation index, see [llms.txt](https://docs.vendex.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vendex.app/developer/cloud-api-for-app/transaction.md).

# Transaction

## Making a payment

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/transaction/payment/`

API call from a sender to make a payment. Transaction signature given in the API will determine who the recipient is.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login.                     |
| Content-Type     | string | Content-type need to be set as application/json          |

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

```javascript
{
    "status": "success",
    "detail": "Payment successful",
    "data": {
        "transaction_id": 1029,
        "recipient_name": "John Doe",
        "amount": "500.00",
        "currency_code": "USD",
        "created": "2020-09-09T07:14:39.660639Z",
        "description": "Payment Pizza hut - Airport, Vegas.",
    }
}
```

{% endtab %}
{% endtabs %}

#### Example of POST data (JSON)

```javascript
{
    "amount": 100.00,
    "currency_code": "USD",
    "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2"
}
```

## Authorize payment

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/transaction/authorize/`

This method is to allow merchant to charge account. When user scan a QR with type "sale\_point", app will give authorization to the merchant so that it can charge later with any amount (limited to account balance and charge limit). It can be used for a vending, taxi or any suitable application. Transaction signature is required for this call.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login.                     |
| Content-Type     | string | Content type need to be set as application/json          |

{% tabs %}
{% tab title="200 Successful API call  will set Authorization signature which must be used in further payment operations. also trigger notify\_url along with appropriate data to inform merchant server. " %}

```javascript
{
    "status": "success",
    "detail": "Payment authorization successful"
}
```

{% endtab %}
{% endtabs %}

#### Example of POST data(JSON)

```javascript
{
    "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2"
}
```

## Cancel previous payment authorization

<mark style="color:blue;">`GET`</mark> `https://api.vendex.app/api/transaction/authorize_cancel/`

This method is to cancel all open authorization.

#### Headers

| Name             | Type   | Description                                             |
| ---------------- | ------ | ------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method |
| Api-User-Token   | string | User token obtained from user login                     |

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

```javascript
{
    "status": "success",
    "detail": "Cancel payment authorization successful"
}
```

{% endtab %}
{% endtabs %}

## Conducting a refund

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/transaction/refund/`

To conduct refund on previous transaction. Refund amount can be partial or full. One transaction can have multiple refunds as long as the total refund amount is no greater than the original transaction amount.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login.                     |
| Content-Type     | string | Content-type need to be set as application/json.         |

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

```javascript
{
    "status": "success",
    "detail": "Refund successful"
}
```

{% endtab %}
{% endtabs %}

#### Example of POST data (JSON)

```javascript
{
    "amount": 50.00,
    "currency_code": "USD",
    "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2"
    "description": "Customer refund."
}
```

## Set transaction signature

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/signature/set/`

To set signature with the payment request amount. If signature is not set, sender has the capability to enter amount when making a payment.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login.                     |
| Content-Type     | string | Content-type need to be set as application/json          |

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

```javascript
{
    "status": "success",
    "detail": "Set transaction signature successful"
    "data": {
        "recipient_name": "John Doe",
        "amount": "500.00",
        "currency_code": "USD",
        "description": "Payment Pizza hut - Airport, Vegas.",
        "amount_required": false,
        "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2",
        "recipient_profile_image_url": "https://nxpay-uploaded-media.s3.ap-south-1.amazonaws.com/upload/9c900a41-9027-4218-9737-f91db6cf4f53.png"
    }
}
```

{% endtab %}
{% endtabs %}

#### Example of POST data (JSON)

```javascript
{
    "amount": 500.00,
    "currency_code": "USD",
    "description": "Payment Pizza hut - Airport, Vegas."
}
```

## Get transaction signature&#x20;

<mark style="color:blue;">`GET`</mark> `https://api.vendex.app/api/signature/get/?account_number=1234567812345678`

To get transaction signature before making a transaction. Result can include amount if it is set by the recipient.

#### Query Parameters

| Name            | Type    | Description                                       |
| --------------- | ------- | ------------------------------------------------- |
| account\_number | integer | Account number can retrieved from QR code/Barcode |

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login method.              |

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

```javascript
// Amount known
{
    "status": "success",
    "detail": "Transaction signature obtained successful",
    "data": {
        "recipient_name": "John Doe",
        "amount": 500.00,
        "currency_code": "USD"
        "description": "Payment Pizza hut - Airport, Vegas.",
        "amount_required": false,
        "authorization_required": false,
        "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2",
        "recipient_profile_image_url": "https://nxpay-uploaded-media.s3.ap-south-1.amazonaws.com/upload/9c900a41-9027-4218-9737-f91db6cf4f53.png"
    }
}

// Amount unknown
{
    "status": "success",
    "detail": "Transaction signature obtained successful",
    "data": {
        "recipient_name": "John Doe",
        "amount": 0.00,
        "currency_code": "USD"
        "description": "",
        "amount_required": true,
        "authorization_required": false,
        "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2",
        "recipient_profile_image_url": "https://nxpay-uploaded-media.s3.ap-south-1.amazonaws.com/upload/9c900a41-9027-4218-9737-f91db6cf4f53.png"
    }
}

// Amount unknown for merchant
{
    "status": "success",
    "detail": "Transaction signature obtained successful",
    "data": {
        "recipient_name": "Nexlytics vending 001",
        "amount": 0.00,
        "currency_code": "USD"
        "description": "",
        "amount_required": true,
        "authorization_required": true,
        "transaction_signature": "9ef4e5f81dacd2b844c28a7e674cd13961e821c9b559a08b926c736fc5aaffa2",
        "recipient_profile_image_url": "https://nxpay-uploaded-media.s3.ap-south-1.amazonaws.com/upload/9c900a41-9027-4218-9737-f91db6cf4f53.png"
    }
}
```

{% endtab %}
{% endtabs %}

## Cancel transaction signature

<mark style="color:blue;">`GET`</mark> `https://api.vendex.app/api/signature/cancel/`

To cancel signature where signature is set while request a payment.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login method.              |

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

```javascript
{
    "status": "success",
    "detail": "Cancel transaction signature successful"
}
```

{% endtab %}
{% endtabs %}
