how to verify purchase with the new api?

I am trying get author sale and I enter a purchase code that a customer of mine sent me https://build.envato.com/api/#!/market_0/Author_Sale

When I run the query I get this
{
“error”: 404,
“description”: “No sale belonging to the current user found with that code”
}

Is there any reason why this isn’t working? How should I verify the purchase?

1 Like

possibly this document will help you
https://build.envato.com/api/
can you explain you are trying to implement this in PHP script right.

I will build it in php, but the page you provided does not have a method to verify byuers purchase.

this will help you
https://build.envato.com/api/#market_0_Buyer_Purchase

it’s not working
{
“error”: 404,
“description”: “No purchase belonging to the current user found with that code”
}
I think that method only works for currently logged in user, that would be me right now and it needs to be code for some items I purchased, I suply code that was sent to me by my customer, and it returns nothing. I don’t want customers to login to be able to update my application, I want them just to provide purchase code.

If you do not show us all your code, we can not help

try this method instead

https://build.envato.com/api/#market_0_Buyer_Purchase

I do not have a code I am simply right now just testing to see if its possible to verify purchase and I amd doing that by https://build.envato.com/api/ you can test the api right there if you are logged in, it seems that they do not support verifying of your customers purchases to me, unless I am misstaken

that was already suggested and I tried it and got

it’s not working
{
“error”: 404,
“description”: “No purchase belonging to the current user found with that code”
}

dude, what is your php code? How you are using the API rofl

The link that is provided to you is an API Endpoint (Application Programming Interface), it is not a ready to go App where you can enter a license code so it will verify it for you.

Not sure what you mean, I am doing all according to documemtation. Even my php code returns nothing. Here is a sample that should work:

    $bearer   = 'Bearer myBearerCodeHere;
    $header   = array();
    $header[] = 'Content-length: 0';
    $header[] = 'Content-type: application/json; charset=utf-8';
    $header[] = 'Authorization: ' . $bearer;

    $verify_url = 'https://api.envato.com/v3/market/author/sale?code='.$purchaseCode;
    $ch_verify = curl_init( $verify_url );

this returns

{
“error”: 404,
“description”: “No sale belonging to the current user found with that code”
}

Well for one you haven’t passed your $header variable into the CURL object.

I wrote a guide on how to implement this in PHP: Setup Envato API to check Product Codes

1 Like

