Skip to content

Integration

Lovable

Sign up in the agent conversation and integrate the SDK on the server.

Updated

1. Prepare the account

Look for existing Infi credentials first. Reuse an existing integration through normal sign-in. For a new account, follow agent onboarding. Ask for the email, app name and offer intent. Explain that the OTP authorizes creating a sandbox account and handing its test credentials to this project.

2. Confirm the email in the conversation

Connect the remote MCP at https://api-sandbox.beinfi.com/mcp without a token for new signup. Call onboarding_start_v1 for the missing-field questions, then repeat with the returned key and the person's answers to request the OTP. Ask for this signup's six-digit code and call onboarding_verify_v1. The complete result contains account with the owner already linked and test keys. Give the person dashboardUrl for later sign-in with the same email. There is no claim step.

Without MCP, the agent follows the two HTTP calls in the onboarding guide.

3. Env in the Lovable app

INFI_SECRET_KEY=sk_test_...
INFI_PUBLISHABLE_KEY=pk_test_...
INFI_TENANT_SLUG=your-tenant

Save INFI_SECRET_KEY in your server functions' secrets. Only INFI_PUBLISHABLE_KEY may be exposed in the browser when a client API requires one; it is Infi's, not the payment provider's. Never expose the secret in a VITE_* variable. Provide only this signup OTP to the agent. Never provide your password.

Do not set INFI_AUTH_BASE_URL / INFI_PAY_BASE_URL — they are legacy and nothing reads them. The hosts come from the key's prefix.

4. Create the product

The seed product is good for neither selling nor metering (version in draft, no meter). Create and publish your own — three calls in catalog. Keep the productId: it goes into the payment link, checkout() and every usage event.

5. Integrate the SDK

Infi does not log your user in — use the auth the app already has (Supabase, in the typical Lovable case) and pass that id to Infi.

// server — enrollment + usage metering
import { Infi } from "@beinfi/sdk";
 
const infi = new Infi({ secretKey: process.env.INFI_SECRET_KEY! });
 
// yourUserId comes from YOUR auth (e.g. Supabase)
const enrollment = await infi.products.enroll(productId, {
  externalId: yourUserId,
  email: userEmail,
});
 
await infi.track({
  customerId: enrollment.id,
  productId,               // required once the tenant has more than one product
  meter: "tokens",
  value: "1200",
});

To charge, send a payment link. To know they paid, polling in sandbox — registering a webhook answers 503 with a test key.

MCP tools

A reference for what the MCP server exposes. Point your MCP client at it like this:

{
  "mcpServers": {
    "infi": { "command": "npx", "args": ["-y", "@beinfi/mcp"] }
  }
}
ToolWhat for
onboarding_start_v1Asks for missing details and requests the OTP in the conversation
onboarding_verify_v1Confirms the code and returns an owned account
infi_doctorSetup health (JSON + fix commands)
infi_go_live_statusGuidance for claim → KYC → sk_live_
infi_sync_plan / infi_sync_applyDry-run / apply of the company file
infi_set_app_urlUpdates the app's origins
infi_pullBackend → infi.company.ts