Difference between payment.created an payment.updated webhooks

I capture payment.created and payment.updated webhooks, and use the data to change database records. My existing method for capturin card info is to have the customer use the card SDK to manually enter data, create a the card with the API, and then connect the returned ccof to the customer record for reuse in other payments/orders

We’re getting requests to use a card reader to capture card info. I’m specifically interested in capturing data payments of type ‘contactless’ or ‘Swiped’ method.

I create a Square customer record and a database record with the squareID. Then the staff can use that customer record to sell an item using the Square POS via a card swipe.

I want to capture the card info from that card swipe. I have a listener that can do this. I just don’t understand how the numerous payment.updated webhooks are meant to be used.

It’s my understanding that I can use the payment_id a Source for a create card API. So I’ve been observing payment.createed and payment.updated records. I’m surprised that there are typically 3 (or more) payment updated records for each payment.

What I want to find is the webhook that reflects the first time that payment record has both a customerID and a payment ID (usually the second or third payment.updated webhook)

I don’t understand what other data is being added in other payment updated webhooks, or whether the (seemingly) small updates are relevant to my database.

Any help appreciated.

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Create a Card on File from a Payment ID
Gift Card Webhooks
Customers API Workflows

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The Payments API generates a payment.updated webhook event whenever any field in a Payment is updated. This could include updates to the payment status, card details status, or any other field in the Payment object.

For example, when a payment is completed (paid), a payment.updated event is generated. Similarly, if a payment is associated with a Square Invoice and the buyer has paid the invoice, or when a payment is part of an Order and you call PayOrder, the Payment.status is changed to COMPLETED, which results in a payment.updated event.

In your case, you are observing multiple payment.updated events because there are multiple updates happening to the Payment object.

If you are specifically interested in capturing data payments of type ‘contactless’ or ‘Swiped’ method, you can look at the payment_method_details field in the Payment object. This field provides more details about the payment method used.

To find the first time that a payment record has both a customerID and a payment ID, you can check the customer_id and id fields in the Payment object.

As for the relevance of the small updates to your database, it depends on your specific use case. If those updates are not relevant to your application, you can choose to ignore them. However, if you need to keep track of all changes to a Payment object, you should update your database accordingly each time you receive a payment.updated event.

This answer was reviewed by @josh-square.