# Payments

## Get all payments

<mark style="color:blue;">`GET`</mark> `https://wemx.app/api/v1/payments`

Returns all payments made on your application

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

```json
{
    "status": true,
    "current_page": 1,
    "data": [
        {
            "id": "21087b8f-532c-4a83-86ce-35d5406d5932",
            "user_id": 1,
            "order_id": 2,
            "package_id": 1,
            "price_id": 1,
            "type": "once",
            "description": "Universal",
            "status": "paid",
            "currency": "USD",
            "amount": 5,
            "transaction_id": "21087b8f-532c-4a83-86ce-35d5406d5932",
            "handler": "App\\Handlers\\NewOrder",
            "gateway": {
                "id": 1,
                "name": "Balance",
                "type": "once",
                "driver": "Balance",
                "class": "App\\Models\\Gateways\\BalanceGateway",
                "endpoint": "balance",
                "refund_support": 1,
                "blade_edit_path": null,
                "status": 1,
                "created_at": "2024-01-09T18:29:17.000000Z",
                "updated_at": "2024-01-09T18:29:17.000000Z",
                "default": 0
            },
            "data": [],
            "options": {
                "coupon": null
            },
            "show_as_unpaid_invoice": 0,
            "notes": null,
            "due_date": null,
            "created_at": "2024-01-09T18:29:25.000000Z",
            "updated_at": "2024-01-09T18:29:25.000000Z"
        }
    ],
    "first_page_url": "http://wemx.app/api/v1/payments?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "http://wemx.app/api/v1/payments?page=1",
    "links": [
        {
            "url": null,
            "label": "Previous",
            "active": false
        },
        {
            "url": "http://wemx.app/api/v1/payments?page=1",
            "label": "1",
            "active": true
        },
        {
            "url": null,
            "label": "Next",
            "active": false
        }
    ],
    "next_page_url": null,
    "path": "http://wemx.app/api/v1/payments",
    "per_page": 15,
    "prev_page_url": null,
    "to": 2,
    "total": 2
}
```

{% endtab %}
{% endtabs %}

### Available Relationships (optional)

```
https://wemx.app/api/v1/payments?include=user,order,price
```

#### Available relationships:

`user`, `order`, `package`, `price`

## Filters (optional)

```
https://wemx.app/api/v1/payments?filter[transaction_id]=test
```

#### Available Filters:

`id`, `payment_id`, `price_id`, `order_id`, `user_id`, `status`, `type`, `currency`, `amount`, `transaction_id`, `gateway`, `data`, `options`

Tip: To filter JSON columns such as gateway, data and options, you can specify the key using \
`?filter[gateway->driver]=PayPal`

## Sorting (optional)

```
https://wemx.app/api/v1/payments?sort[created_at]=asc
```

#### Available Sorting Parameters:

`description`, `status`, `type`, `currency`, `amount`, `options`, `created_at`

#### Sorting operators

`asc`, `desc`, `random`

## Dates (optional)

```
https://wemx.app/api/v1/payments?date=30days
```

<table><thead><tr><th width="390">Operator</th><th>Description</th></tr></thead><tbody><tr><td>today</td><td>Get payments created today</td></tr><tr><td>yesterday</td><td>Get payments created yesterday</td></tr><tr><td><code>3days</code>, <code>7days</code>, <code>14days</code>, <code>30days</code>, <code>90days</code></td><td>Get payments created last x days</td></tr><tr><td>YYYY-MM-DD,YYY-MM-DD</td><td>Get payments created between a range of dates</td></tr></tbody></table>

## Generate a payment

<mark style="color:green;">`POST`</mark> `https://wemx.app/api/v1/payments/generate`

Generate a payment on your application and redirect the user to pay it

If the payment is generated successfully, the API responds with a list of links in the links object for each gateway that the user can use to directly pay the payment. You can display these links for the user to choose a gateway.

#### Request Body

| Name                                          | Type    | Description                                         |
| --------------------------------------------- | ------- | --------------------------------------------------- |
| user\_id<mark style="color:red;">\*</mark>    | Numeric | ID of the user for which you want to create payment |
| description<mark style="color:red;">\*</mark> | String  | Short description of the payment                    |
| amount<mark style="color:red;">\*</mark>      | Numeric | The amount for the payment                          |
| data                                          | Array   | Pass custom data as an array                        |
| notes                                         | String  | Write a note about the payment                      |
| show\_as\_invoice                             | Boolean | Show the payment as an invoice on the application   |

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

```json
{
    "success": true,
    "payment": "43d5c727-df50-4826-8c33-01d4e5213fd4",
    "links": [
        {
            "Balance": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=1"
        },
        {
            "PayPal": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=2"
        },
        {
            "Tebex": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=3"
        },
        {
            "Tebex": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=4"
        },
        {
            "stripecheckout": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=7"
        },
        {
            "Pay By Link": "https://wemx.app/payment/invoice/43d5c727-df50-4826-8c33-01d4e5213fd4/pay?gateway=9"
        }
    ]
}
```

{% 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://wemx.gitbook.io/wemx-api/api-reference/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.
