# Status

{% hint style="info" %}
**Good to know:** Before you begin, make sure you have obtained the login and password from the administrator. These credentials are required to authenticate and successfully execute the API requests.
{% endhint %}

#### [Code samples](#code-samples-1)

## Get payment status

**After making a payment, you must request the status of the status of this payment every 10 seconds, until you receive a Reject or Charge.**

To retrieve the payment status based on the order number, you need to call the endpoint `https://{url}.finipay.kg/api/v1.1.0/status`.

```json5
{
    "orderNumber":"89832199",
    "language":"en"
}
```

## Returns status of transaction

<mark style="color:blue;">`GET`</mark> `https://{url}.finipay.kg/api/v1.1.0/status`

#### Request Body

| Name                                          | Type   | Description                                                                                                                                                                                                                                 |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| orderNumber<mark style="color:red;">\*</mark> | string | Order number generated by EPG after the registration of the order (the same as the token parameter).                                                                                                                                        |
| language                                      | string | Language code in the ISO 639-1 format. If unspecified, SmartVista E-commerce Payment Gateway uses the default language from the settings of the user used to process the merchant's payments. Error messages are returned in this language. |

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

```json5
{
    "code": "200",
    "message": "PAYMENT_SUCCESS",
    "data": {
        "orderNumber": "Fp00000116261320",
        "amount": 500.00,
        "status": "CHARGE",
        "currency": "EUR"
    }
}
```

{% endtab %}

{% tab title="203 Amount is blocked" %}

```json5
{
    "code": "203",
    "message": "AMOUNT_IS_BLOCKED",
    "data": {
        "orderNumber": "Fp00000116261320",
        "amount": 500.00,
        "status": "AUTH",
        "currency": "EUR"
    }
}
```

{% endtab %}

{% tab title="202: Payment reject" %}

```json
{
    "code": "202",
    "message": "PAYMENT_REJECT",
    "data": {
        "orderNumber": "Fp00000116261320",
        "amount": 500.00,
        "status": "REJECT",
        "currency": "EUR"
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error" %}

```json5
{
    "timestamp": 1686344770202,
    "status": 500,
    "error": "Internal Server Error",
    "path": "/api/status"
}
```

{% endtab %}

{% tab title="404: Not Found" %}

```json5
{
    "code": "404",
    "message": "PAYMENT_NOT_FOUND",
    "data": null
}
```

{% endtab %}
{% endtabs %}

#### Code samples

Here are the code snippets for making a POST request to the specified endpoint using different programming languages.\
\
Please make sure to replace `'your_username'` and `'your_password'` with your actual credentials.

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

```php
<?php

$endpoint = 'https://{url}.finipay.kg/api/payment';
$username = 'your_username';
$password = 'your_password';

$data = [
    'orderId' => '8983219622',
    'language' => 'en'
];

$options = [
    'http' => [
        'header' => "Content-type: application/json\r\n",
        'method' => 'POST',
        'content' => json_encode($data),
        'header' => "Authorization: Basic " . base64_encode($username . ":" . $password) . "\r\n"
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($endpoint, false, $context);

if ($response === false) {
    echo 'Error occurred while making the request.';
} else {
    echo $response;
}

?>

```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string endpoint = "https://{url}.finipay.kg/api/payment";
        string username = "your_username";
        string password = "your_password";

        var data = new
        {
            orderId = "8983219622",
            language = "en"
        };

        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")));
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await httpClient.PostAsync(endpoint, content);
            var responseContent = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseContent);
        }
    }
}

```

{% endtab %}

{% tab title="Axios(node.js)" %}

```javascript
const axios = require('axios');

const endpoint = 'https://{url}.finipay.kg/api/payment';
const username = 'your_username';
const password = 'your_password';

const data = {
    orderId: '8983219622',
    language: 'en'
};

axios.post(endpoint, data, {
    auth: {
        username: username,
        password: password
    },
    headers: {
        'Content-Type': 'application/json'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.log(error);
});

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class StatusEndpointExample {
    public static void main(String[] args) throws IOException {
        String endpoint = "https://{url}.finipay.kg/api/status";
        String username = "your_username";
        String password = "your_password";

        String requestBody = "{\n" +
                "    \"orderId\":\"8983219622\",\n" +
                "    \"language\":\"en\"\n" +
                "}";

        URL url = new URL(endpoint);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);

        String auth = username + ":" + password;
        String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes(StandardCharsets.UTF_8));
        conn.setRequestProperty("Authorization", "Basic " + encodedAuth);
        conn.setRequestProperty("Content-Type", "application/json");

        conn.getOutputStream().write(requestBody.getBytes(StandardCharsets.UTF_8));

        int responseCode = conn.getResponseCode();

        if (responseCode == HttpURLConnection.HTTP_OK) {
            // Request succeeded, handle the response
            // ...
        } else {
            // Request failed
            // ...
        }

        conn.disconnect();
    }
}

```

{% endtab %}
{% endtabs %}
