Documentation

If you need further help please contact us

store
Create Transaction
On each transaction to use the IPN you need to create transactions via API and set the IPN URL & Invoice ID.

PHP Example ( Generate Payment Address ) Code:
<?php

function sendPostData($url, $post){
  $ch = curl_init($url);
  curl_setopt($ch,CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;
}

$data = [
  "endpoint" => "generate_address",
  "api_k" => "YOURAPIKEY",
  "currency" => "BTC",
  "ipn_url" => "http://www.yourwebsite.com/ipn.php",
  "invoice_id" => 341
];

$url_send = "https://www.bitcrate.io/api_merchant";
$str_data = $data;
$return = sendPostData($url_send, $str_data);

$r = json_decode($return);

echo $r->address;

?>


EndPointVariables
generate_addressRequired Sending Variables:
api_k - Your API KEY
currency - Required currency ( BTC, LTC )

Optional Sending Variables:
ipn_url - Your IPN URL
invoice_id - Your invoice id to identify the transaction


Sent variables (JSON FORMAT)

error - 1 or 0 ( 0 if no error occured), if an error occured and is returned 1 it will also return the message variable with an error text

address - will be returned if no error encountered
store
Instant Payment Notification
On each transaction to use the IPN you need to create transactions via API and set the IPN URL & Invoice ID.

PHP Example ( Verify IPN response ) Code:
<?php

$apikey = "YOURAPIKEY";
$secret = "YOURAPISECRETCODE";
$hash_formed = sha1($apikey.$secret);

$tid = intval($_POST['invoice_id']);
$amount = floatval($_POST['amount']);
$txid = $_POST['txid'];
$confirmation = intval($_POST['confirmations']);
$currency = $_POST['currency'];
$status = intval($_POST['status']);
$hash_received = $_POST['hash'];

if($hash_received == $hash_formed) {

  // Check the original currency to make sure the buyer didn't change it.
  if ($currency != "BTC") {
  errorAndDie('Not the right currency!');
  }

  // Check amount against order total
  if ($amount < "1.00000000") {
  errorAndDie('Amount is less than order total!');
  }

  if ($status == 1) {
  // this is your code for success transaction received
  echo"IPN OK"; // If ipn url return IPN OK it will validate your transaction and won't send more requests, only show this when transaction is final.
  }

}

?>


MethodVariables
POSTReceiving Variables:
invoice_id - Your INVOICE id when created payment address
amount - Amount Paid
txid - Transaction txid if not internal transaction
confirmations - Transaction confirmations

currency - Currency received ( BTC, LTC )status - status of the transaction ( 0: not received, 1: received )
hash - transaction hash sent when it was created