Current Price: 109,568,000 IDR/BTC
BitBayar.com service will be terminated on 1 November 2017. If you hold IDR or BTC balance in your account, we encourage you to withdraw the balance before 31 October 2017. If you have any question, please contact us by email to [email protected]

Overview

Before integration please visit Available Plugins to check if there is a plugin that is suitable for your ecommerce software.

 

BitBayar payment API is the easiest way to accept Bitcoin without the need to host your Bitcoin wallet and sell the Bitcoin into Rupiah manually. Below you will find the explaination of each API method and the example of request call in shell command and PHP.

 

To get the API Token Key, please visit Setting & API.

 

Method: create_invoice

To accept a payment, first you need to create an invoice with this method.

 

URL: https://bitbayar.com/api/create_invoice

 

Variable (POST)

token: Your API token key

invoice_id: Invoice ID from your end (alpha-numeric)

rupiah: The amount of invoice in Rupiah (min 1,000, max 10,000,000)

memo: Internal invoice memo (max length 255 characters)

callback_url: URL to receive notification when invoice is paid

url_success: Customer will be sent to this URL if payment is success

url_failed: Customer will be sent to this URL if payment is canceled

 

Example (Shell):

curl --data "token=GD1FA2CC2A3357FDF45B84744FFF7102&invoice_id=123&rupiah=150000&memo=Invoice%20%23123%20Jose%20Alejandro&callback_url=http%3A%2F%2Fwww.mywebsite.com%2Fbitbayar_callback.php&url_success=http%3A%2F%2Fwww.mywebsite.com%2Fbitbayar_payment_success.php&url_failed=http%3A%2F%2Fwww.mywebsite.com%2Fbitbayar_payment_failed.php" https://bitbayar.com/api/create_invoice

 

Example (PHP):

$data = array(
	'token'=>'GD1FA2CC2A3357FDF45B84744FFF7102',
	'invoice_id'=>'123',
	'rupiah'=>150000,
	'memo'=>'Invoice #123 Jose Alejandro',
	'callback_url'=>'http://www.mywebsite.com/bitbayar_callback.php',
	'url_success'=>'http://www.mywebsite.com/bitbayar_payment_success.php',
	'url_failed'=>'http://www.mywebsite.com/bitbayar_payment_failed.php'
);
$url = 'https://bitbayar.com/api/create_invoice';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$return = curl_exec($ch);
curl_close($ch);
$data = json_decode($return);
if($data->success){
	header('Location: '.$data->payment_url);
	exit;
}
else{
	exit('BitBayar API Error: '.$data->error_message);
}

 

Return

This will return the Bitcoin address and the amount of Bitcoin customer needs to pay. Data is in JSON format.

{
	"success":1,
	"id":"54f5527d194a6672965313",
	"payment_address":"16CSUNyV7e7YjpEB5sSAhNnXycDmGyhEMo",
	"payment_url":"https:\/\/bitbayar.com\/payment\/54f5527d194a6672965313"
	"amount_rp":"150000",
	"amount_btc":"0.0452",
	"created_time":1425363581,
	"expired_time":1425364481,
	"invoice_id":"123",
	"memo":"Invoice #123 Jose Alejandro",
	"callback_url":"http:\/\/www.mywebsite.com\/bitbayar_callback.php",
	"url_success":"http:\/\/www.mywebsite.com\/bitbayar_payment_success.php",
	"url_failed":"http:\/\/www.mywebsite.com\/bitbayar_payment_failed.php"
}

After calling this method, redirect your customer to "payment_url".

 

Callback

When 0.0452 BTC sent to 16CSU before expired_time, the callback_url will be invoked with a POST request.

Array (
	[id] => 54f5527d194a6672965313
	[invoice_id] => 123
	[memo] => Invoice #123 Jose Alejandro
	[btc] => 0.0452
	[rp] => 150000
	[auto_sell] => 1
	[payment_id] => 7214
	[payment_time] => 1425360875
	[txid] => 74830fdb62639d9e40828a7d3b0242cacafc5bcdd6f45ca85ec4d53cf12cae57
)

 

Success or Failed URL

