I need some help from anyone familiar with webhooks, or Snipcart in particular.
I am trying to follow Snipcart’s documentation for calculating rates with a webhook.
This is the route code the webhook calls: (rates are simplified)
The problem is that the route does not seem to receive the request body the webhook is sending.
I am not sure how to test for this, but the $country variable ends up empty.
Im not the greatest with this but ive tinkered a bit with this kind of thing. I think the issue is that its one way… you only posting out. I think you need the method to be both post and get.
Normally to debug this kind of stuff you use a tool to start off with to make sure getting the responses correct. Theres a bunch of free ones out there like Postwomen
@jimbobrjames Ι tried setting the method to POST|GET but the same thing happens. I tried the Insomnia tool to send a mock of the body the webhook is sending, and the route handles it correctly.
So I wonder if kirby()->request()->data() the right way to get the webhook’s request body.
Ok, it was just a matter of removing the [‘body’] index from $data. I guess I messed up switching contexts between the mock data I used in Insomnia, and the real data.