API WebHook

CoinCorner Checkout provides a webhook which allows merchants to receive updates about the status of an order paid with CoinCorner Checkout.

Once an order status changes, CoinCorner Checkout sends a HTTP POST request to the Notification URL of the order (provided by the merchant when an order is created).

The webhook is sent containing the following parameters in the header of the request and within the content of the request (these parameters are sent in JSON format).

NameValueDataType
OrderId

Customers OrderId

string
API Key

Merchants generated API Key from CoinCorner website

globally unique identifier

The webhook request doesn't contain any sensitive information about an order and is only an indication that the order status has changed. The Merchant would typically use the API Key provided in the request as authentication that the webhook was sent from CoinCorner Checkout.

If the webhook doesn't receive a 200 response, it will send the request again up to 3 times. the timeout of the request is 100 seconds, if a 200 response is not received within this timeframe, the request will be classed as failed.

Once you have received the webhook and been informed that one of your orders has changed status, a call to the CheckOrder call will be required to retrieve the updated status of the order.

The overall flow is as follows:

  1. The status of an order changes.
  2. CoinCorner Checkout send a HTTP POST request to the provided Notification URL with OrderId and API Key in the header and content of the request.
  3. You authenticate the request received was from CoinCorner Checkout using the API Key parameter.
  4. Get the details for your order update using the CheckOrder call

You can then used the information received from the CheckOrder call to update your internal systems.

            
                  
    <?php

        $raw_post = file_get_contents('php://input');
        $decoded  = json_decode($raw_post, true);
        $order_id = $decoded['OrderId'];
        $API_Key_Request = $decoded['APIKey'];
        $UserId = "Merchant UserId";
        $Api_Key = "Merchant API Key";


        $url = 'https://checkout.coincorner.com/api/CheckOrder';
        $nonce = (int)(microtime(true) * 1e6);
        $sig = Generate_Sig($nonce);
        $headers = array();
        $params = array();


        $params['APIKey'] = $Api_Key;
        $params['Nonce'] = $nonce;
        $params['Signature'] = $sig;
        $params['OrderId'] = $order_id;

        if($API_Key_Request == $Api_Key) {

            $curl = curl_init();

            $curl_options = array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL            => $url
            );


            $headers[] = 'Content-Type: application/x-www-form-urlencoded';
            array_merge($curl_options, array(CURLOPT_POST => 1));
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));

            curl_setopt_array($curl, $curl_options);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

            $response  = json_decode(curl_exec($curl), true);
            $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

            $OrderStatus = $response["OrderStatus"];
        }
    ?>