How to Set Up Hook URLs
Learn how to configure Hook URLs in the Bolt Merchant Dashboard.

Set up Hook URLs in the Bolt Merchant Dashboard to listen for key transaction event updates. Each Hook URL corresponds to a feature that must also be enabled.

How to Set Up Hook URLs

  1. Log in to the Bolt Merchant Dashboard.
  2. Navigate to Administration > API.
  3. Scroll to Merchant Callbacks.
  4. Choose the base URL you want to update and click the pencil icon next to it.
  5. Select the endpoint you want to declare in the dropdown menu.
  6. Input the URL.
  7. Select Add merchant callback to save.

Universal API URL

The Universal API endpoint can be used as an alternative to having many individually defined endpoints such as Shipping, Tax, and Create Order.

PHP Example

https://your-store-url.com/example/universalapi.php

<?php
require(dirname(__FILE__) . '/init_example.php');

$hmacHeader = @$_SERVER['HTTP_X_BOLT_HMAC_SHA256'];

$signatureVerifier = new \BoltPay\SignatureVerifier(
    \BoltPay\Bolt::$signingSecret
);

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

if (!$signatureVerifier->verifySignature($requestJson, $hmacHeader)) {
    throw new Exception("Failed HMAC Authentication");
}

$requestData = json_decode($requestJson);
$event = $requestData->event;

header('Content-Type: application/json');
http_response_code(200);
$exampleData = new \BoltPay\Example\Data();
switch ($event) {
    case "order.shipping":
        $data = $exampleData->generateShippingOptions();
        break;
    case "order.tax":
        $shippingOption = @$requestData->data->shipping_option;
        $data = $exampleData->generateTaxOptions($shippingOption);
        break;
    case "order.shipping_and_tax":
        $data = $exampleData->generateShippingTaxOptions();
        break;
    case "order.create":
        $baseUrl = $exampleData->getBaseUrl();
        $data = [
            'status' => 'success',
            'message' => 'Order create was successful.',
            'order_received_url' => $baseUrl . '/example/order_confirmation.php',
            'display_id' => @$requestData->order->cart->display_id
        ];
        break;
}

echo json_encode(
    [
        'status' => 'success',
        'event' => $event,
        'data' => $data,
    ]
);



Shipping URL

The Shipping endpoint is the singular alternative to the combined Shipping and Tax endpoint.

PHP Example

https://your-store-url.com/example/shipping.php

<?php
require(dirname(__FILE__) . '/init_example.php');

$hmacHeader = @$_SERVER['HTTP_X_BOLT_HMAC_SHA256'];

$signatureVerifier = new \BoltPay\SignatureVerifier(
 \BoltPay\Bolt::$signingSecret
);

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

if (!$signatureVerifier->verifySignature($requestJson, $hmacHeader)) {
 throw new Exception("Failed HMAC Authentication");
}

$exampleData = new \BoltPay\Example\Data();
$response = $exampleData->generateShippingOptions();

header('Content-Type: application/json');
http_response_code(200);
echo json_encode($response);

Tax URL

The Tax endpoint is the singular alternative to the combined Shipping and Tax endpoint.

PHP Example

https://your-store-url.com/example/tax.php

<?php
require(dirname(__FILE__) . '/init_example.php');

$hmacHeader = @$_SERVER['HTTP_X_BOLT_HMAC_SHA256'];

$signatureVerifier = new \BoltPay\SignatureVerifier(
    \BoltPay\Bolt::$signingSecret
);

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

if (!$signatureVerifier->verifySignature($requestJson, $hmacHeader)) {
    throw new Exception("Failed HMAC Authentication");
}

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

$shippingOption = json_decode($requestJson)->shipping_option;
$exampleData = new \BoltPay\Example\Data();
$response = $exampleData->generateTaxOptions($shippingOption);

header('Content-Type: application/json');
http_response_code(200);
echo json_encode($response);

Shipping and Tax URL

The Shipping and Tax endpoint can be used to combined both Shipping and Tax calculations in one request.

PHP Example

https://your-store-url.com/example/shipping_and_tax.php

<?php
require(dirname(__FILE__) . '/init_example.php');

$hmacHeader = @$_SERVER['HTTP_X_BOLT_HMAC_SHA256'];

$signatureVerifier = new \BoltPay\SignatureVerifier(
    \BoltPay\Bolt::$signingSecret
);

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

if (!$signatureVerifier->verifySignature($requestJson, $hmacHeader)) {
    throw new Exception("Failed HMAC Authentication");
}

$exampleData = new \BoltPay\Example\Data();
$response = $exampleData->generateShippingTaxOptions();

header('Content-Type: application/json');
http_response_code(200);
echo json_encode($response);


Create Order URL

The Create Order endpoint is used to verify that an order can be created before payment is authorized.

PHP Example

https://your-store-url.com/example/preauth_create_order.php

<?php
require(dirname(__FILE__) . '/init_example.php');

$client = new \BoltPay\ApiClient([
    'api_key' => \BoltPay\Bolt::$apiKey,
    'is_sandbox' => \BoltPay\Bolt::$isSandboxMode
]);

$requestJson = file_get_contents('php://input');
$requestData = json_decode($requestJson);
$exampleData = new \BoltPay\Example\Data();
$baseUrl = $exampleData->getBaseUrl();
$response = [
    'status' => 'success',
    'message' => 'Order create was successful.',
    'order_received_url' => $baseUrl . '/example/order_confirmation.php',
    'display_id' => @$requestData->order->cart->display_id
];

header('Content-Type: application/json');
http_response_code(200);
echo json_encode($response);



Filter by Section
Filter by Topic