API Documentation

Configuration

HTTP Method POST
API URL https://pay.tokomini.net/api/v1
API Key (check here)
Response Format JSON

Get Balance

Parameter Value
access_key Your API Key
action balance
Example Responses :
							
{
    "status": true,
    "action": "balance",
    "message": "IDR 3.809.488",
    "balance": "3809488"
}
						

Webhook or Callback URL

Webhook or also called as Callback URL is a feature to get updates of transaction status in realtime. With webhook, you don't need to run API requests (viewTrx) on cronjob/crontab for get transactions status.

That means your script or query will only be run when there is a transaction status update sent from us (API server), this will save your resource.

You have 3 ways to get transaction status updates:
First, use API Request: vieTrx()
Second, use Webhook or Callback URL
Third, use a combination of both. For example you provide a webhook, but for backup you also run API Request every 1 hour.
You are free to choose which is more suitable for your application.

How to make and configure Webhook or Callback URL?
That's easy, you only need to create a page to listen to the HTTP POST Requests. Because we will send 3 POST parameters, each time there is a change in your transaction status. And then, you can process it to run a data update query on your database. These are the 3 POST parameter details:
Parameter Description
trx_id id transaction that has updates.
trx_status the newest status for the transaction (SUCCESS or FAILED).
trx_note is a serial number of successful transaction or a note for failed transaction.

Don't forget to register your Callback URL on API Setting page. Feel free to contact us if you need further assistance


PHP Example Scripts

How to Get Your Public IP to set as Remote IP on API Setting

<?php
$api_url = "https://pay.tokomini.net/api/v1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
curl_close($ch);

$response = json_decode($result);
print_r($response);


/*
Run this script, and return data will be like it (ip_address is your remote ip):
stdClass Object ( [status] => [message] => Access Forbidden [ip_address] => 182.1.113.35 )
*/
?>
							

Get Account Balance

<?php
$api_key = ""; // Change with Your API Key
$api_url = "https://pay.tokomini.net/api/v1";
$param = array(
  'access_key'	=> $api_key,
  'action'	=> 'balance'
);

$_data = [];
foreach ($param as $name => $value)
{
  $_data[] = $name.'='.urlencode($value);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_data));
$result = curl_exec($ch);
curl_close($ch);

$response = json_decode($result);
echo $response->balance;
?>								
							

Get List of All Product

<?php
$api_key = ""; // Change with Your API Key
$api_url = "https://pay.tokomini.net/api/pricelist";


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result);

echo "<ul>";
foreach($response->data as $list)
{
	echo '
		<li>['.$list->product_code.'] '.$list->product_name.
		' have price '.$list->product_price.
		' is '.$list->product_status.'.</li>
	';
}
echo '</ul>';


/*
Example Result:
[A10] Axis 10rb have price 10810 is ready.
[A100] Axis 100rb have price 98225 is error.
[A15] Axis 15rb have price 14885 is ready.
dst..
 */

?>								
							

Add New Order

<?php
$api_key = ""; // Change with Your API Key
$api_url = "https://pay.tokomini.net/api/v1";
$param = array( 
  'access_key'	=> $api_key, 
  'action'	=> 'order',
  'trx_code'	=> 'S1', // Examples trx_code, you can change it
  'phone_number'=> '085222222222', // Examples destination phone number, you must change it
  'customer_id'	=> '0' // Examples trx_code is "0" because not needed, you can change it if order PLN Token, Topup Game or others.
);

$_data = [];
foreach ($param as $name => $value)
{
  $_data[] = $name.'='.urlencode($value);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_data));
$result = curl_exec($ch);
curl_close($ch);

$response = json_decode($result);
if($response->status === TRUE)
{
	echo "New transaction added with id trasaction ".$response->idtrx;
}else
{
	echo "Order failed, error: ".$response->message;
}
?>