Gameball Developers Guide
v3.0
Ask or search…
K

Webhooks

Use our webhooks to subscribe to receive notifications for events in Gameball application.
You can use webhook subscriptions to receive notifications for particular events in Gameball. After you have subscribed to a webhook, your app can execute a specific code immediately after specific events occur in Gameball. Common webhook use cases include sending notifications to IM clients and pagers.
After you configure a webhook subscription, the events that you specified will trigger a webhook notification each time they occur. This notification contains a JSON payload, and HTTP headers that provide context. Webhook includes the following header with example value:
X-GB-Signature: d755uJWQ5U6S7LmgLbg3Fjx9q5MaBW=

Supported Webhook Events

You can retrieve data in JSON format. At the moment, webhooks are available for notification event, while we are working on supporting more events.
Events
Description
Event is sent whenever a new notification is generated for a player
Event is sent whenever an update occurs to player's profile

Creating an Endpoint for Webhooks

Your endpoint must be an HTTP webhook address that can correctly process event notifications as described. You must also implement verification to make sure webhook requests originate from Gameball.

Configuring Webhooks

You can configure a webhook using Gameball admin dashboard by following the below steps:
  1. 1.
    From your Gameball admin, go to Admin Settings > Account Integration.
  2. 2.
    In the Webhooks section, click Edit.
  3. 3.
    Enter the URL on which you want to receive notifications.

Receiving a Webhook

After you register a webhook URL, Gameball issues an HTTP POST request to the URL specified every time that event occurs. The request's POST parameters contain JSON data relevant to the event that triggered the request.

Verifying Webhooks

Webhooks are verified by calculating a digital signature. Each webhook request includes a base 64 encoded X-GB-Signature header, which is hashed using the TransactionsKey along with the data sent in the request. You can find more about base 64 encoding here, if you are unfamiliar.
To verify that the request came from Gameball, compute the SHA1 digest according to the following algorithm and compare it to the value in the X-GB-Signature header. If they match, then it is s verified webhook from Gameball.
calculated_sha1 = Base64.encode(sha1.ComputeHash(JSON_Payload+':'+TransactionsKey))
if(calculated_sha1 == Headers['X-GB-Signature'])
//verified webhook
else
//non verified webhook
Check out our next article to learn more about notifications webhook.

Webhooks Retry Policy

The webhook retry policy governs the behavior of failed webhook deliveries and provides guidelines for handling such scenarios. When a webhook delivery fails, it is essential to have a well-defined retry policy to ensure successful delivery of the payload. In our case, Gameball handles webhooks behavior in case of sending failure as described below.

Failed Attempt

The webhook attempt is considered a failed attempt whenever Gameball receives a response with status code that is not 2XX, which means that for example, a status code of 403 is considered as a failed attempt, hence the retry policy applies.

Retry Attempts

The retry policy defines the number of attempts that will be made to deliver the webhook payload. Gameball provides three retry attempts. The retry policy also specifies the delay between each retry attempt. The delays durations are specified as follows, 1st attempt is after 5 minutes, the 2nd attempt is after 20 minutes and the final attempt is after 60 minutes. Lastly, if the webhook failed to send after all these attempts, this specific webhook request will be discarded.