How to verify purchase using Purchase Code using new API

tips-and-tricks
envato-api
#1

Hello,
I am an Android Developer.
I tried a lot but didn’t found any way to verify purchase using the new API. I can’t ask users to log in because it will be useless in Java projects.
I want users to enter the purchase code, then it will be compiled. After that, the app will check if the Purchase code is valid or not. If not then don’t stop there.
I already saw this post but it will not work in my case Verify Purchase API Response Example

#2

You can’t do this, you must provide your full source code and compiled app without any purchase verification. They’re working on a help article to explain this, but in the meantime you can look at this rejection message.

#3

Hey,

I do not think you can make the compiler to first ask code that is against the Envato rules, but it also against any idea on how things work.
Compiler can not work by connecting to an API first, except if you make an online generator of your code

1 Like
#4

@baileyherbert I am giving the full source code to the buyers. All I want them is to paste in their purchase code inside my application and compile it. Then the app will check the purchase code and then decide what to do next.
Hope you get it @creativeGagency

#5

You’ll need your own server to do the verification, otherwise it’s insecure. You can verify a purchase code at this URL:

https://api.envato.com/v3/market/author/sale?code=a00a3c11-4931-4a34-9a61-0314e6534ad5

  • You should pass an Authorization header like this: Authorization: Bearer <token>

  • You can retrieve your <token> at https://build.envato.com/my-apps/ (make sure you make a Personal token app, at the very bottom of the page, and give it “Verify purchases of your items” permission).

Example response for a valid purchase code (HTTP 200 OK):

{
  "amount": "16.00",
  "sold_at": "2016-08-09T10:13:26+10:00",
  "item": {
    "id": 17022701,
    "name": "Item name...",
    "description": "Item description in HTML form...",
    "site": "codecanyon.net",
    "classification": "php-scripts/project-management-tools",
    "classification_url": "https://codecanyon.net/category/php-scripts/project-management-tools",
    "price_cents": 2400,
    "number_of_sales": 282,
    "author_username": "baileyherbert",
    "author_url": "https://codecanyon.net/user/baileyherbert",
    "author_image": "https://s3.envato.com/files/231789931/logo_rd_blue-80px.png",
    "url": "https://codecanyon.net/item/seo-studio-professional-tools-for-seo/17022701",
    "summary": "High Resolution: Yes, Software Version: PHP 7.x, PHP 5.4, PHP 5.5, PHP 5.6, MySQL 5.x",
    "rating": 4.45,
    "rating_count": 22,
    "updated_at": "2016-07-22T16:58:54+10:00",
    "published_at": "2016-07-13T19:07:03+10:00",
    "trending": false
  },
  "license": "Regular License",
  "support_amount": "0.00",
  "supported_until": "2018-02-07T02:13:26+11:00",
  "buyer": "collis",
  "purchase_count": 1
}

If the purchase code is invalid, the page returns 404 Not Found error code, and will look like this:

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