Skip to content
Intents Checkout plugins

Plugin Connect

How a store plugin gets its keys without anyone copying one, and how to add Connect to a plugin.

Connect links a store plugin to an intents.fi account in a few clicks. The merchant presses Connect intents.fi in their store’s settings, signs in (or signs up) on the dashboard, approves, and lands back in their store already connected, in test mode, with payment notifications set up. Nobody copies a key.

The WooCommerce plugin, the WHMCS module, the PrestaShop module, the Magento module and the OpenCart extension speak Connect today. The plugin half is a small PHP class with no platform code in it (plugins/_shared/connect/class-connect-protocol.php), so other plugins get the same checks as they adopt it.

The consent screen says it, and the API holds to it:

  • Create payments for the store’s orders and read them.
  • Get notified when an order is paid: the plugin registers its own webhook endpoint.
  • Use the merchant’s logo and colours on checkout.
  • It can’t change where the merchant gets paid. No API key can: a payout wallet changes only from a signed-in dashboard session, with a fresh email code and a 24-hour wait.

The key is a normal secret key named for the store (WooCommerce: shop.example.com), so it shows on the API keys page, and the account’s owners get the “New API key created” email.

A connection made before go-live gets test-mode keys only. Go live in the plugin runs the same round trip with mode=live; the dashboard checks the go-live checklist (a verified email and a payout wallet) and says what is missing. Live keys are issued only once both are done, and the plugin switches to live only when the round trip finishes. Nothing goes live by itself.

From the plugin (Disconnect, which calls POST /v0/connect/revoke with its own key) or from the dashboard (Integrations → Connected stores → Disconnect). Either way the store’s keys and the webhooks they registered stop at once. Connecting the same store again replaces the last connection.

It is OAuth 2.0’s authorization-code flow with PKCE (S256), with the keys as the result.

  1. Start. Make a state and a code_verifier (32 random bytes each, base64url). Keep both on your server, tied to the admin who pressed Connect (never in a cookie or the page). Send the admin’s browser to:

    https://dashboard.intents.fi/connect
    ?platform=woocommerce
    &site_url=https://shop.example.com
    &return_url=https://shop.example.com/wp-admin/admin-post.php?action=intentsfi_connect_return
    &state=…
    &code_challenge=BASE64URL(SHA256(code_verifier))
    &code_challenge_method=S256
    &mode=test

    return_url must have the same origin as site_url (scheme, host and port), and both must be https. Anything else is refused before the consent screen shows. A platform whose admin can live on another origin (Magento) returns to a storefront route that only forwards code and state to the admin URL it saved when Connect was pressed.

  2. Come back. After Connect, the browser arrives at return_url?code=…&state=…. Check state is exactly the one you stored for this admin, and spend it. After Cancel it arrives with error=access_denied&state=… instead.

  3. Exchange, server to server, within 5 minutes:

curl
curl https://api.intents.fi/v0/connect/token \
-X POST \
-H 'authorization: Bearer $INTENTS_SECRET_KEY' \
-H 'content-type: application/json' \
-d '{
"code": "<the code from return_url>",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"site_url": "https://shop.northwood.example"
}'
TypeScript
const response = await fetch("https://api.intents.fi/v0/connect/token", {
method: "POST",
headers: {
authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`,
"content-type": "application/json",
},
body: JSON.stringify({
"code": "<the code from return_url>",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"site_url": "https://shop.northwood.example"
}),
});
if (!response.ok) {
const { error } = await response.json();
throw new Error(`${error.code}: ${error.message}`);
}
const data = await response.json();
Python
import os
import httpx
response = httpx.post(
"https://api.intents.fi/v0/connect/token",
headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},
json={
"code": "<the code from return_url>",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"site_url": "https://shop.northwood.example"
},
)
response.raise_for_status()
data = response.json()

The response carries secret_key (ik_test_…, or ik_live_… after go-live), publishable_key, mode, the account and merchant, and the connection. Check mode is the one you asked for, and store the keys like a password.

  1. Register your webhook with the new key (POST /v0/webhooks, the invoice.* events) and store the whsec_ it returns. A webhook registered with the connection’s key is revoked with it.

The code is single-use and lives 5 minutes, bound to the store and to your verifier; only its hash is stored. Every exchange spends it, right or wrong, and presenting a spent code revokes the connection it made. Failures are CONNECT_CODE_INVALID with a details.reason; a live request before go-live is LIVE_MODE_LOCKED.

Nothing secret travels in a URL except the one-time code. Never log the code, the verifier or the keys.