Selling license keys is very easy using Payhip.

You simply setup a product as usual then you click advanced options and simply click the checkbox to generate a license key every time a customer purchases your product. Make sure you save your changes.

License key enforcement is completely up to you. As the seller, you can decide how many uses each key gets. We have two simple API calls for you to achieve this.

License Key Verification

To verify a license key in your application simply call the verify API method.

Example Request

curl https://payhip.com/api/v1/license/verify?product_link=mVT0&license_key=WTKP4-66NL5-HMKQW-GFSCZ 
  \ -X GET 
  \ --header "payhip-api-key: YOUR_API_KEY_HERE"

Example Response

{
  "data": {
    "enabled": true,
    "product_link": "mVT0",
    "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
    "buyer_email": "contact@payhip.com",
    "uses": 0,
    "date": "2018-02-22T11:23:05+00:00"
  }
}

If verification fails, you will receive an empty response.

Enable or Disable a License Key

To enable a license key you can use the endpoint “license/enable” or to disable, use the endpoint “license/disable”. You might want to disable a license key after a buyer asks for a refund for example.

Example Request

curl https://payhip.com/api/v1/license/disable 
  \ -d "product_link=mVT0" 
  \ -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" 
  \ -X PUT 
  \ --header "payhip-api-key: YOUR_API_KEY_HERE"

Example Response

{
  "data": {
    "enabled": false,
    "product_link": "mVT0",
    "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
    "buyer_email": "contact@payhip.com",
    "uses": 1,
    "date": "2018-02-22T11:23:05+00:00"
  }
}

License Key Usage

To increase the license keys usage, simply call the usage endpoint

Example Request

curl https://payhip.com/api/v1/license/usage 
  \ -d "product_link=mVT0" 
  \ -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" 
  \ -X PUT 
  \ --header "payhip-api-key: YOUR_API_KEY_HERE"

Example Response

{
  "data": {
    "enabled": true,
    "product_link": "mVT0",
    "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
    "buyer_email": "contact@payhip.com",
    "uses": 1,
    "date": "2018-02-22T11:23:05+00:00"
  }
}

If usage update fails, you will receive an empty response.

Key Note

You can find your API KEY in Account > Settings > Developer.