Quick setup guide for Recur payment integration. Use when starting a new Recur integration, setting up API keys, installing the SDK, or when user mentions ”integrate Recur”, ”setup Recur”, ”Recur 串接”, ”金流設定”.
npx playbooks add skill recur-tw/skills --skill recur-quickstart
You are helping a developer integrate Recur, Taiwan's subscription payment platform (similar to Stripe Billing).
Skip this step only if the user already has a Recur API key and a product ID.
Recur has no public signup form. **Accounts are created inside the Recur MCP
OAuth flow**, so make sure the recur MCP server is connected. Pick ONE:
recur-skills Claude Code plugin (this skill is/recur-skills:recur-quickstart): the MCP server is already bundled. Run/mcp, pick recur, authorize. Do NOT run claude mcp add — that would
register a second recur server.
npx skills add): claude mcp add --transport http recur https://mcp.recur.tw/
https://mcp.recur.tw/ as a remote (streamable HTTP) MCP server. One-click
links and config snippets: https://docs.recur.tw/guides/mcp
Before the first tool call, tell the user what will happen:
> A browser window will open. Log in, or click 建立新帳號 (Create account) on
> the login page to create a Recur account, then approve the connection. Keep
> the default scopes — Step 0 needs api-keys:write and products:write.
> New accounts start in sandbox mode.
Then, through MCP:
get_setup_overview — lists the SANDBOX keys and products that alreadyexist. Reuse them; only create what is missing (every create call inserts a
new row, so rerunning this step blindly makes duplicates).
create_api_key for each SANDBOX key type the overview does NOT show — itcreates ONE key per call: type: PUBLISHABLE and/or type: SECRET, withenvironment: SANDBOX (pk_test_… / sk_test_…). A secret key is shown
only once; store it. An existing secret key cannot be read back — if it was
lost, create a new one and revoke_api_key the old one.
create_product only if the overview / list_products has no matchingproduct — e.g. name Pro, price 499 (TWD integer, NOT cents), intervalmonth (MCP takes month / year; only the CLI flag below spells itmonthly), type SUBSCRIPTION. Note the returned product id (a CUID
such as cm5x…, not a prod_ prefix).
No MCP available? The CLI does the same once the user has a secret key from
the dashboard (app.recur.tw → 開發者 → API 金鑰):
npx @recur-tw/cli login
npx @recur-tw/cli products create --name "Pro" --price 499 --interval monthly --type SUBSCRIPTION
Charging real cards requires merchant review (apply from app.recur.tw when
ready); everything else works end-to-end in sandbox.
pnpm add recur-tw
# or
npm install recur-tw
Use the SANDBOX key pair from Step 0 (MCP create_api_key), or copy one from the dashboard at app.recur.tw → 開發者 → API 金鑰.
Key formats:
pk_test_xxx - Publishable key (frontend, safe to expose)sk_test_xxx - Secret key (backend only, never expose)pk_live_xxx / sk_live_xxx - Production keysEnvironment variables to set:
NEXT_PUBLIC_RECUR_PUBLISHABLE_KEY=pk_test_xxx # frontend (Next.js needs the NEXT_PUBLIC_ prefix)
RECUR_SECRET_KEY=sk_test_xxx # backend only
Wrap your app with RecurProvider:
'use client'
import { RecurProvider } from 'recur-tw'
export default function App({ children }) {
return (
<RecurProvider
config={{
publishableKey: process.env.NEXT_PUBLIC_RECUR_PUBLISHABLE_KEY!,
}}
>
{children}
</RecurProvider>
)
}
Hosted Checkout redirects to checkout.recur.tw and works on localhost. (Modal/embedded
checkout via useSubscribe() needs checkoutMode on the provider and a registered domain —
see /recur-checkout.)
'use client' // hooks + window: this must be a Client Component in the App Router
import { useState } from 'react'
import { useRecur } from 'recur-tw'
function PricingButton({ productId }: { productId: string }) {
const { redirectToCheckout } = useRecur()
const [redirecting, setRedirecting] = useState(false) // redirectToCheckout does not set isCheckingOut
const handleCheckout = async () => {
setRedirecting(true)
try {
await redirectToCheckout({
productId, // the CUID from Step 0 (or productSlug)
successUrl: `${window.location.origin}/success?session_id={CHECKOUT_SESSION_ID}`,
cancelUrl: `${window.location.origin}/pricing`,
})
} catch (err) {
setRedirecting(false)
// Invalid key, unreachable API, bad product id — show it, don't swallow it
console.error('Failed to start checkout:', err)
alert('無法開始結帳,請稍後再試')
}
}
return (
<button onClick={handleCheckout} disabled={redirecting}>
{redirecting ? 'Redirecting...' : 'Subscribe'}
</button>
)
}
The result arrives on your success page and via webhooks (Step 5), not through a callback.
Create a webhook endpoint to receive payment notifications. See the recur-webhooks skill for detailed instructions.
pnpm list recur-tw)pk_test_, sk_test_, pk_live_, or sk_live_create_product, npx @recur-tw/cli products create, or the dashboardid returned by list_products / npx @recur-tw/cli products list (a CUID likecm5x…; Recur product IDs have no prod_ prefix), never a placeholder
RecurProvider wraps your app/recur-checkout - Learn checkout flow options/recur-webhooks - Set up payment notifications/recur-entitlements - Implement access control@recur-tw/cli)](https://www.npmjs.com/package/@recur-tw/cli)Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.