We have a very basic example here: https://developer.squareup.com/docs/webhooks-api/validate-notifications (note you need to switch to PHP in the top code switcher). It technically is showing you how to validate the notifications, but in doing so, you’ll see how to receive the webhooks as well. If you still have questions, let me know and I will try to assist!
I have set my app up to receive ebooks. I now have an “event id” in my app.
How do I make the call to squares server to get the information I need from a given event id?
I need:
Customer name
Customer email
Customer phone
And the status of whether they chose any choices within the specific item (in my case. Whether they chose yes or no on a checkbox charging them an extra $5)
What webhook are you currently listening to? Customer information would be retrieved using the Customers API, but depending on what webhook you are getting would depend on how you get there. For example, if you’re receiving payment webhooks, you would need to call GetPayment, then the payment should have a customer_id attached to it, and then you can use RetrieveCustomer to get the customer information.
Anything related to the itemization would be retrieved using the Orders API.
I am listening to the orders webhook. I chose that one because I wanted to log that persons information and purchase details to my own system when they order a specific online item.
Do you have any general or php specific information on making the connection to the square api so that I can make the GetPayment and RetrieveCustomer calls?
If you’re using the PHP SDK you can see some basic functionality in the README found here: https://github.com/square/square-php-sdk. If you’re not using the SDK, then you’ll need to build out your own HTTP requests within PHP. This can be done using the built in cURL, or any other third-party HTTP library (like Guzzle). You’ll need to set the headers, any body parameters, and the URL which can be seen in the above links that I provided. In the right-hand side it shows how to do the requests in cURL or one of the SDKs.