Support » Plugin: License Manager for WooCommerce » Extra information for license keys

  • Resolved stijnb12345

    (@stijnb12345)


    Hello there,

    Is it possible to add extra information to a license key? I want to check the license, and if the IP and Port are correct.

    So, at the activation, I need to give the API an IP and port, and then at validation I need to check if that IP and port are correct.

    So, I need something like an instance.

    Is this possible?

    Thanks in advance!

    Kind regards,

    Stijn

Viewing 13 replies - 16 through 28 (of 28 total)
  • Plugin Author Drazen Bebic

    (@drazenbebic)

    @stijnb12345

    Honestly, I don’t know 🙂 Give it a go and see how it turns out.

    stijnb12345

    (@stijnb12345)

    {"code":"lmfwc_rest_data_error","message":"License Key invalid.","data":{"status":404}}

    I get this error when I go to /lmfwc/v2/licenses/activate/KEY

    The KEY is correct and not activated yet.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    It must be the $licenseKey variable inside the filter. You need to debug to see if you’re getting anything in there.

    stijnb12345

    (@stijnb12345)

    I will debug it today.

    If you still need any translators for nl_NL (Dutch), I’m here to help you with the translations.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @stijnb12345,

    hope you had a merry xmas 🙂

    Yes, I would absolutely love to take you up on that translation offer, thank you very much!

    I see that you’ve already contributed to a couple of translations, they haven’t been approved by the nl_NL community yet. I have to ask: would you like to become a Project Translation Editor (PTE for short) for this plugin? If you were a plugin PTE, you could manage all the nl_NL translations for the plugin, and approve them right away yourself.

    Please let me know either way 🙂

    stijnb12345

    (@stijnb12345)

    Hope you had a merry Christmas too!

    Yeah, I like to be a PTE.

    stijnb12345

    (@stijnb12345)

    $licenseKey = sanitize_text_field($request->get_param('license_key'));

    This line at the lmfwc_rest_api_validation filter is null, what is wrong?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @stijnb12345

    great, I will make the PTE request soon!

    The route isn’t really using any query or body parameters, so that probably is the reason it fails. You’ll have to extract the license key from the $request->get_route() method instead. This route will return something like: v2/licenses/YOUR-LICENSE-KEY. I’d recommend using a regular expression to match the pattern and extract the license key. You could also do explode('/', $request->get_route()) and check the array contents.

    stijnb12345

    (@stijnb12345)

    /** @var \LicenseManagerForWooCommerce\Models\Resources\License $license */
    $license = \LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->findBy(
        array(
            'license' => apply_filters('lmfwc_hash', $licenseKey)
        )
    );
    
    if ($license) {
        $licenseId = $license->getId();
    } else {
        return new WP_Error(
            'lmfwc_rest_data_error_12',
            'License Key ID invalid.',
            array('status' => 404)
        );
    }

    Now I get the lmfwc_rest_data_error_12 error. The License key is now correct.

    stijnb12345

    (@stijnb12345)

    Fixed that issue, but the instance is still not added at activation.

    stijnb12345

    (@stijnb12345)

    Okay, at the lmfwc_rest_api_pre_response filter, how to get the key from the URL?

    $route returns:

    Array
    (
        [0] => v2
        [1] => licenses
        [2] => {license_key}
    )
    stijnb12345

    (@stijnb12345)

    Fixed it. I’m now using the $data variable, and get it from there.

    Thanks for your help! It’s working now.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @stijnb12345

    Great job! I’m glad you worked it out 🙂

    If I can help with anything else, do let me know.

    PS: I would also be extremely thankful if you could take some time out of your day to write a plugin review here on WordPress.org. These reviews really help the plugin to grow and mean a lot to me personally. Here’s the link:

    https://wordpress.org/support/plugin/license-manager-for-woocommerce/reviews/#new-post

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