RoR: Reading Transaction Webhooks JSON

First, apologies if this is not the right subforum to post this in.

I’ve set up webhooks in our Test Environment to get get sample data into our test server and see it working as a sort of proof of concept. However they are not sending data with them, but rather a blank JSON object only with the key ‘webhook’

I’ve created a Program with Brands, Locations and Offers. Then set up the four transaction webhooks (transaction.clearing, transaction.clearing.qualified, transaction.auth, and transaction.auth.qualified).

Using the API Playground, I can add a new Card and can create Transactions at the test locations with the test card. This does trigger the webhooks, but the data received by the server it is an empty JSON object. It is just the key ‘webhook’ with no information inside of it. Is this a limitation of the Test Environment? If so, is there a better way of testing the webhooks? And if not, could someone point me to where I might be making a mistake?

Thanks!

HI @gpwest

We just published a blog post about using webhooks with the Fidel APIs.

Inside the post above are 2 Glitch apps that:

  1. Add a card, and submit a transaction.
  2. Receive the webhooks and parse the data

Check out the code in the 2nd Glitch to see if that helps. It is built on NodeJS, and the issue I had was that I forgot to add the Express JSON parsing:

var app = express();
app.use(express.json());  

Without this - there was no information in the body. Once I added this line, the magic began :smiley:

Doug

Thank you Doug for pointing me towards that! I’m really not sure how I missed that being published right there.

That post helped guide me in the right direction — I was able to see you were reading the JSON for each webhook from the body of the request. I am working with Ruby on Rails, and for anyone else also, this is what I found:

As per the linked post above, the JSON info is passed in the body of the request rather than in the params. Looking at params will only show the blank ‘webhook’ hash with no information inside. You can read the full JSON response by parsing it from the request’s body:

JSON.parse request.body.read

1 Like