SDK Integration
/
SDK Usage

SDK for WordPress Usage

To access to the SDK you can use the global variable from the snippet you created for your own plugin.

$my_license

Or by calling the custom method that will return SDK without creating it each time.

my_license()

Get a unique landing page URL for your product

$link = $my_license->purchase_link($plugin_slug);
// https://licensebridge.com/market/my-plugin

Check if the user has a license key

if ($my_license->license_exists($plugin_slug)) {
    // User have the license
}

Check if the license is active

if ($my_license->is_license_active($plugin_slug)) {
    // User license is active
}

Get a license details

$response = $my_license->license($plugin_slug);

Response can be false is license does not exist. Expected response is an array with license details:

array (size=13)
  'first_name' => string 'John' (length=11)
  'last_name' => string 'Doe' (length=10)
  'full_name' => string 'John Doe' (length=22)
  'email' => string '[email protected]' (length=20)
  'plan_type' => string 'month' (length=5)
  'plan_name' => string 'plan' (length=4)
  'charge_type' => string 'subscription' (length=12)
  'gateway' => string 'stripe' (length=6)
  'active' => boolean true
  'created_at' => string '01/27/2022 18:07:48' (length=19)
  'subscribed' => boolean true
  'cancelled' => boolean true
  'subscription' => 
    array (size=4)
      'stripe_id' => string 'sub_0KMcNuxCqoZozrbaG75rgcZs' (length=28)
      'stripe_customer_id' => string 'cus_L2hnYEuIw2p3pE' (length=18)
      'ends_at_formated' => string 'February 27, 2022' (length=17)
      'is_ended' => boolean false

Cancel the user license request

Sometimes, when the user is subscribed to your plugin, you can allow a user to cancel subscription to your plugin. This is how the user can cancel license subscription.

if ($my_license->cancel_license($plugin_slug)) {
    // User license is canceled
}