Helper function that let users check if license is valid
@param $license

@return array|mixed|\Psr\Http\Message\ResponseInterface
183459
public static function checkSubscription( $license ) {
		$response = self::client()->get( self::api_url() .'check-subscription', [ 'query' => [ 'license' => $license,  'Geot-Origin' => $_SERVER['HTTP_HOST'] ] ] );

		if( $response->getStatusCode() != '200')
			return json_encode(['error' => 'Something wrong happened'. strip_tags((string) $response->getBody())]);

		$response = (string)$response->getBody();
		return $response;
	}
1250968
function activate_license() {
		// listen for our activate button to be clicked.
		if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
			return;
		}
		$status = $this->get_license_status();
		// retrieve the license from the database.
		$license    = $_POST[ $this->product->get_key() . '_license' ];
		$api_params = array(
			'license'   => $license,
			'item_name' => rawurlencode( $this->product->get_name() ),
			'url'       => rawurlencode( home_url() ),
		);
		if ( 'valid' != $status ) {
			// data to send in our API request.
			$api_params['edd_action'] = 'activate_license';
		} else {
			$api_params['edd_action'] = 'deactivate_license';
		}
		// Call the custom API.
		$response = wp_remote_get( add_query_arg( $api_params, $this->get_api_url() ) );
		// make sure the response came back okay.
		if ( is_wp_error( $response ) ) {
			$license_data          = new \stdClass();
			$license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid';

		} else {
			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
			if ( ! is_object( $license_data ) ) {
				$license_data          = new \stdClass();
				$license_data->license = ( 'valid' != $status ) ? 'valid' : 'invalid';
			}
			if ( ! isset( $license_data->license ) ) {
				$license_data->license = 'invalid';
			}
		}
		if ( ! isset( $license_data->key ) ) {
			$license_data->key = $license;
		}
		if ( 'valid' == $license_data->license ) {
			$this->reset_failed_checks();
		}

		if ( isset( $license_data->plan ) ) {
			update_option( $this->product->get_key() . '_license_plan', $license_data->plan );
		}

		update_option( $this->product->get_key() . '_license_data', $license_data );
		set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );

	}
746944
function _get_subscription( $license_id ) {
            if ( ! isset( $this->_storage->subscriptions ) ||
                 empty( $this->_storage->subscriptions )
            ) {
                return null;
            }

            foreach ( $this->_storage->subscriptions as $subscription ) {
                if ( $subscription->license_id == $license_id ) {
                    return $subscription;
                }
            }

            return null;
        }
496989
public static function get($slug = null)
    {
        $licenses = self::getLicenseFile();
        $data = (array)$licenses->content();
        $licenses->free();
        $slug = strtolower($slug);

        if (!$slug) {
            return $data['licenses'] ?? [];
        }

        return $data['licenses'][$slug] ?? '';
    }
638724
function _get_license_by_id( $id, $sync_licenses = true ) {
            $this->_logger->entrance();

            if ( ! FS_Plugin_License::is_valid_id( $id ) ) {
                return false;
            }

            /**
             * When running from the network level admin and opted-in from the network,
             * check if the license exists in the network user licenses collection.
             *
             * @author Vova Feldman (@svovaf)
             * @since  2.0.0
             */
            if ( fs_is_network_admin() &&
                 $this->is_network_registered() &&
                 ( ! is_object( $this->_user ) || $this->_storage->network_user_id != $this->_user->id )
            ) {
                $licenses = $this->get_user_licenses( $this->_storage->network_user_id );

                foreach ( $licenses as $license ) {
                    if ( $id == $license->id ) {
                        return $license;
                    }
                }
            }

            if ( ! $this->has_any_license() && $sync_licenses ) {
                $this->_sync_licenses( $id );
            }

            if ( is_array( $this->_licenses ) ) {
                foreach ( $this->_licenses as $license ) {
                    if ( $id == $license->id ) {
                        return $license;
                    }
                }
            }

            return false;
        }
1222718
public function verifyRequest($request)
    {
        $this->getVersion($request);
        $consumer = $this->getConsumer($request);
        $token = $this->getToken($request, $consumer, "access");
        $this->checkSignature($request, $consumer, $token);
        return array($consumer, $token);
    }
672919
private function fetch_license_by_key( $license_id, $license_key ) {
            $this->_logger->entrance();

            $api = $this->get_current_or_network_user_api_scope();

            $result = $api->get( "/licenses/{$license_id}.json?license_key=" . urlencode( $license_key ) );

            return $this->is_api_result_entity( $result ) ?
                new FS_Plugin_License( $result ) :
                $result;
        }
