Skip to content
OnCharge.io
View as Markdown
Developer docs

Build with AI

You can ask an AI coding assistant (Claude, ChatGPT, Cursor, GitHub Copilot and others) to integrate OnCharge for you. Give it the right context and it can write the session endpoint, checkout page, webhook handler, shipment reporting and tests for your stack. Everything on this page is free to use.

1. Point the assistant at the docs#

ResourceUse it for
https://oncharge.io/llms.txtAn index of these docs in the llms.txt format.
https://oncharge.io/llms-full.txtAll of these docs in one Markdown file. Paste or attach it when the assistant cannot browse.
https://oncharge.io/openapi.jsonThe OpenAPI 3.1 spec of the merchant API and webhooks.
https://oncharge.io/docs/<page>.mdAny single page as Markdown, e.g. /docs/webhooks.md (the overview is /docs/index.md).

In Cursor, add https://oncharge.io/llms-full.txt under Docs and mention @OnCharge in your prompt. In Claude or ChatGPT, attach llms-full.txt or paste its URL.

2. Use a prompt for your stack#

The AI prompt library has copy-paste prompts for Next.js, React with a backend, plain HTML with a Node or PHP backend, a custom WooCommerce theme, Magento, Wix, a headless Shopify (Hydrogen) storefront, and Webflow or Framer. Each one tells the assistant exactly what to build, which endpoints to call, how to sign requests and verify webhooks, how to report shipments, when to add the RUO compliance feed, and what never to do.

3. Claude: the OnCharge skill#

The oncharge-checkout Agent Skill teaches Claude the OnCharge integration: the workflow, the signing rules, and reference files it loads only when needed.

Claude Code. Download and unzip it into your personal skills folder:

Shell
mkdir -p ~/.claude/skills && cd ~/.claude/skills
curl -fsSLO https://oncharge.io/docs/ai-files/oncharge-checkout-skill.zip
unzip -o oncharge-checkout-skill.zip && rm oncharge-checkout-skill.zip

Unzip it into .claude/skills/ inside a project instead to share it with your team through the repository.

Claude apps. Download oncharge-checkout-skill.zip and upload it under Settings → Capabilities → Skills (skills must be available on your plan).

The individual files are also published: SKILL.md.

Then ask, for example: "Add OnCharge checkout to this project."

4. ChatGPT: the OnCharge Integration Assistant GPT#

You can create a custom GPT that knows these docs and can look pages up while it works:

  1. In ChatGPT, open Explore GPTs → Create → Configure.
  2. Name: OnCharge Integration Assistant. Description: Integrates OnCharge checkout into your store.
  3. Instructions: paste gpt-instructions.md.
  4. Conversation starters: add the four lines from conversation-starters.txt.
  5. Knowledge: upload llms-full.txt and openapi.json.
  6. Capabilities: turn on Web Search and Code Interpreter.
  7. Actions → Create new action → Import from URL: https://oncharge.io/docs/ai-files/chatgpt/actions.openapi.json. Authentication: None. Privacy policy: https://oncharge.io/privacy.

The actions only read the public docs (search and fetch pages). The GPT never calls the OnCharge merchant API: requests must be signed with your API secret, which should never be pasted into a chat. For live API calls from an assistant, use the MCP server below on your own machine.

5. MCP server: docs and live API tools#

@oncharge/mcp is a Model Context Protocol server that runs locally over stdio. It gives any MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf and others):

ToolWhat it does
search_docs, read_doc, list_docsSearch and read these docs offline (bundled with the server).
create_checkout_sessionPOST /api/v1/checkout/sessions
get_checkout_sessionGET /api/v1/checkout/sessions/{id}
attach_orderPOST /api/v1/checkout/sessions/{id}/order
report_shipmentPOST /api/v1/shipments
get_delivery_statusGET /api/v1/shipments?session_id=…
create_refundPOST /api/v1/refunds (moves money; your client asks before running it)
verify_webhook_signatureChecks an OnCharge-Signature header against a raw body.
explain_signatureShows the signing string and signature for a request, to debug your own code.

The docs tools work without credentials. The API tools appear when ONCHARGE_API_KEY and ONCHARGE_API_SECRET are set; ONCHARGE_BASE_URL defaults to https://app.oncharge.io, and ONCHARGE_WEBHOOK_SECRET is used by verify_webhook_signature when no secret is passed.

Claude Code

Shell
claude mcp add oncharge \
  --env ONCHARGE_API_KEY=oc_key_... \
  --env ONCHARGE_API_SECRET=oc_sec_... \
  -- npx -y @oncharge/mcp

Claude Desktop (claude_desktop_config.json), Cursor (.cursor/mcp.json) and most other clients:

MCP client configuration
{
  "mcpServers": {
    "oncharge": {
      "command": "npx",
      "args": ["-y", "@oncharge/mcp"],
      "env": {
        "ONCHARGE_API_KEY": "oc_key_...",
        "ONCHARGE_API_SECRET": "oc_sec_...",
        "ONCHARGE_BASE_URL": "https://app.oncharge.io"
      }
    }
  }
}

VS Code (.vscode/mcp.json):

.vscode/mcp.json
{
  "servers": {
    "oncharge": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@oncharge/mcp"],
      "env": { "ONCHARGE_API_KEY": "${input:onchargeKey}", "ONCHARGE_API_SECRET": "${input:onchargeSecret}" }
    }
  },
  "inputs": [
    { "id": "onchargeKey", "type": "promptString", "description": "OnCharge API key" },
    { "id": "onchargeSecret", "type": "promptString", "description": "OnCharge API secret", "password": true }
  ]
}

Leave the env block out to use only the docs tools. MCP configuration files contain your secret: keep them out of version control.

What a good AI-built integration has#

Use this to review what the assistant produced:

  • Sessions are created on the server, with the amount from your database and an Idempotency-Key.
  • The API secret never reaches the browser or the repository.
  • The checkout is shown by redirect or an iframe on a registered domain, and postMessage events are checked against https://app.oncharge.io.
  • Orders are marked paid only from a verified webhook (or a server-side status check).
  • The webhook handler verifies OnCharge-Signature on the raw body, deduplicates event IDs and replies within 10 seconds.
  • Shipping addresses are sent for physical goods, and tracking numbers are reported when orders ship.
  • Tests cover the signing test vector and webhook verification.