When payment is paid, customer will be sent to url_success. When payment is cancelled, customer will be sent to url_failed. We will add 3 GET variables to the end of return URLs: invoice_id (your previously set invoice_id), uid (invoice id from BitBayar, and status ('paid' if payment is success, or 'cancel' if payment is cancelled)

 

Example of return URL if payment is paid:

http://websiteku.com/success?status=paid&invoice_id=123&uid=54f5527d194a6672965313

 

Example of return URL if payment is cancelled:

http://websiteku.com/failed?status=cancel&invoice_id=123&uid=54f5527d194a6672965313

 


 

Method: check_invoice

Call this method to get the status of an invoice and other information. You can also use this API method to prevent callback injection by checking check_invoice on your callback_url function before processing the order.

 

URL: https://bitbayar.com/api/check_invoice

 

Variable (POST)

token: Your API token key

id: Invoice ID generated from previous create_invoice request

 

Example (Shell):

curl --data "token=GD1FA2CC2A3357FDF45B84744FFF7102&id=54f5527d194a6672965313" https://bitbayar.com/api/check_invoice

 

Example (PHP):

$data = array(
	'token'=>'GD1FA2CC2A3357FDF45B84744FFF7102',
	'id'=>'54f5527d194a6672965313'
);
$url = 'https://bitbayar.com/api/check_invoice';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$return = curl_exec($ch);
curl_close($ch);
echo $return;

 

Return

This will return the status of invoice and payment info.

{
	"success":1,
	"id":"54f5527d194a6672965313",
	"status":"paid",
	"txid":"74830fdb62639d9e40828a7d3b0242cacafc5bcdd6f45ca85ec4d53cf12cae57",
	"payment_time":"1425360875",
	"payment_id":"7214",
	"payment_address":"16CSUNyV7e7YjpEB5sSAhNnXycDmGyhEMo",
	"amount_rp":"150000",
	"amount_btc":"0.0452",
	"created_time":"1425363581",
	"expired_time":"1425364481",
	"invoice_id":"123",
	"memo":"Invoice #123 Jose Alejandro",
	"callback_url":"http:\/\/www.mywebsite.com\/bitbayar_callback.php"
}

 


 

Method: list_invoices

Shows 50 recent invoices.

 

URL: https://bitbayar.com/api/list_invoices

 

Variable (POST)

token: Your API token key

start: use start to paginate the result

 

Example (Shell):

curl --data "token=GD1FA2CC2A3357FDF45B84744FFF7102&start=0" https://bitbayar.com/api/list_invoices

 

Example (PHP):

$data = array(
	'token'=>'GD1FA2CC2A3357FDF45B84744FFF7102',
	'start'=>0
);
$url = 'https://bitbayar.com/api/list_invoices';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$return = curl_exec($ch);
curl_close($ch);
echo $return;

 

Return

This method returns 50 recent invoices (unless "start" specified).

{
  "success": 1,
  "total_invoices": "2",
  "start": 0,
  "limit": 50,
  "invoices": [
    {
      "id": "553e1802d99c3687037123",
      "status": "expired",
      "payment_address": "1Nvv2XmKxZWThvMQf1iPNiM12xE5kSeD4A",
      "amount_rp": "10000",
      "amount_btc": "0.0035",
      "created_time": "1430132738",
      "expired_time": "1430133638",
      "invoice_id": "a123",
      "memo": "Order 2",
      "callback_url": ""
    },
    {
      "id": "553e12e3f18dc076668456",
      "status": "expired",
      "payment_address": "1DAEkCTqUs74jvqW2oQ7vfC8cvLBiAjbW1",
      "amount_rp": "100000",
      "amount_btc": "0.0344",
      "created_time": "1430131427",
      "expired_time": "1430132327",
      "invoice_id": "a124",
      "memo": "Order 1",
      "callback_url": ""
    }
  ]
}

 


 

Method: balances

Shows BTC dan IDR balances.

 

URL: https://bitbayar.com/api/balances

 

Variable (POST)

token: Your API token key

 

Example (Shell):

curl --data "token=GD1FA2CC2A3357FDF45B84744FFF7102" https://bitbayar.com/api/balances

 

Example (PHP):

$data = array(
	'token'=>'GD1FA2CC2A3357FDF45B84744FFF7102'
);
$url = 'https://bitbayar.com/api/balances';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$return = curl_exec($ch);
curl_close($ch);
echo $return;

 

Return

This method returns BTC dan IDR balances.

{
  "success": 1,
  "balances": {
    "idr": "250000",
    "btc": "0.01500000"
  }
}