logo

Webhook Documentation

Setting Up a Webhook

Webhooks allow you to receive real-time updates from DashX. Follow these steps to set up a webhook.

How to Create a Webhook

  1. Go to the DashX Dashboard.
  2. Login with your DashX account.
  3. Navigate to Webhook in the sidebar menu.
  4. Click the Create Webhook button on the top-right.
  5. Webhook Setup Guide
  6. Enter the Endpoint URL and a brief description, then click Create.
  7. Once added, hover over the endpoint and click Send Test Event to verify the webhook.
  8. For security, a Webhook Secret Key is generated. Store it securely as it will only be shown once.

Usage of Webhook

Webhooks allow you to receive real-time updates about checkout sessions and other events. Once a webhook is configured, your server will receive structured JSON payloads whenever an event occurs.

Response from Webhook

  • When a checkout session is completed, your webhook URL will receive a POST request with a payload similar to this:

    
    {
      "id": "38ea5415-d69c-4aa2-a892-588972a534d3",
      "apiVersion": "2023-01-11",
      "created": 1745405443086,
      "object": "checkoutSession",
      "type": "checkout_session.completed",
      "data": {
        "object": {
          "id": "7cf3f4cf-e39a-48b5-ad07-ea7a77c4c52d",
          "createdAt": "2025-04-23T10:50:41.449683Z",
          "amountTotal": "0.00987000",
          "status": "SUCCESS",
          "currency": "SOL",
          "customer_id": "36ab0154-0797-42",
          "payment_link_id": "d4cf04d5-0d45-4b6e-9227-011b39844aac",
          "payment_link_title": "test",
          "payment_link_slug": "sKgmsAGmRZ-aa5XOFLqZ8Q",
          "transaction_hash": "3jdxLnx5Pe22X6uBqB1Cwt6x6xtjfjh8yUnwc3667KkX43KiCroiT2rZ9b3VJ8jnMyF3LvGF2biJu3etsubHjb2t",
          "from_address": "4umonu9DZSj63cUZVvAUfLhBMDr8ad4YcAeUMBSZXUS2",
          "payment_address": "cuZFBDnPSt5J7Limwm37RedRWpNVs1xNR8XQDtWDMiN",
          "chain_symbol": "SOL",
          "payment_amount": "0.01000000",
          "payment_processing_fee": "0.00005000",
          "updatedAt": "2025-04-23T10:50:43.086043+00:00"
        }
      }
    }
  • When a checkout session is expired, your webhook URL will receive a POST request with a payload similar to this:

    
    {
      "id": "d011c41f-a29f-4c44-b3de-64e234d8b269",
      "apiVersion": "2023-01-11",
      "created": 1742839610947,
      "object": "checkoutSession",
      "type": "checkout_session.expired",
      "data": null
    }
  • When a checkout session is canceled, your webhook URL will receive a POST request with a payload similar to this:

    
    {
      "id": "d011c41f-a29f-4c44-b3de-64e234d8b269",
      "apiVersion": "2023-01-11",
      "created": 1742839610947,
      "object": "checkoutSession",
      "type": "checkout_session.canceled",
      "data":null
    }

Tip: You can use the payment_link_slug from the webhook response to verify the transaction status through the API. This is especially useful when you need to confirm payment details or perform additional checks after receiving a webhook event.

Handling Webhooks in Your Application

Webhooks allow your server to listen for real-time payment events. When a checkout session is completed, your webhook URL will receive a POST request containing transaction details. Below are examples of how to handle webhook events in Python and JavaScript.

🔹 Python Example (Flask)

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def webhook():
    data = request.json
    if data["type"] == "checkout_session.completed":
        print("Payment successful:", data["data"]["object"])
    return jsonify({"status": "received"}), 200

if __name__ == '__main__':
    app.run(port=5000)

🔹 JavaScript Example (Express.js)

const express = require("express");
const app = express();

app.use(express.json());

app.post("/webhook", (req, res) => {
  const data = req.body;
  if (data.type === "checkout_session.completed") {
    console.log("Payment successful:", data.data.object);
  }
  res.json({ status: "received" });
});

app.listen(5000, () => console.log("Webhook server running on port 5000"));

Note: Only 5 webhooks are allowed per merchant