image CryptoWiz Manual and
Documentation

The callback functionality

Whenever you specify a script to be called when an order is completed, our system will send a POST request with all the data we can gather from the order to the script you set as recipient of the notification.

You can set a different script to every button you create, giving you all the control you need to process orders programmatically.

Data is posted as a standard array of keys/values, and you can see a full example of what is being included ahead:

[order_id] => 11538455260036

[timestamp] => 1538455260

[date] => 2018-10-01 23:41:00

[time_zone] => GMT-0500

[gmdate] => Tue, 02 Oct 2018 04:41:00 GMT

[full_order_handler] => bardcanvas.com/vk4cx57fshc:11538455260036

[invoker_website_key] => bardcanvas.com

[button_id] => vk4cx57fshc

[button_owner_website_key] => bardcanvas.com

[entry_id] => DIRECT-DONATION

[entry_title] => Donation to the lead developers of the BardCanvas CMS.

[entry_data1] =>

[entry_data2] =>

[entry_data3] =>

[entry_data4] =>

[entry_data5] =>

[ref_code] =>

[sender_data] => Array

    (

        [account_id] => 1011538391441085

        [name] => Test User

        [email] => some-email@domain.com

        [country] => MX

    )

[recipient_data] => Array

    (

        [account_id] => 1011536047713093

        [name] => BardCanvas

        [email] => other-email@domain.com

        [country] => US

    )

[request_type] => suggestion

[coin_scheme] => multi_converted

[fiat_currency_symbol] => USD

[per_coin_transaction_data] => Array

    (

        [0] => Array

            (

                [opslog_id] => 2018100123410057

                [coin_name] => Dynamic

                [fiat_rate] => 0.72840100

                [gross_coin_amount] => 1.99995000

                [deducted_fees] => Array

                    (

                    )

                [net_coin_amount] => 1.99995000

                [gross_fiat_value] => 1.45676558

                [net_fiat_value] => 1.45676558

            )

    )

[total_fiat_value] => 1.45676558

We provide below two samples of PHP scripts that handle IPN posts sent by CryptoWiz when an order is placed.

Sample 1: send order data by email

Copy and customize this code and upload it to a website you own:

<?php

/**

 * BCF IPN processing script demo

 *

 * This script will receive the order details and send it by email.

 * In order to make it function, please copy/paste, edit and upload to your website,

 * then create a button and set the callback script URL on the button to the

 * actual URL of this script on your server and then hit the "Test" button.

 */

 

// Validations

if( empty($_POST) || ! is_array($_POST) ) die("ERROR: Nothing has been posted.");

 

// You should customize this:

$mail_to    = "lava.caballero@gmail.com";

 

// Mail info forging

$ip         = $_SERVER["REMOTE_ADDR"];

$hostname   = gethostbyaddr($_SERVER['REMOTE_ADDR']);

$received   = date("Y-m-d H:i:s");

$subject    = "[BCF-IPN-TEST] Order received: #{$_POST["order_id"]} from {$_POST["sender_data"]["name"]}";

 

// Body forging

$body = "A payment order has been received from BCF.<br><br>"

    . "Posted data:<br>"

    . "---------------------------------<br>"

    . "<pre>" . print_r($_POST, true) . "</pre>"

    . "---------------------------------<br><br>"

    . "Received: $received<br>"

    . "IP:       $ip<br>"

    . "Host:     $hostname<br>"

;

 

// Actual mail sent

@mail(

    $mail_to, $subject, $body,

    "MIME-Version: 1.0\r\n" .

    "Content-Type: text/html; charset=UTF-8\r\n"

);

 

// HTML message that will be shown to the sender

echo "<b>Thank you for your order!</b> We'll handle it ASAP.";

Once uploaded, edit a button and set the callback URL and hit the “Test” button:

image

You’ll be notified when the demo data is posted and the message received from your script:

image

So when you open your email, you’ll see the message sent by your IPN processor:

image

Sample 2: saving incoming data locally

This sample is similar to the previous one, but instead of emailing the data, it is flattened and saved to a temporary file.

Note: since this script saves to the system’s “temp” directory, you might need SSH access to see the contents of the generated file.

<?php

/**

 * BCF IPN processing script demo

 *

 * This script will receive the order details and save it to a temporary file.

 * In order to make it function, please copy/paste, edit and upload to your website,

 * then create a button and set the callback script URL on the button to the

 * actual URL of this script on your server and then hit the "Test" button.

 */

 

// Validations

if( empty($_POST) || ! is_array($_POST) ) die("ERROR: Nothing has been posted.");

 

// Helper function

function flatten_param($parent_key, $key, $value)

{

    if( is_array($value) || is_object($value) )

    {

        $return = "";

       

        foreach($value as $key2 => $value2)

            $return .= flatten_param("$parent_key.$key", $key2, $value2);

       

        return $return;

    }

   

    return ltrim("$parent_key.$key = $value", "._") . "\n";

}

 

// Let's flatten the posted data

$flattened_data = "";

foreach ($_POST as $key => $value) $flattened_data .= flatten_param("", $key, $value);

 

// Now let's just write the file

$tempdir = sys_get_temp_dir();

file_put_contents("$tempdir/ipn_received.txt", $flattened_data);

 

// HTML message that will be shown to the sender

echo "<b>Thank you for your order!</b> We'll handle it ASAP.";

Paste and upload the script to your website and set it as callback on the button. When you hit the “Test” button you’ll be notified. Then, look up on your system’s temp directory and watch the contents of the generated file:

image

If you get stuck…

If you need help implementing this feature on your website, feel free to drop a request at our User Support forum or contacting us directly.

© 2018 Blockchain Financial image