601 posts
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Most Wanted Bounty Winner
  • Interviewed on the Envato Notes blog
  • Referred between 50 and 99 users
  • Bought between 50 and 99 items
  • Microlancer Beta Tester
  • Exclusive Author
  • Has been a member for 2-3 years
UBLThemes says

Hi, guys…

I know the question about getting the verification code from the envato api has been raised a few times recently.

But i was wondering if anyone who has implemented this can tell me if this is about spot on or if it will throw errors.

I cant test it because i have no verification codes for my own items.

Here is the code:

$myusername = 'MY PERSONAL USERNAME FROM ENVATO';
        $myapi = 'MY API KEY FROM ENVATO';

        $apiurl = 'http://marketplace.envato.com/api/edge/' . $myusername . '/' . $myapi . '/verify-purchase:' . $verification . '.json';

        $cinit = curl_init($apiurl);
        curl_setopt($cinit, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($cinit, CURLOPT_RETURNTRANSFER, true);
        $cinit_data = curl_exec($cinit);
        curl_close($cinit);

        $verification_data = json_decode($cinit_data, true);

        if(empty($verification_data['verify-purchase'])){
            $errors[] = 'Sorry your verification code is not correct, we can not support you with out the relevant information!';
        } else { // do something
}

When running the code it comes back with the error variable which was expected as i do not have the purchase verification code.

I can not see if it comes back true if there is a verification code though.

2823 posts
  • Australia
  • Community Moderator
  • Elite Author
  • Author had a Free File of the Month
  • Most Wanted Bounty Winner
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Contributed a Blog Post
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+10 more
dtbaker Volunteer moderator says

yer should be right, just put some debugging in there eg:

mail('you@example.com','Verify purchase debugging!',$verification."\n".var_export($verification_data,true));

then when you get a real user you will get their code and see if it works or not.

601 posts
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Most Wanted Bounty Winner
  • Interviewed on the Envato Notes blog
  • Referred between 50 and 99 users
  • Bought between 50 and 99 items
  • Microlancer Beta Tester
  • Exclusive Author
  • Has been a member for 2-3 years
UBLThemes says

yer should be right, just put some debugging in there eg:
mail('you@example.com','Verify purchase debugging!',$verification."\n".var_export($verification_data,true));
then when you get a real user you will get their code and see if it works or not.

Thanks for the reply, most appreciated :)

by
by
by
by
by
by