# Payments

The **Payment resource** in IVPAY allows you to create and read payment requests. You can initiate payments with specified fiat amounts and monitor their statuses. This resource simplifies payment management, ensuring efficient handling of transactions for businesses.

## `GET` Get payment

Get the payment details

### Endpoint

<mark style="color:green;">`GET`</mark> `/payment/{payment_id}`

### **Headers**

| Name         | Value               |
| ------------ | ------------------- |
| Content-Type | `application/json`  |
| X-API-KEY    | `your_api_key_here` |

### **Response**

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

```json
{
  "success": true,
  "data": {
    "payment_id": "6b577835afbefe60335b6e5cd04410a9",
    "foreign_id": "123456",
    "processed_at": 1726248785,
    "status": "PAID"
  }
}
```

{% endtab %}

{% tab title="400 Bad Request" %}

```json
{
  "success": false,
  "error": "Error message"
}
```

{% endtab %}

{% tab title="401 Unauthorized" %}

<pre class="language-json"><code class="lang-json">{
<strong>  "success": false,
</strong>  "error": "Wrong auth parameters"
}
</code></pre>

{% endtab %}
{% endtabs %}

## `POST` Create a new payment <a href="#create" id="create"></a>

Create a payment for the customer for a specified amount

### Endpoint

<mark style="color:green;">`POST`</mark> `/payment/create`

### **Headers**

| Name         | Value               |
| ------------ | ------------------- |
| Content-Type | `application/json`  |
| X-API-KEY    | `your_api_key_here` |

### **Body**

<table><thead><tr><th width="244">Name</th><th width="115">Type</th><th width="114">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>amount_fiat</code></td><td>string</td><td>Yes</td><td>Amount for payment</td></tr><tr><td><code>currency_fiat</code></td><td>string</td><td>Yes</td><td><p>Fiat currency ticker </p><p>(<a href="../../get-started/fiat-currencies">List of supported currencies</a>)</p></td></tr><tr><td><code>foreign_id</code></td><td>string</td><td>No</td><td>Additional field (internal id, for example)</td></tr><tr><td><code>url_success</code></td><td>string</td><td>No</td><td>URL where to redirect the customer after a successful payment </td></tr><tr><td><code>url_failed</code></td><td>string</td><td>No</td><td>URL where to redirect the customer after a failed payment</td></tr></tbody></table>

### **Response**

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

```json
{
  "success": true,
  "data": {
    "payment_id": "6b577835afbefe60335b6e5cd04410a9",
    "payment_url": "https://pay.ivpay.io/payment/6b577835afbefe60335b6e5cd04410a9",
    "created_at": 1726248776,
    "foreign_id": "123456",
  }
}
```

{% endtab %}

{% tab title="400 Bad Request" %}

<pre class="language-json"><code class="lang-json">{
<strong>  "success": false,
</strong>  "error": "Error message"
}
</code></pre>

{% endtab %}

{% tab title="401 Unauthorized" %}

```json
{
  "success": false,
  "error": "Wrong auth parameters"
}
```

{% endtab %}
{% endtabs %}

## Statuses

The possible payment statuses are explained [here](https://docs.ivpay.io/start/get-started/concepts#the-payment-statuses).
