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 6 replies - 16 through 21 (of 21 total)
  • @drazenbebic I have the same issues @luislpez mentioned in the above messages. Actually this plugin is not working fine. Admin can’t change the status of the key either.

    API is not working as expected. Seems like I have to find an another plugin which can do the job

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @geethuv and @luislpez

    sorry you are having this issue with my plugin. I will have another go at solving this problem this weekend. If you like, you can add me on discord (Zerrb#8676) so we can talk there.

    As for the “Admin can’t change the status of the key” part, this will be possible with the next update. I admit that this was an unnecessary bit of functionality which I added.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @geethuv and @luislpez,

    I think that I was finally able to reproduce the problem on my end! I will try to find a fix for this asap, will keep you posted.

    Thanks @drazenbebic,

    I will be attentive to your response.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @geethuv, @luislpez,

    I have found the source of the problem.

    Problem

    When performing certain API calls, the User ID of the API Key owner is used to update certain meta data (create_by and updated_by to be precise).

    To figure out the user ID, I use a function which matches the API credentials to the user. This part works flawlessly, the problem is the way the plugin obtains the API credentials.

    For this, the plugin uses the $_SERVER['PHP_AUTH_USER'] variable to obtain the consumer key. This does NOT work on PHP-CGI, which could be your PHP handler.

    You can read more about this here.

    Solution

    I have just uploaded a fix for this (plugin version 1.2.4). Please update your plugin and try again, it should work now.

    What does this fix do?

    This update changes the way the plugin REST API retrieves the consumer key. Instead of relying on the server configuration and the proper PHP handler, we are forcing the plugin to use the consumer_key we now provide explicitly.

    PS: @geethuv, @luislpez, it would help me tremendously if you took some time out of your day to write a plugin review here on WordPress. Those reviews really help spread the plugin and mean a lot to me personally.

    Hi @drazenbebic,

    The problem was solved!.

    Thanks.

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