Authors validating item license using Market Api

Codewigs Reps

To validate an item license you will need to send a CURL request to our api endpoin: https://www.codewigs.com/api/v1/validate_item_liecense

The above endpoint can only be acess via the POST request. Below are the information you need to pass in.

API request value
Keys Values Descriptions
public_key Market api bublic key This is the key you coppy for your settings as public key
license_code Item license code Requst item license code for the user to validate item
buyer_username user account username This is the correct codewigs account username of the user

 

After collecting the post value you can easily pass it the the CURL request:

CURL Example:

curl --location --request POST 'https://www.codewigs.com/api/v1/validate_item_liecense' \
--header 'Content-Type: application/json' \
--form 'public_key="cw_pubkey_10b91950cf19659fa277c54436dd55518b88cb0939db3ed595293216cceb34ffd"' \
--form 'license_code="33497R40MWxjyjYgzM7RsNX7v"' \
--form 'buyer_username="root"'

 

NodeJs Example

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://www.codewigs.com/api/v1/validate_item_liecense',
'headers': {
'Content-Type': 'application/json'
},
formData: {
'public_key': 'cw_pubkey_10b91950cf19659fa277c54436dd55518b88cb0939db3ed595293216cceb34ffd',
'license_code': '33497R40MWxjyjYgzM7RsNX7v',
'buyer_username': 'root'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

 

Pyton Example:

import requests
url = "http://www.codewigs.com/api/v1/validate_item_liecense"
payload={'public_key': 'cw_pubkey_10b91950cf19659fa277c54436dd55518b88cb0939db3ed595293216cceb34ffd',
'license_code': '33497R40MWxjyjYgzM7RsNX7v',
'buyer_username': 'root'}
files=[
]
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)

 

PHP Example:

<?php

$reuest = [
            'public_key' => 'cw_pubkey_10b91950cf19659fa277c54436dd55518b88cb0939db3ed595293216cceb34ffd',
            'license_code' => '33497R40MWxjyjYgzM7RsNX7v',
            'buyer_username' => 'root'
        ];

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://www.codewigs.com/api/v1/validate_item_liecense',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($request),
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

 

Our endpoint will return a json reponse.

Error Response(Failed) usually use 400 error code

{
    "status": 400,
    "error": "Invalid license code",
    "messages": {
        "error": "The provided liecense code is not valid"
    }
}

 

Sucess Response type (Verification Success)

{
"status": 201,
"response": "success",
"message": "License code has been activated",
"data": {
"message": "License code has been validated successfully",
"item_name": "Litemag - Self hosted php script",
"item_prices": {
"regular": "60.00",
"extended": "200.00",
"currencey": "USD"
},
"license_paid": {
"type": "extend",
"price": "200.00",
"currency": "USD"
}
},
"purchase_date": "Dec 7, 2020",
"support_expire": "Jun 7, 2021"
}

 

Once our endpont report a 201 status request the mean the verification was successfully and the liecense has been validated!

Was this article helpful?

Yes No

Thanks so much for your feedback!

Have more questions? Ask Our Community

Support