Sell on WooCommerce with license keys
For WordPress sellers with their own WooCommerce shop: the paid "Pro" version of a plugin, a game, an app or a bot. Every paid order gets a SunLicense key, buyers see it in the shop, and a refund revokes it.
There are two ways to connect. Both use the same integration, so you can switch at any time:
| Plugin (recommended) | Webhook only | |
|---|---|---|
| Setup | Install SunLicense for WooCommerce, paste two values | Add a WooCommerce webhook by hand |
| Buyers get the key | On the thank-you page, in My account → License keys, in WooCommerce's order emails, and by our key email | By our key email and the redeem page |
| Which products | The ones you tick in WooCommerce, mapped in SunLicense | Every product you map in SunLicense |
| Admin order screen | Keys, masked, with Reveal and Copy | Nothing |
With the plugin
Coming to wordpress.org
The plugin is waiting for wordpress.org's review. Until it's listed in Plugins → Add New, connect with Webhook only: the plugin uses the same integration, so nothing changes in SunLicense when you switch.
- SunLicense: Integrations → WooCommerce → Connect. Map WooCommerce product IDs to policies, or
*to give every product you tick the same policy. Copy the integration's hook URL and webhook secret. - WordPress: Plugins → Add New, search for SunLicense for WooCommerce, install and activate it (WooCommerce must be active).
- WooCommerce → Settings → SunLicense: paste the hook URL and webhook secret, Save changes, then Test connection. The integration's log in SunLicense shows the test as Order status is connection-test.
- On each product you sell with a key, tick SunLicense key next to Virtual and Downloadable, and update the product. Variations follow their product.
Then check the key in your software with an SDK.
What buyers see
- Thank-you page and My account → Orders → View: a License keys table under the order.
- My account → License keys: every key from their orders (turn the tab off in the plugin's settings if you like).
- Order emails: the keys under the order table (WooCommerce's Processing order and Completed order emails, HTML and plain text). Emails to the shop show them masked.
Buyers see their own full keys: they paste them into your product. On the admin order screen, the SunLicense keys box shows them masked (AX8P-XXXX-XXXX-XXXX) with Reveal and Copy.
When it runs
| Order status | The plugin does |
|---|---|
processing, completed | Sends the order's ticked lines; SunLicense issues one key per product (once, however often it's sent) |
refunded, cancelled | Revokes the order's keys |
| anything else | Nothing |
The call is made before WooCommerce sends its email for the same status change, so the key is usually in the first email. If SunLicense can't be reached, or your automations haven't issued the key yet (Let automations decide), the plugin tries again after 2, 10 and 30 minutes, then hourly for a day; Get keys now in the order's SunLicense keys box tries at once. Partial refunds don't revoke (WooCommerce keeps the order Processing or Completed).
SunLicense also emails the buyer their key as for any store (Settings → Customer emails → License key delivered); turn that email off if you'd rather have only WooCommerce's.
What the plugin sends
Only for orders with a ticked product: the order ID and number, status, currency, customer ID, billing first name, last name and email, and per ticked line its product and variation ID, quantity and total. Nothing is sent before you save the settings. The request is signed with the webhook secret like a WooCommerce webhook, and carries a timestamp: SunLicense only answers with keys for a signed request less than an hour old.
Troubleshooting
| The SunLicense keys box says | Do this |
|---|---|
| SunLicense refused the signature | The webhook secret doesn't match: copy it again from the integration page |
| SunLicense doesn't know this hook URL | The URL is wrong, or the integration is turned off |
| SunLicense has no policy for these products | Map the product ID (shown in WooCommerce's product list) or * on the integration, then Get keys now |
| Your SunLicense plan's license limit is reached | Upgrade on Billing, then Get keys now |
Webhook only
- SunLicense: Integrations → WooCommerce → Connect. Map WooCommerce product IDs to policies, or
*. SunLicense creates a webhook secret. - WooCommerce Settings → Advanced → Webhooks → Add webhook: status Active, topic Order updated (add a second one for Order created if you like), delivery URL = the hook URL, secret = the one on the integration page, API version WP REST API v3.
- Link the integration's redeem page in your order emails. Buyers enter the order number and their billing email.
| Order status | SunLicense does |
|---|---|
processing, completed | One license per product line (once, however many updates follow) |
refunded, cancelled | Revokes |
| anything else | Logged |
X-WC-Webhook-Signature (base64 HMAC-SHA256 of the body) is checked. The unsigned ping WooCommerce sends when you save the webhook is acknowledged.
Using both the plugin and a webhook is fine: they send the same order, and SunLicense issues one key per product per order whichever arrives first. With both, a webhook also issues keys for mapped products you didn't tick.
