Envato APi issue not finding sold items

I want to add a check into my plugins, if it was bought via Envato.

Therefor I have:

$personalToken = 'AmrhXQlMQjd5yj9f78hxxxxxxxxxxxxxxx';
$purchaseCode = '156393a2-04c6-4ade-xxxx-xxxxxxxxxxx';

$url = "https://api.envato.com/v3/market/author/sale?code=".$purchaseCode;
$response = wp_remote_get($url, array(
	"headers" => array(
		"Authorization" => "Bearer ".$personalToken,
		"User-Agent" => "Purchase code verification script"
	)
));

To try, I created a API for myself with the correct permissions (View and search Envato sites (selected by default), Download your purchased items, View your items’ sales history, List purchases you’ve has made) and tried an Item Code I bought myself.
Details above are not the correct ones.

I get always the response:

[body] => {"error":404,"description":"No sale belonging to the current user found with that code"}
    [response] => Array
        (
            [code] => 404
            [message] => Not Found
        )

But the Personal Token is valid and the purchase has been made. What am I doing wrong?

Do I use the wrong Token/Purchase Codes?

Hi @BlutVampir,

You can check if you act as an Author:

If you are a Buyer/customer:
Before you create a new token the following 3 permissions should be selected from the list of permission available on the Token page.

  1. View and search Envato sites (checked by default)
  2. Download the user’s purchased items
  3. List purchases the user has made

Hope this will help you.

Thanks

1 Like

Thats exactly the things I use and read.

You can find the code 1:1 in the wiki. Thats why I ask for help whats wrong?

It doesn’t look like you have any items for sale yet, is that right? Which means you won’t be able to test that endpoint (/author/sale) because it only works for your own items, not items you’ve purchased from other authors.

You have two options to test in this case:

  • You can replace the /author/sale endpoint with /buyer/purchase to use a code for one of your purchases. The response should be identical, except the buyer field will be missing. This will require the purchase:verify permission on the personal token, which is labeled on build.envato.com as “Verify purchases the user has made.”

  • You can also use my unofficial sandbox to test a realistic response from /author/sale, see my documentation on that here: How to verify a purchase code using the Envato API

4 Likes

cool, thanks a lot, that helped me a lot :wink:

Can test it now before selling items, great thanks

1 Like