# Payments

## Get all payments

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/payments`

Retrieve the latest payments (up to a maximum of 100) made on your webstore.

#### Query Parameters

| Name  | Type   | Description                            |
| ----- | ------ | -------------------------------------- |
| limit | number | Limit the amount of payments returned. |

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

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

```javascript
[
  {
    "id": 1,
    "amount": "4.99",
    "date": "2016-01-27T15:40:19+0000",
    "currency": {
      "iso_4217": "GBP",
      "symbol": "£"
    },
    "gateway": {
      "id": 24,
      "name": "PayPal"
    },
    "status": "Complete",
    "email": "test@test.com",
    "player": {
      "id": 1,
      "name": "Notch",
      "uuid": "365bfa21803249ee9b634fe890c9d43f"
    },
    "packages": [
      {
        "id": 13,
        "name": "Test Package"
      }
    ],
    "notes": [
      "created_at": "2022-01-01 10:13:04",
      "note": "Test Note"
    ],
    "creator_code": "creator123"
  },
  {
    "id": 2,
    "amount": "9.99",
    "date": "2016-01-18T11:37:38+0000",
    "currency": {
      "iso_4217": "GBP",
      "symbol": "£"
    },
    "gateway": {
      "id": 24,
      "name": "PayPal"
    },
    "status": "Refund",
    "email": "test@test.com",
    "player": {
      "id": 2,
      "name": "7n",
      "uuid": "ef01f2da1b284ad6ba8ba2aaf4432e22"
    },
    "packages": [
      {
        "id": 13,
        "name": "Test Package"
      }
    ],
    "notes": [
      "created_at": "2022-01-01 10:13:04",
      "note": "Test Note"
    ],
    "creator_code": "creator123"
  }
]
```

{% endtab %}
{% endtabs %}

## Get all payments paginated

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/payments?paged=1`

Return all pages, paginated into pages of 25

#### Path Parameters

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| page | integer | The page number to return |

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

```javascript
{
    "total": 146133,
    "per_page": 25,
    "current_page": 2,
    "last_page": 5846,
    "next_page_url": "https://plugin.tebex.io/payments?page=3",
    "prev_page_url": "https://plugin.tebex.io/payments?page=1",
    "from": 26,
    "to": 50,
    "data": [
        {
            "id": 123456,
            "amount": "9.99",
            "date": "2020-03-05T15:34:46+00:00",
            "gateway": {
                "id": 21,
                "name": "Xsolla"
            },
            "status": "Complete",
            "currency": {
                "iso_4217": "GBP",
                "symbol": "£"
            },
            "player": {
                "id": 1,
                "name": "Notch",
                "uuid": "365bfa21803249ee9b634fe890c9d43f"
            },
            "packages": [
                {
                    "id": 1234,
                    "name": "Test Package
                }
            ],
            "notes": [
                "created_at": "2022-01-01 10:13:04",
                "note": "Test Note"
            ],
            "creator_code": "creator123"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Retrieve a payment

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/payments/{transaction}`

Retrieve a payment made on your webstore by transaction ID.

#### Path Parameters

| Name        | Type   | Description                      |
| ----------- | ------ | -------------------------------- |
| transaction | string | The transaction ID of a payment. |

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

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

```javascript
{
  "id": 1,
  "amount": "4.99",
  "status": "Complete",
  "date": "2016-01-27T15:40:19+0000",
  "currency": {
    "iso_4217": "GBP",
    "symbol": "£"
  },
  "player": {
    "id": 1,
    "name": "Notch",
    "uuid": "365bfa21803249ee9b634fe890c9d43f"
  },
  "packages": [
    {
        "id": 100001,
        "name": "Test Package"
    },
    {
        "id": 100002,
        "name": "Test Package 2"
    }
  ],
  "notes": [
    "created_at": "2022-01-01 10:13:04",
    "note": "Test Note"
  ],
  "creator_code": "creator123"
}
```

{% endtab %}
{% endtabs %}

## Get the required payment fields for a package

<mark style="color:blue;">`GET`</mark> `https://plugin.tebex.io/payments/fields/{package}`

Returns an array of fields (custom variables, etc) required to be entered for a manual payment to be created for a package.

#### Path Parameters

| Name    | Type   | Description          |
| ------- | ------ | -------------------- |
| package | string | The ID of a package. |

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

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

```javascript
[
  {
    "name": "price",
    "value": "Custom Price",
    "type": "numeric"
  },
  {
    "name": "server",
    "description": "Select a server to run commands on",
    "type": "dropdown",
    "options": [
      {
        "label": "Test Store",
        "value": 7
      },
      {
        "label": "Empty Server",
        "value": 21
      }
    ]
  },
  {
    "name": "uname",
    "description": "uname",
    "type": "username",
    "options": false
  },
  {
    "name": "global",
    "description": "Global level",
    "type": "numeric",
    "options": false
  }  
]
```

{% endtab %}
{% endtabs %}

## Create a payment

<mark style="color:green;">`POST`</mark> `https://plugin.tebex.io/payments`

Create a manual payment in the same way as is possible from the control panel. One or more packages should be added to the payment, and the package commands will be processed in the same way as would be for a standard manual payment.

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

#### Request Body

| Name                  | Type    | Description                                                                                              |
| --------------------- | ------- | -------------------------------------------------------------------------------------------------------- |
| note                  | string  | A note to assign to the payment.                                                                         |
| packages\[]\[options] | object  | An object of key => value pairs for the required option fields (as retrieved from the /fields endpoint). |
| packages\[]\[id]      | number  | The ID of the package.                                                                                   |
| packages              | array   | Array of packages to add to the payment.                                                                 |
| price                 | integer | The price of the payment.                                                                                |
| ign                   | string  | The username of the user to apply the payment to.                                                        |

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

```
```

{% endtab %}
{% endtabs %}

## Update a payment

<mark style="color:orange;">`PUT`</mark> `https://plugin.tebex.io/payments/{transaction}`

Update a payment.

#### Path Parameters

| Name        | Type   | Description                        |
| ----------- | ------ | ---------------------------------- |
| transaction | string | The transaction ID of the payment. |

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

#### Request Body

| Name     | Type   | Description                                                             |
| -------- | ------ | ----------------------------------------------------------------------- |
| username | string | The username that the payment should be applied to.                     |
| status   | string | The status of the payment, either 'complete', 'chargeback' or 'refund'. |

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

```
```

{% endtab %}
{% endtabs %}

## Create a payment note

<mark style="color:green;">`POST`</mark> `https://plugin.tebex.io/payments/{transaction}/note`

Create a note against a payment.

#### Path Parameters

| Name        | Type   | Description                        |
| ----------- | ------ | ---------------------------------- |
| transaction | string | The transaction ID of the payment. |

#### Headers

| Name           | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| X-Tebex-Secret | string | The secret key of a server. |

#### Request Body

| Name | Type   | Description                          |
| ---- | ------ | ------------------------------------ |
| note | string | The note to add against the payment. |

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

```
```

{% 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.tebex.io/plugin/endpoints/payments.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.
