# Webhook beginner

**URL:** <https://developer.squareup.com/forums/t/webhook-beginner/1314>\
**Category:** Questions\
**Tags:** webhooks-api\
**Created:** [November 27, 2020, 10:50pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314 "2020-11-27T22:50:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkdiscgolf](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@pkdiscgolf](https://developer.squareup.com/forums/u/pkdiscgolf)\
**Post date:** [November 27, 2020, 10:50pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/1 "2020-11-27T22:50:50Z")

</div>

I am trying to learn how to properly set up webhooks and a listener on my server in order to process the webhooks.

My end game is to make a mysql database entry every time i have some purchase an item with their name and a couple of the item details.

I am hoping to set this up in PHP. I have a generic rest api set up but I am trying to learn how to configure it to read one of these square webhooks.

Does any one have example php of a listener which reads the square webhooks? Or familiarity with what I am trying to accomplish?

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [December 1, 2020, 5:59pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/2 "2020-12-01T17:59:07Z")

</div>

Hi @pkdiscgolf welcome to the forums!

We have a very basic example here: [https://developer.squareup.com/docs/webhooks-api/validate-notifications](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!

---

<div class="post-metadata">

**Author:** ![pkdiscgolf](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@pkdiscgolf](https://developer.squareup.com/forums/u/pkdiscgolf)\
**Post date:** [December 1, 2020, 6:15pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/3 "2020-12-01T18:15:58Z")

</div>

Thank you for getting back to me!

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)

Thank you

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [December 1, 2020, 6:51pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/4 "2020-12-01T18:51:05Z")

</div>

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](https://developer.squareup.com/reference/square/payments-api/get-payment), then the payment should have a `customer_id` attached to it, and then you can use [RetrieveCustomer](https://developer.squareup.com/reference/square/customers-api/retrieve-customer) to get the customer information.

Anything related to the itemization would be retrieved using the [Orders API](https://developer.squareup.com/docs/orders-api/what-it-does).

---

<div class="post-metadata">

**Author:** ![pkdiscgolf](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@pkdiscgolf](https://developer.squareup.com/forums/u/pkdiscgolf)\
**Post date:** [December 1, 2020, 7:22pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/5 "2020-12-01T19:22:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [December 1, 2020, 7:44pm UTC](https://developer.squareup.com/forums/t/webhook-beginner/1314/6 "2020-12-01T19:44:46Z")

</div>

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](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.
