Initialise Widget With Webhook

The webhook (postback) can be used to have data sent straight to your server about widget transaction completes. By entering variables relevant to your project in the customFields you can track completed purchases and know which user completed, for which currency and how much.

POST https://api.kriptomat.io/widget/init 

	"token": "6a7d2e91d4cff64939450c74001da4f24fbabd2abae8b2fc1c79a561da9de14a",
	"asset_type": "eth",
	"to_address": "0x7873ce9E57c6aEEA16aD6AE759CE955736f14e96",
	"amount": 35,
	"amount_type": "fiat",
	"webhook_url": "https://yourDomain.com",
	"additional_fields[0]": "userId",
	"additional_fields[1]": "TransactionId",

Setup Webhook

A page on your site that receives POST data from Kriptomat when a transaction completes. Confirm IP location as being from Kriptomat - Fetch Post data

	"uuid": "uuid",
	"amount": 0.5,
	"asset_type": "eth",
	"fiat_amount": "200",
	"to_address": "0x7873ce9E57c6aEEA16aD6AE759CE955736f14e96",
	"additional_fields[0]": "customContent1",
	"additional_fields[1]": "customContent2",

Then give your user loyalty points or assets or whatever you like.

PhP example

$postdata = file_get_contents("php://input");
$data = json_decode($postdata, true);
if (isset($data['uuid'])){ $uuid = $data['uuid']; }
if (isset($data['amount'])){ $amount = $data['amount']; }
if (isset($data['asset_type'])){ $asset_type = $data['asset_type']; }
if (isset($data['fiat_amount'])){ $fiat_amount = $data['fiat_amount']; }
if (isset($data['to_address'])){ $to_address = $data['to_address']; }
if (isset($data['network'])){ $network= $data['network']; }
if (isset($data['0'])){ $additional_fields1 = $data['0']; }
if (isset($data['1'])){ $additional_fields2 = $data['1']; }

Check the uuid (transaction id) has not been recorded already.

If not a duplicate, record the post details and reward the user if you so choose.

Last updated