Webhook

The webhook is generally responsible for verifying requests sent to your webhook URL. Requests sent from a source other than BuyCoins is regarded as malicious.

The webhook class is instantiated with three arguments:

  • body: request body

  • token: webhook token from BuyCoins account

  • header-signature: request header signature defaulting to "X-Webhook-Signature"

verify_request()

This method, when called, verifies the legitimacy of the arguments passed when instantiating the class. The method returns a boolean:

  • True: if the request originated from BuyCoins

  • False: if the request didn't originate from BuyCoins

Example

from buycoins import Webhook

request = Webhook(body=sample_body, token=token_from_buycoins)

isValid = print(request.verify_request())

print(isValid) # True or False

For a more detailed explanation of BuyCoins' webhook, refer to BuyCoins' documentation.

Last updated