hi Patchesoft this is actually my complete code:

    $verify_url = 'https://api.envato.com/v3/market/author/sale?code='.$code;
    $ch_verify = curl_init( $verify_url );

    curl_setopt( $ch_verify, CURLOPT_HTTPHEADER, $header );
    curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 );
    curl_setopt( $ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

    $cinit_verify_data = curl_exec( $ch_verify );
    curl_close( $ch_verify );

Isn’t there any opposite method for getting the purchase codes from a client who bought some product from a developer with the API?
It would be a nice feature for the future. At least for developers who want to save those informations somewhere, or that want to test the API for any other purposes whitout the need to request this from buyers… Or probably under the Developer statements and that could be available for that user.

Best regards.

Yes @EZCode you can do this, by having them login with OAuth and then you can see all of their purchases from you along with the corresponding purchase codes.

See: https://build.envato.com/api/#oauth
Then you can list a buyer’s purchases: https://build.envato.com/api/#market_0_Buyer_Purchases

Example response from calling /buyer/purchases (thanks dtbaker):

{
  "buyer": {
    "id": 123456,
    "username": "buyer_name_here"
  },
  "author": {
    "id": 1234,
    "username": "dtbaker"
  },
  "purchases": [
    {
      "amount": "59.00",
      "sold_at": "2016-01-18T09:21:08+11:00",
      "item": {
        "id": 33333333333,
        "name": "name",
        "description": "desc",
        "site": "themeforest.net",
        "classification": "wordpress/creative",
        "classification_url": "http://themeforest.net/category/wordpress/creative",
        "price_cents": 5900,
        "number_of_sales": 102,
        "author_username": "dtbaker",
        "author_url": "http://themeforest.net/user/dtbaker",
        "author_image": "https://0.s3.envato.com/files/111547951/dtbaker-php-scripts-wordpress-themes-and-plugins.png",
        "url": "http://themeforest.net/item/beautiful-watercolor-hand-painted-creative-wordpress/14157442",
        "summary": "Widget Ready: Yes, Compatible Browsers: IE10, IE11, Firefox, Safari, Opera, Chrome, Edge, Compatible With: WooCommerce 2.4.x, Visual Composer 4.8.x, Software Version: WordPress 4.4.2, WordPress 4.4.1, WordPress 4.4, Columns: 2",
        "rating": 4.71,
        "rating_count": 7,
        "updated_at": "2016-03-02T03:00:00+11:00",
        "published_at": "2016-01-12T06:34:43+11:00",
        "trending": true,
        "attributes": [],
        "tags": [],
        "previews": {
          "live_site": {
            "href": "/item/beautiful-watercolor-hand-painted-creative-wordpress/full_screen_preview/14157442",
            "type": "live_site"
          },
          "icon_with_landscape_preview": {
            "icon_url": "https://0.s3.envato.com/files/164095185/creative-hand-drawn-watercolor-wordpress-theme.png",
            "landscape_url": "https://0.s3.envato.com/files/173394366/1.a-very-unique-handpainted-creative-WordPress-website-theme.__large_preview.png",
            "type": "icon_with_landscape_preview"
          },
          "landscape_preview": {
            "landscape_url": "https://0.s3.envato.com/files/173394366/1.a-very-unique-handpainted-creative-WordPress-website-theme.__large_preview.png",
            "type": "landscape_preview"
          },
          "icon_preview": {
            "icon_url": "https://0.s3.envato.com/files/164095185/creative-hand-drawn-watercolor-wordpress-theme.png",
            "type": "icon_preview"
          }
        },
        "wordpress_theme_metadata": {
          "theme_name": "Beautiful Watercolor",
          "author_name": "dtbaker",
          "version": "1.6.12",
          "description": "Beautiful Watercolor WordPress theme by dtbaker"
        }
      },
      "license": "Regular License",
      "support_amount": "0.00",
      "supported_until": "2016-07-19T00:21:08+10:00",
      "code": "e4e0942b-1212-1212-1212-121212121212"
    },
    {
      "amount": "58.00",
      "sold_at": "2014-11-14T08:19:32+11:00",
      "item": {
        "id": 123434344,
        "name": "name",
        "description": "desc",
        "site": "themeforest.net",
        "classification": "wordpress/ecommerce/woocommerce",
        "classification_url": "http://themeforest.net/category/wordpress/ecommerce/woocommerce",
        "price_cents": 5900,
        "number_of_sales": 513,
        "author_username": "dtbaker",
        "author_url": "http://themeforest.net/user/dtbaker",
        "author_image": "https://0.s3.envato.com/files/111547951/dtbaker-php-scripts-wordpress-themes-and-plugins.png",
        "url": "http://themeforest.net/item/boutique-kids-creative-wordpress-woocommerce/9367833",
        "summary": "High Resolution: Yes, Widget Ready: Yes, Compatible Browsers: IE9, IE10, IE11, Firefox, Safari, Opera, Chrome, Compatible With: WPML, WooCommerce 2.2.x, Software Version: WordPress 4.2, WordPress 4.1, WordPress 4.0, Columns: 2",
        "rating": 4.23,
        "rating_count": 22,
        "updated_at": "2016-03-01T08:50:52+11:00",
        "published_at": "2014-11-12T18:57:06+11:00",
        "trending": false,
        "attributes": [],
        "tags": [],
        "previews": {
          "live_site": {
            "href": "/item/boutique-kids-creative-wordpress-woocommerce/full_screen_preview/9367833",
            "type": "live_site"
          },
          "icon_with_landscape_preview": {
            "icon_url": "https://0.s3.envato.com/files/166458805/thumb_boutique.png",
            "landscape_url": "https://0.s3.envato.com/files/129807750/1.creative-kids-boutique-clothing-store-shop-woocommerce-wordpress-theme.__large_preview.jpg",
            "type": "icon_with_landscape_preview"
          },
          "landscape_preview": {
            "landscape_url": "https://0.s3.envato.com/files/129807750/1.creative-kids-boutique-clothing-store-shop-woocommerce-wordpress-theme.__large_preview.jpg",
            "type": "landscape_preview"
          },
          "icon_preview": {
            "icon_url": "https://0.s3.envato.com/files/166458805/thumb_boutique.png",
            "type": "icon_preview"
          }
        },
        "wordpress_theme_metadata": {
          "theme_name": "Boutique Kids",
          "author_name": "dtbaker",
          "version": "1.22",
          "description": "Boutique Kids WordPress Theme by dtbaker"
        }
      },
      "license": "Regular License",
      "support_amount": "0.00",
      "supported_until": null,
      "code": "e4e0942b-1212-1212-1212-121212121212"
    }
  ]
}

Hi @thenextsoft.

But i don’t expect the buyer to auth himself.
I just want to get buyer details when searching for its purchase code, but I’m not able to get those.
It’s strange, because the old API return those values.

Best regards and sorry for the late reply.

Somewhere on the API documentation page is a button to login and then enter a purchase code, it will show you your buyer’s details.

1 Like

Thanks @thenextsoft.
I’ve found that, and already managed to verify users.

Best regards.

Here is a free tool for Online Purchase Code Verifier by using Envato API.It will help you to save time. Free Envato Purchase Code Verify