Hosted checkout

Using hosted checkout, you can redirect to your customers to CoinMkr.com or display the payment form inside of your website, then you can receive their payments with your selected cryptocurrencies.

To use this feature, you must have your xPub configured in Wallets page

The fields available are documented below.

Field Description
api_key Required Your account API Key
currency Required The currency of the payment (BTC, LTC, USD, EUR, etc.)
Check fiat currency or cryptocurrencies supported table.
amount Required The amount (in the currency chosen) of the payment.
store_name Required Name of your store/company that will appear in checkout page.
store_logo URL of your logo, it must be a secured url (HTTPS).
item_name Required The name of the item being purchased.
item_desc Description of the item being purchased.
item_number This is a passthru variable for your own use. [not visible to buyer]
custom This is a 2nd passthru variable for your own use. [not visible to buyer]
wallets Cryptocurrency codes of your wallets separated with a comma you will accept. This is used to further restrict the coin selection from your list of enabled coins; for example if you are doing your own exchange rates and want to limit checkout to a user selected currency. Example: BTC,LTC
ipn_url Sets an IPN URL (Webhook/Callback), it must be a secured url (HTTPS).
success_url Sets a URL to go to if the buyer does complete checkout, it must be a secured url (HTTPS).
cancel_url Sets a URL to go to if the buyer decides to not complete checkout, it must be a secured url (HTTPS).

PHP examples

This example shows how to create a payment link and redirect user to the payment form.

In this case, you need to configure the success_url and cancel_url to redirect users when a payment is completed or if user decides to cancel it.

<?php
//Your API Key
$api_key = 'Your API Key Here';

$data = [
	'currency' => 'USD',
	'amount' => 300.99,
	'store_name' => 'My First Store',
	'store_logo' => 'https://mysite.com/logo.png',
	'item_name' => 'Printer Epson',
	'item_desc' => 'Printer Epson EcoTank L5590',
	'item_number' => 1592,
	'custom' => 'XH32is',
	'wallets' => 'BTC,LTC,ETH',
	'ipn_url' => 'https://mysite.com/webhook',
	'success_url' => 'https://mysite.com/thank_you',
	'cancel_url' => 'https://mysite.com/store'
];
$ch = curl_init('https://coinmkr.com/api/v1/checkout');
$payload = json_encode( $data );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
	'Content-Type:application/json',
	'x-api-key: '.$api_key,
));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response);

if($result->status == 'error'){
	//Error
	die('Error was found: '.$result->message);
}else{
	//Success and redirect to payment form
	header('location: '.$result->url);
	exit;
}
?>

With this example your users can make a deposit within your web page. It allows users to make a transaction without leaving their current experience.

In this case, it's not necessary to configure the success_url and cancel_url because payment form is working inside of your website.

<?php
//Your API Key
$api_key = 'Your API Key Here';

$data = [
	'currency' => 'USD',
	'amount' => 300.99,
	'store_name' => 'My First Store',
	'store_logo' => 'https://mysite.com/logo.png',
	'item_name' => 'Printer Epson',
	'item_desc' => 'Printer Epson EcoTank L5590',
	'item_number' => 1592,
	'custom' => 'XH32is',
	'wallets' => 'BTC,LTC,ETH',
	'ipn_url' => 'https://mysite.com/webhook'
];
$ch = curl_init('https://coinmkr.com/api/v1/checkout');
$payload = json_encode( $data );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
	'Content-Type:application/json',
	'x-api-key: '.$api_key,
));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response);

if($result->status == 'error'){
	//Error
	echo 'Error was found: '.$result->message;
}else{
	//Embedded form
	?>
	<script src="<?php echo $result->script;?>"></script>
<?php
}
?>

A success message returns a json response:

{
    "status": "success",
    "id": "c0e48e4cae927s31343",
    "url": "https:\/\/coinmkr.com\/checkout\/c0e48e4cae927s31343",
    "script": "https:\/\/coinmkr.com\/checkout\/js\/c0e48e4cae927s31343"
}

Postback notification

Webhook is invoked when a transaction is added to a block or when it appears in the mempool (ETH and BSC).

The request body of the POST request is a JSON object with the following structure:

{
  "status": "completed",
  "payment": {
    "delivery": "on_time",
    "asset": "LTC",
    "blockchain": "LTC",
    "address": "ltc1q95wg2wz93ve0v8vcsfnsuthn37gy5azpsg5ygh",
    "amount": "0.00988995",
    "total_received": "0.00988995",
    "txID": "1b5f874ad29f7bc1c46bd099152de6606c2c066370af93b0e08750c28cb44dba"
  },
  "store": {
    "currency": "USD",
    "amount": 1,
    "item_name": "Printer Epson",
    "item_number": 1592,
    "custom": "XH32is"
  }
}

Data information:

  • status: if amount is equal or higher than required, then status will be completed otherwise it returns uncompleted. If it is uncompleted, then user needs to send more funds to complete this transaction.
  • payment:delivery: if system detects that deposit is completed before than 60 minutes, then it returns on_time, otherwise it returns delayed
  • payment:asset: cryptocurrency code of transaction.
  • payment:blockchain: the blockchain where this transactions is done.
  • payment:address: your deposit address.
  • payment:amount: amount received in this notification.
  • payment:total_received: the total amount received, if user made twice deposits, then this is the sum of amounts of those two transactions.
  • payment:txID: the transaction id (TXID) of this transaction in the blockchain.
  • store:currency: The currency you sent for your product or service.
  • store:amount: The amount (in the currency chosen) of the payment.
  • store:item_name: The name of the item being purchased.
  • store:item_number: This is a passthru variable for your own use.
  • store:custom: This is a passthru variable for your own use.
We use your API Key as the HMAC shared secret key to generate an HMAC signature of the raw JSON data. The HMAC signature is sent as a HTTP header called COINMKR_SIGNATURE.
<?php

$api_key = "Your_API_Key";

$raw_post_data = file_get_contents('php://input');

$signature = hash_hmac("sha256", $raw_post_data, $api_key);

if($signature != $_SERVER['HTTP_COINMKR_SIGNATURE']){
	die('Invalid signature');
}

$payment_data = json_decode($raw_post_data);
                
            

Credit consumption

You will consume credits only for API calls, in case of Hosted Checkout, there are some required calls:

  1. 3 credits per address generated from each chain.
  2. 30 credits per webhook subscription from each chain.
  3. (*) 10 credits per webhook notification each chain.
  4. 2 credits per webhook unsubscription from each chain.

(*) You will be notified only if you receive a payment within the 12 hours, after that period credits for webhook notification will not be debited.

An unsuccessful transaction will consume 35 credits per wallet

A successful transaction will consume 35 credits per wallet + 10 credits per notification