Dokumentasi API H2H

Buat Software Pulsa Kamu Sendiri dengan API dari Larakost Pulsa

API H2H Dokumentasi

API (Application Programming Interface) adalah sekumpulan perintah, fungsi, dan protokol yang dapat digunakan oleh programmer saat membangun software, sehingga tercipta interkoneksi yang stabil dan cepat antar sistem.


API Server Pulsa H2H merupakan jalur yang dapat digunakan mitra server pulsa h2h untuk bertransaksi pulsa murah dengan cepat dan stabil. Dapat digunakan untuk cek saldo terakhir, cek harga produk pulsa termurah, cek update status transaksi, isi pulsa murah all operator, isi token pln prabayar, bayar tagihan, dll.


Metode transaksi pulsa via API ini memerlukan sedikit pengetahuan tentang pemrograman komputer. Jika Anda tidak paham tentang bahasa pemrograman sebaiknya tidak menggunakan metode transaksi pulsa ini.

Syarat dan ketentuan menggunakan API

  1. Mempunyai IP Statis agar keamanan transaksi Anda terjamin.
  2. Menyediakan Callback Url / Link Reversal untuk menerima update status transaksi.
  3. Masukkan IP Statis dan Callback Url / Link Reversal di member area menu 'Profile - Developer API'
  4. Setelah itu sistem akan otomatis men-generate API KEY. Sebagai parameter utama saat transaksi, juga berfungsi untuk pengamanan tambahan transaksi.
  5. Response yang muncul dan yang dikirim berupa DATA JSON. Sehingga sistem Anda harus sudah mendukung JSON.

Sedikit pengetahuan: IP Statis adalah IP server Anda yang tidak berubah-ubah, Jika server Adalah sebuah website maka IP Statis adalah IP Website Anda tersebut. Sedangkan callback url adalah alamat url yang harus Anda sediakan di server/website Anda yang berguna untuk menerima update status transaksi dari kami, Script / Isi dari callback sudah kami beri contohnya dihalaman ini.

