I recently had the need to validate some buyer purchase codes programmatically using the Envato API. After a little googling, all the examples I found were either outdated or too bloated. The api documentation isn’t aso very clear on a number of things. For instance, It does not explain why one would use AUTH over personal tokens, but I digress. I was able to solve the problem with the code below.

Before you deploy the code you need two things,

A Personal token to authenticate you with the api. This can easily be obtained here. There token is referred to as the API Key in the code below.

Your customer’s purchase code with looks something like this ’38a856d2-a0e4-46dc-976d-8e4ec367a3cb’.

At Radium Themes we provide you with free and premium tools to build your website with WordPress. Our products offer top-of-the-line security, an enterprise-grade infrastructure, and around-the-clock support.