2229 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+11 more
revaxarts
says

you have to explain them how to obtain the purchase code as well and the value is different for each purchase. On the other hand, the api key only has to be generated once and then it works for any theme.

I also assume the purchase verify is done on the update server or else it would be possible to bypass the check and obtain a download link without a purchase code. Even by caching the result, there’s still the possibility to hit the api limit.

BF

Since most buyers only purchase one item this doesn’t matter imo. If they purchase more than one each theme offers a different way to enter the credentials so it’s still confusing.

Purchase code is like a license key for software which is more common. Many do not even know what an API is.

Also the lack of support of WP plugins demands for a custom solution. I can also limit the amount of domains the plugin is used (regular license) which isn’t possible with the “native” method.

501 posts
  • Has referred 1000+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 more
pixelentity
says

Also the lack of support of WP plugins demands for a custom solution. I can also limit the amount of domains the plugin is used (regular license) which isn’t possible with the “native” method.
I can understand the choice for plugins because currently there’s no other way to give buyers auto updates.

It would be much simpler if envato would just do for plugins what they did for themes. This would allow buyers to just configure their api key once per installation and being able to update all items purchased from TF/CC at once in the same way as they do for theme/plugins installed from wp.org

About the domain check, that’s really another subject.

BF

4 posts
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 4 years
  • Located in Greece
themesic
says

On every new download, after the users install a script, is there a way to “activate it” for the first time by entering a purchase id that will be confirmed with envato and if it will fails the script wont unlock?

202 posts Quality Templates
  • Has referred 50+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 more
ThemeRox
says

Seems problem in first code example failed to open stream: HTTP request failed! HTTP/1.1 422 Unprocessable Entity

58 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Has been part of the Envato Community for over 2 years
+1 more
kluska
says

Basing of all your previous code, and on fact that envato security now require API requests to have user-agent set – I’ve made this class and simple method that seems to work.

class Envato {

    public static function verifyPurchase($userName, $apiKey , $purchaseCode, $itemId = false) {

        // Open cURL channel
        $ch = curl_init();

        // Set cURL options
        curl_setopt($ch, CURLOPT_URL, "http://marketplace.envato.com/api/edge/$userName/$apiKey/verify-purchase:$purchaseCode.json");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERAGENT, 'ENVATO-PURCHASE-VERIFY'); //api requires any user agent to be set

        // Decode returned JSON
        $result = json_decode( curl_exec($ch) , true );

        //check if purchase code is correct
        if ( !empty($result['verify-purchase']['item_id']) && $result['verify-purchase']['item_id'] ) {
            //if no item name is given - any valid purchase code will work
            if ( !$itemId ) return true;
            //else - also check if purchased item is given item to check
            return $result['verify-purchase']['item_id'] == $itemId;
        }

        //invalid purchase code
        return false;

    }

}
by
by
by
by
by
by