Contoh Script API Untuk Pemrograman PHP dan Response yang Muncul

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/balance';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"balance": "150000",
"message": "Jumlah Saldo Anda adalah Rp 150.000"
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembelian/categorie';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"product_id": "pulsa",
"product_name": "Pulsa All Operator",
"status": "1" // 1 = Tersedia, 0 = Tidak Tersedia
},
{
"product_id": "plnpra",
"product_name": "Token PLN",
"status": "1"
},
{
"product_id": "paket",
"product_name": "Paket Internet",
"status": "1"
},
{
"product_id": "game",
"product_name": "Voucher Game",
"status": "0"
},
{
"product_id": "gojek",
"product_name": "Saldo GOJEK",
"status": "1"
},
{
"product_id": "grab",
"product_name": "Saldo GRAB",
"status": "0"
}
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembelian/operator';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'product_id' => 'pulsa', // Kode Kategori (pulsa, plnpra, paket, dll)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"product_id": "TSEL",
"product_name": "TELKOMSEL",
"prefix": "0811,0812,0813,0821,0822,0823,0852,0853,0851",
"status": "1" // 1 = Tersedia, 0 = Tidak Tersedia
},
{
"product_id": "ISAT",
"product_name": "INDOSAT",
"prefix": "0856,0857,0858,0815,0816,0855",
"status": "1"
},
{
"product_id": "AXIS",
"product_name": "AXIS",
"prefix": "0831,0832,0838",
"status": "1"
},
{
"product_id": "XL",
"product_name": "XL",
"prefix": "0817,0818,0819,0859,0877,0878",
"status": "1"
},
{
"product_id": "SMART",
"product_name": "SMARTFREN",
"prefix": "0881,0882,0883,0884,0885,0886,0887,0888,0889",
"status": "1"
},
{
"product_id": "THREE",
"product_name": "THREE",
"prefix": "0896,0897,0898,0899,0895",
"status": "1"
},
{
"product_id": "BOLT",
"product_name": "BOLT",
"prefix": "999",
"status": "1"
}
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembelian/product';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'product_id' => 'TSEL', // Kode Operator (TSEL, ISAT, AXIS, dll)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"product_id": "PLP20",
"product_name": "TOKEN PLN 20.000 (Promo)",
"ket": "",
"price": "19840", // Harga Produk Agent Biasa, Jika Status keagenan anda adalah member/agent biasa maka field yang muncul adalah "price"
"h2h_price": "19720", // Harga Produk MITRA, , Jika Status keagenan anda adalah MITRA maka field yang muncul adalah "h2h_price"
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
},
{
"product_id": "PLP50",
"product_name": "TOKEN PLN 50.000 (Promo)",
"ket": "",
"price": "49840",
"h2h_price": "49720",
"status": "1"
},
{
"product_id": "PLP100",
"product_name": "TOKEN PLN 100.000 (Promo)",
"ket": "",
"price": "99840",
"h2h_price": "99720",
"status": "1"
},
{
"product_id": "PLP200",
"product_name": "TOKEN PLN 200.000 (Promo)",
"ket": "",
"price": "199840",
"h2h_price": "199720",
"status": "1"
},
{
"product_id": "PLP500",
"product_name": "TOKEN PLN 500.000 (Promo)",
"ket": "",
"price": "499840",
"h2h_price": "499720",
"status": "1"
},
{
"product_id": "PLP1000",
"product_name": "TOKEN PLN 1.000.000 (Promo)",
"ket": "",
"price": "999840",
"h2h_price": "999720",
"status": "1"
}
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembayaran/categorie';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"product_id": "PLN",
"product_name": "Tagihan PLN",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "PDAM",
"product_name": "PDAM",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "BPJS",
"product_name": "Asuransi (BPJS)",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "MULTIFINANCE",
"product_name": "Multifinance",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "TELKOM",
"product_name": "Tagihan Telkom",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "TELEPON",
"product_name": "Tagihan Telepon",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "TV",
"product_name": "TV Berbayar",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "PGN",
"product_name": "Gas Negara (PGN)",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembayaran/product';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'product_id' => 'PLN', // Kode Kategori (PLN, BPJS, TELKOM, dll)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"product_id": "PLN",
"product_name": "PLN",
"fee": "1900",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
},
{
"product_id": "PLNNONTAGLIST",
"product_name": "PLN NON TAGLIST",
"fee": "1900",
"status": "1" // 1 = Produk Tersedia, 0 = Produk Gangguan
"updated_at": "2018-06-09 19:29:53",
}
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembelian/transaction';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'code' => 'PLN20', // Kode Produk
'target' => '14534234234', // Nomor Handphone / ID Pelanggan
'api_idtrx' => 'xxxx', // Trxid / Reffid dari sisi client
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"message": "Transaksi anda berhasil di proses, mohon kesabarannya menunggu."
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/transaksi/history';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": [
{
"id": 2554, // ID Transaksi
"code": "IDPH2",
"produk": "Unlimited + 2GB - Promo (Ratu)",
"total": "29450",
"target": "0857966*****",
"mtrpln": "-",
"note": "Trx Unlimited + 2GB - Promo (Ratu) 0857966***** Sukses. Transaksi Berhasil SN : 011728000047918*****",
"token": "011728000047918*****",
"status": "1", // 0 = Proses, 1 = Sukses, 2 = Gagal, 3 = Refund
"saldo_before_trx": "461381",
"saldo_after_trx": "431781",
"created_at": "2018-03-18 21:18:09",
"updated_at": "2018-03-18 21:18:32"
},
{
"id": 2549,
"code": "HSB25",
"produk": "TELKOMSEL 25.000",
"total": "24675",
"target": "0813567*****",
"mtrpln": "-",
"note": "Trx TELKOMSEL 25.000 0813567***** Sukses. Transaksi Berhasil SN : 80318205728015*****",
"token": "80318205728015*****",
"status": "1",
"saldo_before_trx": "486206",
"saldo_after_trx": "461381",
"created_at": "2018-03-18 20:57:11",
"updated_at": "2018-03-18 20:57:56"
}
]
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/transaksi/history/detail';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'trxid' => '2554', // Masukkan Transaksi ID
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"data": {
"id": 2554,
"code": "IDPH2",
"produk": "Unlimited + 2GB - Promo (Ratu)",
"total": "29450",
"target": "0857966*****",
"mtrpln": "-",
"note": "Trx Unlimited + 2GB - Promo (Ratu) 0857966***** Sukses. Transaksi Berhasil SN : 011728000047918*****",
"token": "011728000047918*****",
"status": "1", // 0 = Proses, 1 = Sukses, 2 = Gagal, 3 = Refund
"saldo_before_trx": "461381",
"saldo_after_trx": "431781",
"created_at": "2018-03-18 21:18:09",
"updated_at": "2018-03-18 21:18:32"
}
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembayaran/cektagihan';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'produk' => 'PLN', // Kode Produk (PLN, BPJSKS, TELKOM, SPEEDY)
'nomor_rekening' => '535111153609', // Nomor Pelanggan yang akan di bayarkan (No Meter Dll)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"fee": 2100,
"jml_bayar": 30512,
"data": {
"tagihan_id": "123",
"code": "PLN",
"no_pelanggan": "32165498763541",
"jumlah_tagihan": "30112",
"admin": "2500",
"jumlah_bayar": "32612",
"nama": "LARAKOST GROUP",
"periode": "201806",
"detail": "PLN | Nama : | LARAKOST GROUP | Id Pelanggan : | 32165498763541 | Tagihan Rp : | 30112 | ADM Rp : | 2500 | Total : | 32612 | Nomor Invoice : | INV180616088107 | Tarif/Daya : | R1/000000450 VA | BL/TH : | 201806 | Stand Meter : | 00001221-00001298 | Rp Subsidi : | 0 | Total Lembar Tagihan : 1 Bulan | 201806#30112#2500 | | "
}
}

