SDK for WordPress Usage
Access the SDK via the integration snippet you created:
$bridge = my_license();
$slug = plugin_basename(__FILE__);
Or call your helper function directly:
my_license()->purchase_link(plugin_basename(__FILE__));
Get a unique landing page URL for your product
$link = $bridge->purchase_link($slug);
// https://licensebridge.com/market/my-first-product?callback_url=...
Use in a button:
echo '<a href="' . esc_url($link) . '">Buy Premium</a>';
The SDK builds and URL-encodes the callback URL automatically — you do not need to construct it manually.
Use purchase_link() for hosted checkout: marketing pages, the frontend, PayPal, or when you prefer the License Bridge landing page.
Inline checkout in wp-admin
SDK 2.0+ lets you collect billing details and accept Paddle or Stripe payments inside WordPress admin, without redirecting to the hosted market page.
PayPal is not supported in the inline modal — use purchase_link() for PayPal (hosted redirect).
When a customer clicks your checkout button, the SDK opens a billing modal in wp-admin. The order summary shows the selected plan, billing cycle, price, and trial info when applicable. After billing details are submitted, Paddle opens its overlay or Stripe collects the card inside the modal.
Checkout flow
Shared flow for Paddle and Stripe:
- Render
checkout_button()on a wp-admin page only (returns an empty string on the frontend). - Customer clicks the button → billing modal opens.
- SDK loads plan/pricing from License Bridge (
GET /product-price-info/{product}), proxied through WordPress AJAX (lb_checkout_plans). - Customer enters billing details (name, email, address). Order summary shows plan, billing cycle, price, and trial info when applicable.
- Customer submits → SDK POSTs to License Bridge (
POST /charge/{product}/{gateway}/{planSlug}) via WordPress AJAX (lb_checkout_init). - Paddle: modal closes → Paddle Billing v2 overlay opens → on
checkout.completed, customer is redirected to the success URL (same post-purchase callback as hosted checkout). - Stripe: card is tokenized client-side → token sent to the API → on success, customer is redirected (or checkout completes in the modal).
- Post-purchase flow is unchanged: License Bridge redirects to wp-admin, SDK stores credentials, runs premium upgrade if applicable, then redirects to
plugins.php?license_upgraded=1orplugins.php?license_saved=1.
Payment secrets never touch the WordPress site — WordPress AJAX proxies requests server-side.
Fixed plan (Paddle)
echo my_license()->checkout_button($slug, [
'plugin-file' => __FILE__,
'gateway' => 'paddle',
'plan-slug' => 'pro',
'plan-type' => 'annual',
'label' => 'Upgrade to Pro',
]);
Fixed plan (Stripe)
echo my_license()->checkout_button($slug, [
'plugin-file' => __FILE__,
'gateway' => 'stripe',
'plan-slug' => 'pro',
'plan-type' => 'life',
'label' => 'Upgrade to Pro',
]);
Plan selection by customer
echo my_license()->checkout_button($slug, [
'plugin-file' => __FILE__,
'gateway' => 'stripe',
'allow-plan-selection' => true,
]);
checkout_button() config reference
| Key | Required | Default | Description |
|---|---|---|---|
plugin-file | Yes (for assets) | from Loader::register() if set | Main plugin file path (__FILE__) so the SDK loads CSS/JS from vendor/license-bridge/wordpress-sdk/assets |
gateway | No | paddle | paddle or stripe |
plan-slug | Conditional | — | Required unless allow-plan-selection is true |
plan-type | No | inferred from API | month, annual, or life |
allow-plan-selection | No | false | Show plan and billing-cycle dropdowns |
show-order-summary | No | true | Show order summary panel in the modal |
label | No | Buy Premium | Button text |
Important: Inline checkout works only in wp-admin (is_admin()). On the frontend, checkout_button() returns an empty string. Pass plugin-file when the SDK is installed via Composer so asset URLs resolve correctly. Multiple buttons on the same page are supported (each can use a different gateway or plan). Hosted checkout remains available via purchase_link().
See the example plugin for live Paddle and Stripe button examples, and the SDK README on GitHub.
Gateway comparison
| Gateway | Inline modal | Hosted redirect | Card entry location |
|---|---|---|---|
| Paddle | Yes | Yes (via purchase_link()) | Paddle overlay (after billing form) |
| Stripe | Yes | Yes (via purchase_link()) | Stripe Elements inside modal |
| PayPal | No | Yes (via purchase_link()) | PayPal hosted page |
When to use inline vs hosted checkout
Use inline (checkout_button()) | Use hosted (purchase_link()) |
|---|---|
| Upgrade prompts in plugin settings | Marketing site or frontend |
| License screens in wp-admin | PayPal checkout |
| In-admin upgrade nudges | When you prefer the License Bridge landing page |
For dashboard prerequisites and troubleshooting, see Inline checkout setup.
Check if the user has a license key
if ($bridge->license_exists($slug)) {
// License credentials stored locally
}
Check if the license is active
if ($bridge->is_license_active($slug)) {
// Active license on License Bridge
}
Get license details
$response = $bridge->license($slug);
Returns false if no license exists. Otherwise returns 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
When a user is subscribed to your plugin, you can let them cancel from your plugin UI:
if ($bridge->cancel_license($slug)) {
// Subscription cancelled on License Bridge
}
Post-purchase redirect
After checkout, License Bridge redirects the customer to your WordPress admin. The SDK:
- Verifies the nonce
- Stores
lk,client_id, andclient_secret - Runs premium plugin upgrade (if a newer package is available)
- Redirects to the Plugins screen with one of these query args:
wp-admin/plugins.php?license_upgraded=1— premium upgrade ranwp-admin/plugins.php?license_saved=1— license saved, no newer version to install
Show admin feedback after redirect:
add_action('admin_notices', function () {
if (isset($_GET['license_upgraded'])) {
echo '<div class="notice notice-success"><p>Premium activated.</p></div>';
}
if (isset($_GET['license_saved'])) {
echo '<div class="notice notice-success"><p>License saved.</p></div>';
}
});
The premium version on License Bridge must be higher than the installed free version for auto-upgrade to run after purchase.
Hooks
Run custom logic before or after the post-purchase upgrade:
apply_filters('before_upgrade_plugin_' . $plugin_slug, '');
apply_filters('after_upgrade_plugin_' . $plugin_slug, '');
Replace $plugin_slug with your plugin-slug value from Loader::register().