# Retrieving a download&#039;s payment IDs using EDD&#039;s Logging Class

 The logging class in Easy Digital Downloads was first introduced in v1.3.1 as a means for logging events and errors. In this tutorial, we&#039;re going to use Easy Digital Downloads&#039; Logging Class to retrieve each payment ID associated with a download&#039;s purchase. Once you have the payment ID, you have access to a wealth of information about the purchase, which you can use for practical applications.

 Once such example is [EDD Purchase Gravatars](https://wordpress.org/plugins/edd-purchase-gravatars/), which displays the gravatars of customers who have purchased your product. This can be used for showing social proof/trust, where customers are more inclined to purchase your product when they see other real customers who have already purchased.

 ![edd-purchase-gravatars](https://easydigitaldownloads.com/wp-content/uploads/2022/07/6184cc8d1aa48.png)

 The plugin uses the customer&#039;s email address and first name which are required by Easy Digital Downloads to complete the purchase. Using WordPress&#039; get\_avatar() function, the plugin retrieves the gravatar associated with the given email address, and uses the customer&#039;s first name for the image&#039;s alt tag.

The sales log
=============

 In order to retrieve the customer&#039;s email address and first name for the gravatars, we ultimately need the payment ID for each purchase. This can be found by first retrieving each purchase&#039;s log ID. We can see a list of all a download&#039;s purchases by clicking &quot;View Sales Log&quot; on the &quot;download stats&quot; metabox on the download&#039;s edit/publish screen.

 From the image below, we can see one purchase has a Log ID of 55. In the same row, we can see it has a payment ID of 54. Each time a purchase is made, the Log ID and payment ID are stored at the same time, sequentially.

 ![logs](https://easydigitaldownloads.com/wp-content/uploads/2022/07/6184cc8d60b45.png)

Digging into wp\_postmeta
=========================

 To understand how we can get the payment ID from the log ID, we need to dig into WordPress&#039; wp\_postmeta table. If we filter the table by a post\_id of 55 (log ID), we find the \_edd\_log\_payment\_id meta\_key with a value of 54 (our payment ID). This also matches the sales log, illustrated in the image above.

 ![post_meta_log_id](https://easydigitaldownloads.com/wp-content/uploads/2022/07/6184cc8da04d0.png)

 Filtering by post\_id with our newly discovered payment ID (54), we find all the useful information stored against our purchase. In EDD Purchase Gravatars we use the email stored in the \_edd\_payment\_user\_email meta\_key, and the first name which stored inside the \_edd\_payment\_meta array (there&#039;s also an email address inside here also). In order to make use of all the information stored in the \_edd\_payment\_meta array, you will first need to unserialize it, using the maybe\_unserialize function in WordPress.

 ![post_meta_purchase_id](https://easydigitaldownloads.com/wp-content/uploads/2022/07/6184cc8ddf244.png)

Retrieving the Log IDs
======================

 Now that we know we need to first retrieve all the Log ID&#039;s of a download, we&#039;ll use the helpful logging class in Easy Digital Downloads to do this for us. This function requires a download ID to be passed to it, which in the case of EDD Purchase Gravatars, allow the gravatars to be shown anywhere on the website, for any download.

Retrieving the Payment IDs
==========================

 Now that we have an array of all the log IDs, we can use them in a new function to retrieve an array of all the payment IDs.

Conclusion
==========

 Now that you have an array of all the payment IDs, you can loop and output the information you need. What else can you build using payment IDs and EDD&#039;s Logging Class?