Merchant Tools

We'll send a HTTP POST request to the specified IPN URL at the form. The following parameters would be sent.

Field Description
merchant_id Your Merchant ID. Please ensure that it is YOUR merchant ID only.
token This is a verification token, no need to store it. It can be used to verify the integrity of the API.
page_hash A unique identifier for the payment page.
item_name It contains identifiable information about the item/service/product being purchased.
item_desc It contain more information about the item/service/product being purchased.
invoice A string that can be used to identify the order.
custom A string that can contain extra information and data about the payment.
amount1 The original amount you're charging. It can be decimal like 0.0005 ETH or an integer too.
currency1 The currency in which the original amount you're charging. Please find the complete list which can be used as the currency below.
amount2 The amount which the user paid.
currency2 The currency in which the user paid.


Verifying the authenticity of the IPN callback:

It is very important you that you validate each and other IPN request that is caught by your system. For this reason, we include a token field in every IPN request we send to your IPN URL. Your code must sent a GET request to the following URL ( https://tokenpayments.io/api/token-verifier/TOKEN_SENT_HERE ) to validate the authenticity of every IPN. The token verifier endpoint returns a JSON array with the key valid whose value can either be true or false . You should also check if the merchant_id POSTED is yours or not.

PHP Example:

<?php

define("MERCHANT_ID", "YOUR_MERCHANT_ID_HERE");

$merchant_id = $_POST['merchant_id'];
$token = $_POST['token'];
$page_hash = $_POST['page_hash'];
$item_name = $_POST['item_name'];
$invoice = $_POST['invoice'];
$custom = $_POST['custom'];
$amount1 = $_POST['amount1'];
$amount2 = $_POST['amount2'];
$currency1 = $_POST['currency1'];
$currency2 = $_POST['currency2'];

$token_integrity = json_decode(file_get_contents("https://tokenpayments.io/api/token-verifier/" . $token), true)['valid'];

if ($token_integrity == true) {

    if (MERCHANT_ID == $merchant_id) {

        $order_amount = 100;
        $order_currency = "USD";

        if ($currency1 == $order_currency && $amount1 >= $order_amount) {

            // Process the order here.


        }

    }

} else {

    // Invalid request received, someone is probably attacking the endpoint.

}

?>



Form Parameter Details

This helps you setup a payment form so that you can collect payments.

Check Out

IPN Code Samples

Setup your code to process the response each time a payment is made.

Check Out

WooCommerce Plugin

Power your store with TokenPayments by using our plugin.

Download

PHP Class (For IPN)

Authenticate IPN callbacks easily with our class.

Download