1343701
public function update_license( $license, $keep_status = false ) {
		$option   = get_option( 'sekisyo_license', [] );
		$validity = $this->validate( $license );
		$failed   = $this->failed;
		if ( is_wp_error( $validity ) ) {
			$failed ++;
		} else {
			$failed = 0;
		}
		$prev_status           = $this->valid;
		$cur_status            = is_wp_error( $validity ) ? false : true;
		$option[ $this->guid ] = [
			'license'      => $license,
			'valid'        => ( $keep_status && ! $cur_status ) ? $prev_status : $cur_status,
			'last_checked' => current_time( 'mysql', true ),
			'failed'       => $failed,
		];
		update_option( 'sekisyo_license', $option );

		return is_wp_error( $validity ) ? $validity : true;
	}
276447
private function validate(array $options)
    {
        if (array_key_exists('mandatorId', $options)) {
            $options['mandatorId'] = (int) $options['mandatorId'];
        }

        list($customerId, $licenseKey) =
            $this->siteAccessHelper->getRecommendationServiceCredentials($options['mandatorId'], $options['siteaccess']);

        $options = array_filter($options, function ($val) {
            return $val !== null;
        });

        $resolver = new OptionsResolver();
        $resolver->setRequired(['contentTypeIdList', 'host', 'webHook', 'transaction']);
        $resolver->setDefined(array_keys($options));
        $resolver->setDefaults([
            'transaction' => (new \DateTime())->format('YmdHis') . rand(111, 999),
            'customerId' => $customerId,
            'licenseKey' => $licenseKey,
            'mandatorId' => null,
            'siteaccess' => null,
            'lang' => null,
        ]);

        return $resolver->resolve($options);
    }
1192220
public function getLicenseByIdentifier($identifier)
    {
        if (!isset($this->licenses[$identifier])) {
            return;
        }

        $license = $this->licenses[$identifier];

        // add URL for the license text (it's not included in the json)
        $license[2] = 'http://spdx.org/licenses/' . $identifier . '#licenseText';

        return $license;
    }
825089
public function get_license_status() {

		$license_data = get_option( $this->product->get_key() . '_license_data', '' );

		if ( '' === $license_data ) {
			return get_option( $this->product->get_key() . '_license_status', 'not_active' );
		}

		return isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' );

	}
189548
public function license_view() {
		$status = $this->get_license_status();
		$value  = $this->license_key;

		$activate_string   = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
		$deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
		$valid_string      = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
		$invalid_string    = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
		$license_message   = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );

		echo '<p ><input ' . ( ( 'valid' === $status ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( 'valid' === $status ) ? ( 'style="color:#fff;background:  #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px;  -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background:  #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px;  -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( 'valid' === $status ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a  href="' . $this->get_api_url() . '">' . $this->get_distributor_name() . '</a> ', $this->product->get_type() ) . '</p>';

	}
296411
private function _fetch_site_license_subscription( $license_id = false ) {
            $this->_logger->entrance();
            $api = $this->get_api_site_scope();

            if ( ! is_numeric( $license_id ) ) {
                $license_id = $this->_license->id;
            }

            $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );

            return ! isset( $result->error ) ?
                ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
                    new FS_Subscription( $result->subscriptions[0] ) :
                    false
                ) :
                $result;
        }
900554
function has_features_enabled_license() {
            return (
                is_object( $this->_license ) &&
                is_numeric( $this->_license->id ) &&
                $this->_license->is_features_enabled()
            );
        }
1188795
public function isPremium( $product ) {
		$isPremium = isset( $this->getData()->$product );

		$this->licenseString = $isPremium ?
			__( 'Premium', 'boldgrid-connect' ) : __( 'Free', 'boldgrid-library' );

		return $isPremium;
	}
1293596
function is_valid_license( $license ) {
		try {
			$response = GeotargetingWP::checkLicense( $license );
			$result   = json_decode( $response );
			// update license
			if ( isset( $result->success ) ) {
				update_option( 'geot_license_active', 'valid' );
			} else {
				delete_option( 'geot_license_active' );
			}
		} catch ( \Exception $e ) {
			return \GuzzleHttp\json_encode( [ 'error' => $e->getMessage() ] );
		}

		return $response;
	}
458122
function has_any_active_valid_license() {
            if ( ! fs_is_network_admin() ) {
                return $this->has_active_valid_license();
            }

            $installs            = $this->get_blog_install_map();
            $all_plugin_licenses = self::get_all_licenses( $this->_module_id );

            foreach ( $installs as $blog_id => $install ) {
                if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) {
                    continue;
                }

                foreach ( $all_plugin_licenses as $license ) {
                    if ( $license->id == $install->license_id ) {
                        if ( self::is_active_valid_license( $license ) ) {
                            return true;
                        }
                    }
                }
            }

            return false;
        }