# Transaksi Baru

{% hint style="info" %}
Request nominal dibawah 20.000 dikenakan biaya tambahan sebesar 3%&#x20;

Contoh: jika rate 0.82 maka akan menjadi 0.79
{% endhint %}

<mark style="color:green;">`POST`</mark> `https://api.ilenpay.co.id/v1/transaksi/baru`

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | String | Api Key     |

#### Request Body

| Name                                          | Type   | Description                            |
| --------------------------------------------- | ------ | -------------------------------------- |
| operator<mark style="color:red;">\*</mark>    | String | ( telkomsel, xl, tri, smartfren )      |
| nominal<mark style="color:red;">\*</mark>     | Int    | Nominal pembayaran                     |
| reff\_id<mark style="color:red;">\*</mark>    | String | Kode unik anda. Min 5 Max 20 karakter  |
| sign<mark style="color:red;">\*</mark>        | String | format md5()                           |
| type<mark style="color:red;">\*</mark>        | String | *( redirect / direct )*                |
| return\_url<mark style="color:red;">\*</mark> | String | URL mengalihkan pelanggan Anda kembali |

{% tabs %}
{% tab title="200: OK Respon sukses type Redirect" %}

<pre class="language-json"><code class="lang-json">{
    "data": {
        "respon": "sukses",
        "payment": "telkomsel",
        "rate": "0.82",
        "nominal": "10000",
        "reff_id": "trx68164teewfske2",
        "total_tf": "13000",
        "waktu": 1698753382,
<strong>        "type": "redirect",
</strong><strong>        "hash": "93fc85a4a2ba084f5f4850ee9ae8713d34949712",
</strong><strong>        "url_pay": "https://ilenpay.co.id/payment/93fc85a4a2ba084f5f4850ee9ae8713d34949712",
</strong>        "status": "UNPAID"
    }
}
</code></pre>

{% endtab %}

{% tab title="200: OK Respon sukses type Direct" %}

<pre class="language-json"><code class="lang-json">{
    "data": {
        "respon": "sukses",
        "payment": "telkomsel",
        "rate": "0.82",
        "nominal": "10000",
        "reff_id": "trx68164teewfske2",
        "total_tf": "13000",
        "waktu": 1698753308,
<strong>        "type": "direct",
</strong><strong>        "hash": "fd7e16c7b8c631c53685b699c6b4a5eabee285d9",
</strong><strong>        "no_center": "081286191966",
</strong>        "status": "UNPAID"
    }
}
</code></pre>

{% endtab %}
{% endtabs %}

### Contoh Untuk PHP&#x20;

<pre class="language-php"><code class="lang-php">&#x3C;?php

$api_key    = 'Production Key';
$api_user   = 'User Key';
<strong>$type       = 'direct'; // Type: direct / redirect
</strong><strong>$return_url = 'https://domain.com/riwayat/8833';
</strong>$operator   = 'telkomsel';
$nominal    = '15000';
$reff_id    = 'trx68164343fdgsfdg';
$sign       = md5($operator.'+'.$nominal.'+'.$reff_id.'+'.$api_user);

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_FRESH_CONNECT  => true,
    CURLOPT_URL            => 'https://api.ilenpay.co.id/v1/transaksi/baru',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER         => false,
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_POSTFIELDS     => http_build_query(array(
<strong>        'type'      => $type,
</strong><strong>        'return_url'=> $return_url,
</strong>        'operator'  => $operator,
        'nominal'   => $nominal,
        'reff_id'   => $reff_id,
        'sign'      => $sign
    )),

    CURLOPT_HTTPHEADER     => array(
        'Content-Type: application/x-www-form-urlencoded',
        'Authorization: ' . $api_key
    ),
    CURLOPT_FAILONERROR    => false,
    CURLOPT_IPRESOLVE      => CURL_IPRESOLVE_V4
]);

$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
print_r(empty($error) ? $response : $error);
</code></pre>
