Webhooks

Tue Aug 03 2021

2 min read

What is a webhook?

Webhooks allow you to receive information regarding a purchase when it is made, and integrate that into your own applications. When a payment is made, if a product has a webhook assigned to it that you have configured in your portal, a webhook will be instantly sent to an endpoint that you have specified. This can contain data regarding the purchase, the product(s) that have been purchased, and the customer who purchased from your store.

How do I configure a webhook?

Navigate to: 1. The store that you want to add a webhook to. 2. Store settings. 3. Scroll down the panel until you see 'add a webhook'.

There are various attributes here that you must assign:

Webook Name - A friendly name for you to identifier the webhook when assigning it to a product.

Webhook URI - The URI that you want to make a request to for the webhook to hit on product purchase.

HTTPS Verb - The web that you want to make a request with. For more on this, see this documentation

Webhook Timeout - The time (in ms) to wait for the webhook to respond before timing out

Authorisation - The auth required in your webhook request if necessary

Header Key - The key for a header in your request

Header Value - The subsequent value for the key[^1]

You can then specify which data you wish to be sent with the request. If all three are enabled, an example webhook JSON object that is sent with the webhook would look as follows:

[^1]: You will need to click add header for each key/pair value in a header_**

{
  "data": {
    "paymentDetails": {
      "currency": "GBP",
      "method": "CheckoutCard",
      "purchaseTotal": "500", //minor units of currency
      "status": "FULFILLED",
      "timestamp": "50002482", //epoch time
    },
    "customerDetails": {
      "email": "john.doe@foo.bar",
      "name": "John Doe",
      "playerUsername": "JohnDoe",
    },
    "productData-68713xnb786-173n8x-12xn": {
      "additionalActions": [{
        "integration": "Discord",
        "action": "SendMessage",
        "oncePerPurchase": false,
        "metadata": {
          "channelId": "id",
          "content": "hello world"
        }
      }],
      "availableServers": ["id1", "id2"],
      "categories": ["id1", "id2"],
      "commands": [{
          "command": "say hello world",
          "servers": [{
            "name": "server1",
            "identifier": "id1"
          }],
        }
      ],
      "executeOffline": false,
      "identifier": "7auabbce63d-9ia0dw-ajd92la",
      "isHidden": false,
      "longDescription": "lorem ipsum",
      "minecraftData": {
        "guiItem": "stone"
      },
      "name": "foo",
      "price": 300,
      "quantity": 1,
      "shortDescription": "lorem",
      "dependency": "depId",
    }
  }
}

You can then save the webhook to allow for it to be assigned to a product.

How do I assign a webhook to a product?

Navigate to: 1. The store that you want to add a webhook to. 2. Products. 3. Add/Edit the product you wish to add a webhook to. 4. Scroll down until you see the dropdown for webhooks.

You can assign the webhook using its name that you gave it when you configured it. Click save. On purchase of this product, any webhooks this product have will then be executed.

Tags

store, webstore, webhook