Troubleshooting Wrong Webhooks Implementation

article feature image

In this article, we’ll discuss how to troubleshoot and debug webhook issues. For more details on what a webhook is and how to set up a webhook for Flutterwave transactions, kindly visit here.

After reading this article, you should be able to:

  1. Confirm correct webhook configuration, and
  2. Debug wrong configurations.

Why webhooks fail

If you are not receiving webhooks for your transactions, there are two possible reasons and they are:

  • Flutterwave is not sending the data to your hook URL because the webhook URL is not set or the transaction is not in a final state (success or failed), or
  • Your hook server is not accepting the requests

Irrespective of the situation, the first step in troubleshooting would be testing for the scenarios.

Testing for Flutterwave Hooks

To test for Flutterwave, we will generate a listening URL from  https://webhook.site/. This will serve as our server listening for Flutterwave hooks.

After a transaction is completed, you should see the webhook data on the URL. This verifies that webhooks are being sent to the developer/merchant’s server.

If no response is displayed on the URL, please shoot us an email at developers@fluterwavego.com to resolve the issue.

To perform this test, please follow the steps below:

  1. Go to https://webhook.site/
  2. Copy the Unique URL
  1. Head over to the Webhooks Tab on the settings page of the Flutterwave dashboard.
  2. Insert the copied URL, then save.
  1. Now, go ahead and complete a transaction. After this transaction is complete, switch back to https://webhook.site/. You should see the webhook data that was sent for the recent transaction.

If the webhook data is displayed as shown in the image above, that verifies that Flutterwave is sending the webhooks correctly and the issue is most likely from your server.

Now, it’s time to check your server.

Testing Webhook Server

Next, we will test if your server is allowing requests to the webhook endpoint and you are getting the sent POST data properly.

Before we proceed, ensure you update the webhook URL to your own test endpoint from the Webhooks Tab of the Flutterwave dashboard.

NB: Please ensure that the operations in the endpoint used for testing do not corrupt your live data.

Testing URL Endpoint Access

This test will help verify if your webhook endpoint allows request from Flutterwave. For this test:

  1. Create a POST endpoint that writes a timestamp to a log file whenever a request is sent to it.
  2. Make a payment transaction.
  3. Check if the log file contains the written timestamp a few seconds after the transaction is completed.

If there is a transaction log after the transaction attempt, it verifies that your server allowed access to the endpoint as expected.

If it didn’t write to your log, then there is a high chance that the request is not getting to the endpoint or that your server is rejecting it, to fix this:

  • Ensure that the URL in the Flutterwave webhook settings is correct.
  • Ensure that your endpoint allows CORS request.
  • Review any non 200 (ok) response coming from the POST call.

NB: Always ensure you check that the hash is correct before processing any request.

Testing Post Data

The next step is to test if you are getting the POST Data correctly.

This test is very similar to the one above. In this case, we’ll be getting the body of the POST request and logging it into the file.

Here is a sample webhook body for a successful charge:

The “data” object contains the data for the transaction, for this test, you will be getting this “data” and logging it to a file.

If after a transaction, the data object is written to the log file, that verifies that you are getting the POST data correctly and can now continue with your webhook implementation.

However, if no data is logged to the file, this means you are not getting the POST data correctly and you should check your code to ensure that you are using the proper method to access the POST body.

See here for sample codes (PHP SampleJS Sample) on how to get the body of the webhook request.

These tips are some of the methods our Software Engineers use to debug faulty webhook implementation. Do you know more methods that were not listed in the article? You can share your technique with us via email.

We hope you found this helpful. You can always reach out to our Developer Experience Team via Mail or our Developer Forum.