Support » Plugin: License Manager for WooCommerce » Error on License key activation

  • First of all, thanks for this wonderful. I used this to manage license key for my Woocommerce downloadable products. Plugin side is working fine though.

    In the product end(which is a plugin itself) I need to validate the license key and activate it. I used the following lines of code for the same.

    //To Validate

    $cmd='curl --location --request GET "https://mysite.com/wp-json/lmfwc/v1/licenses/validate/2?consumer_key=ck_5f3e6a4418ea9e02fbd121182676f7720&consumer_secret=cs_2db507222ecfdc7e68b3de594a99dff86c7c" \
      --header "Content-Type: application/json" \ 
      --data "{
    	\"order_id\": null,
    	\"product_id\": null,
    	\"license_key\": \"EDITED_API_KEY_AGAIN\",
    	\"valid_for\": null,
    	\"status\": \"active\"
    }"';
    exec($cmd,$result);

    //To Activate

    $cmd1='curl --location --request PUT "https://mysite.com/wp-json/lmfwc/v1/licenses/activate/2?order_id=48&product_id=42&updated_by=2&consumer_key=ck_5f3e6a49e02bcad6d2fbd121182676f7720&consumer_secret=cs_2db5060ab7222ecfdc7e68b94a99dff86c7c" \
      --header "Content-Type: application/json" \
      --data "{
    	\"order_id\": null,
    	\"product_id\": null,
    	\"license_key\": \"EDITED_API_KEY_AGAIN\",
    	\"valid_for\": null,
    	\"status\": \"active\"
    }"'; 
    exec($cmd1,$result1);

    Validation code is working fine. But the Activation part throws error. Could you please let me know the parameters should I pass with this query?

    Why I am getting this error?

    Array ( [0] => {“code”:”lmfwc_rest_data_error”,”message”:”Updated by User ID is invalid”,”data”:{“status”:404}} )

    Waiting for your reply

Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @geethuv,

    thank you for your message and for using my plugin!

    When you perform that action, a the “edited_at” and “edited_by” database columns get updated for that specific key. The “edited_at” is a simple timestamp, “edited_by” is the WordPress User ID of the REST API Key owner. The API checks if the user still exists before performing the changes. Could it be that the owner no longer exists/has been deleted?

    PS: As you know, I’m currently on vacation until the 13th of May, so replies might take longer than usual.

    Hi @drazenbebic ,

    Thanks for the quick response. I have REST API and the site admin is the owner with ID 1. So the code to activate the key I have in the client side is as follows

    echo "<h1>Activate license </h1>";
    $cmd1='curl --location --request PUT "https:/mysite.com/wp-json/lmfwc/v1/licenses/activate/2?license_key=LBDL55-U5U-2L2-UJ1&order_id=48&product_id=42&updated_by=1&consumer_key=ck_5f3e6a4418ea9e02bcad6d2fbd121182676f7720&consumer_secret=cs_2db5060ab7222ecfdc7e68b3de594a99dff86c7c" \
      --header "Content-Type: application/json" \
      --data "{
    	\"order_id\": null,
    	\"product_id\": null,
    	\"license_key\": \"LBDL55-U5U-2L2-UJ1\",
    	\"valid_for\": null,
    	\"status\": \"active\"
    }"'; 
    exec($cmd1,$result1);

    Where,

    And the result I got is

    Array ( [0] => {“code”:”lmfwc_rest_data_error”,”message”:”Updated by User ID is invalid”,”data”:{“status”:404}} )

    Could you please check the code I have pasted above?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Seems a bit odd, I will check this as soon as I get back from vacation.

    @drazenbebic

    Whether I need to add any other code/file into my product (plugin)? Did I missed any other steps?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    I’m sorry but I really do not know until I try it out myself. I will let you know as soon as I get back from my vacation. I do not have my development PC with me here.

    Hi @drazenbebic ,

    Hope you are back on work. Could you please check the issue I have mentioned in this thread. I was waiting for your reply

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @geethuv,

    sorry for the late reply, a lot of work has accumulated at the office while I was on vacation 🙂

    I will check this out tomorrow and let you know if I can find anything. I also saw your other post, I’ll check that out too.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hey @geethuv,

    I could not recreate this problem either on my end. If you can, please send me the PHP error logs so that I can try to make sense of it.

    Hi @drazenbebic,

    I have the same problem. I cannot be able to activate the license key. It’s possible that API documentation is omitting something?.

    Hope you help us!

    Thanks.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @luislpez,

    could you send me your PHP error logs or show me what code you used to make the request?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    I did some digging.

    For activating a license key, you need a PUT request without any additional parameters in the body. For example

    GET http://dev.wordpress.local/wp-json/lmfwc/v1/licenses/activate/4?consumer_key=ck_bf79a4fb9f2a00a0d40256747cf9f13e81a3a5a7&consumer_secret=cs_4b5e89530e140be6cb7b9b220efb9f0b8fb45d3c

    This should increment the times_activated value (if possible) and return a response which looks like this:

    {
        "success": true,
        "data": {
            "id": "4",
            "order_id": null,
            "product_id": "1777",
            "license_key": "API-LICENSE-KEY",
            "expires_at": null,
            "valid_for": "180",
            "source": "3",
            "status": "3",
            "times_activated": "4",
            "times_activated_max": "5",
            "created_at": "2019-05-27 21:07:36",
            "created_by": "1",
            "updated_at": "2019-05-27 21:16:07",
            "updated_by": "1"
        }
    }

    I

    Thanks for your response,

    I follow your recomendation and get the same error.

    {
        "code": "lmfwc_rest_data_error",
        "message": "Updated by User ID is invalid",
        "data": {
            "status": 404
        }
    }

    This is my PUT request:

    
    http://68.183.122.165/wp-json/lmfwc/v1/licenses/activate/4?consumer_key=ck_0ba85ceb51ffd67068c455f2122a7c5121eca94e&consumer_secret=cs_e1f857010067a757877ce1843e7894e7a9df7a04
    

    If I do the validation GET request:

    
    http://68.183.122.165/wp-json/lmfwc/v1/licenses/validate/3?consumer_key=ck_0ba85ceb51ffd67068c455f2122a7c5121eca94e&consumer_secret=cs_e1f857010067a757877ce1843e7894e7a9df7a04
    

    The server return:

    
    {
        "success": true,
        "data": {
            "times_activated": 0,
            "times_activated_max": 1,
            "remaining_activations": 1
        }
    }
    

    The license status is Delivered in License Manager Plugin.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Could you try please try this out with a new API Key?

    @drazenbebic

    I have created two new api keys and get the same result.

    
    consumer_key = ck_5f0bb55fe4fa64abe7dfe158de3c27913ea7148d
    consumer_secret = cs_2cee275578b50486ea832252fb3bf47d0da18bcf
    
    
    consumer_key = ck_b231bbb34c158cca68fc1e79e07a9e1da16a6c53
    consumer_secret = cs_c768557a68fe28251e23ccfea692f7a57575ee09
    

    Thanks you!

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @luislpez,

    I’ll try to recreate the problem when I get home after work and let you know!

Viewing 15 replies - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.