Contoh Script PHP :

<?php
$url = 'https://larakostpulsa.com/api/pembayaran/bayartagihan';

$header = array(
'Accept: application/json',
'Authorization: Bearer [apikey]', // Ganti [apikey] dengan API KEY Anda
);

$data = array(
'tagihan_id' => '123', // ID Tagihan
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

echo $result;

Contoh Response Sukses :

{
"status": "success",
"tagihan_id": "123",
"reff": "97F23B7901652C96",
"message": "Pembayaran Tagihan Anda Telah Berhasil dengan No. Referensi : 97F23B7901652C96"
}

Contoh Script CallBack Url Transaksi & Produk

Contoh alamat callback url seperti ini: http://domainAnda.tld/script.php . Nama file atau alamat callback terserah Anda. Berikut contoh script untuk menerima update transaksi dari Larakost Pulsa

Contoh Script PHP Untuk CallBack Url :

"Callback ini untuk menerima update Transaksi secara realtime"

<?php

/* Script ini hanya membantu menyimpan dalam file saja
* Hasil yg tersimpan silakan dianalisa agar dapat diproses oleh sistem Anda.
*/


if($_SERVER['REMOTE_ADDR']=='103.215.72.227'){ // memastikan data terikirim dari server Larakost Pulsa

file_put_contents('save.txt', $_GET['content']); // menyimpan dalam file save.txt

}

Contoh Respon / Isi / Content yang dikirim: :

{
"id":2885,
"code":"HSB1",
"produk":"TELKOMSEL 1.000",
"total":"1395",
"target":"08122772388",
"mtrpln":"-",
"note":"Transaksi GAGAL, Produk Sedang Gangguan",
"token":"-",
"status":"2",
"saldo_before_trx":"29594",
"saldo_after_trx":"29594",
"created_at":"2018-03-27 10:30:20",
"updated_at":"2018-03-27 10:30:24"
}

Contoh Script PHP Untuk CallBack Url :

"Callback ini untuk menerima update Produk (Nama, Harga & Status) secara realtime"

<?php

/* Script ini hanya membantu menyimpan dalam file saja
* Hasil yg tersimpan silakan dianalisa agar dapat diproses oleh sistem Anda.
*/


if($_SERVER['REMOTE_ADDR']=='103.215.72.227'){ // memastikan data terikirim dari server Larakost Pulsa

file_put_contents('save.txt', $_GET['content']); // menyimpan dalam file save.txt

}

Contoh Respon / Isi / Content yang dikirim: :

{
"type":"PRABAYAR",
"product_id":"SBP10",
"product_name":"TELKOMSEL 10.000 PROMO",
"price":"10095",
"keterangan":"Masa Aktif 15 Hari",
"status":"1",
"updated_at":"2018-11-24 08:59:21"
}