Home / Developers / AI agents

Connect UPI payments with your AI agent

Using Claude, Cursor, Copilot, Lovable or another AI coding agent? Paste one prompt and it wires UPIDirect into your website: payment links, webhooks and a test payment. Or connect our MCP server so the agent can create payment links and pages for you.

1. Copy this prompt into your agent

Fill in the two lines in angle brackets. The agent reads our full guide at /llms-full.txt, writes server-side code, verifies webhook signatures and tests with a test key.

Connect my website to UPIDirect so customers can pay me by UPI, straight into my bank account.

Read the full integration guide first: https://upidirect.codepeacock.com/llms-full.txt

About my project: <describe your stack, e.g. "Next.js app on Vercel with Supabase" or "PHP/Laravel shop"> and what customers pay for: <e.g. course fees, orders>.

Requirements:
1. Server side only: add an endpoint that creates a UPIDirect payment request (POST https://upidirect.codepeacock.com/api/v1/payment_requests) with amount in rupees (up to 2 decimals, e.g. 2000.50), a purpose, the customer's name/phone, external_ref = my order/fee ID, and an Idempotency-Key = my order/fee ID. Then redirect the customer to the returned payment_url.
2. Add a webhook endpoint that verifies the UPD-Signature header (HMAC-SHA256 of "{t}.{raw body}" with my webhook secret, reject if older than 5 minutes), ignores repeated UPD-Event-Id values, and marks my order paid ONLY on the event payment_request.paid (match data.external_ref). Make the update idempotent.
3. Never mark an order paid because the browser came back to my site.
4. Read the secret key from the environment variable UPIDIRECT_SECRET_KEY and the webhook secret from UPIDIRECT_WEBHOOK_SECRET. Never put them in frontend code, logs or git. I will set these myself; do not ask me to paste them in chat.
5. Add a "Pay with UPI" button where customers pay.
6. Test in test mode (sk_test_ key): create a payment, open payment_url, press "Simulate successful payment", and confirm my order becomes paid via the webhook.
7. When done, tell me the public webhook URL to add in UPIDirect Dashboard → Developers (or add it with the UPIDirect MCP tool create_webhook_endpoint if it is connected), and list every file you changed.
Keep your keys safe. Never paste your secret key (sk_live_…) or webhook secret into a chat. Put them in your hosting’s environment variables as UPIDIRECT_SECRET_KEY and UPIDIRECT_WEBHOOK_SECRET; the prompt tells the agent to read them from there.

2. Or connect the UPIDirect MCP server

MCP (Model Context Protocol) lets an AI assistant use UPIDirect directly: create a payment link for a customer, make a payment page, check what is paid, register a webhook. Start with a test key (sk_test_…) from Dashboard → Developers.

Claude Code

claude mcp add --transport http upidirect https://upidirect.codepeacock.com/mcp \
  --header "Authorization: Bearer sk_test_..."

Cursor, Windsurf, VS Code and other MCP clients

{
  "mcpServers": {
    "upidirect": {
      "url": "https://upidirect.codepeacock.com/mcp",
      "headers": {
        "Authorization": "Bearer sk_test_..."
      }
    }
  }
}

Claude Desktop

{
  "mcpServers": {
    "upidirect": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://upidirect.codepeacock.com/mcp",
        "--header",
        "Authorization: Bearer sk_test_..."
      ]
    }
  }
}

Tools the agent gets

ToolWhat it does
create_payment_requestOne-time payment link for an amount in rupees (e.g. 2000.50)
get_payment_request / list_payment_requestsCheck status: pending, paid, expired, cancelled
cancel_payment_requestStop a link from being paid
confirm_payment_requestMark paid after you see the money in your bank
create_payment_page / list_payment_pages / update_payment_pageReusable pages and Pay buttons for fees, donations, products
create_webhook_endpoint / list / deleteWhere your site gets payment events
get_accountAccount status, UPI ID and key mode
get_integration_guideThe full integration guide, for writing code

The MCP server uses the same rules as the API: a test key only sees test data, live payments need an approved account, and money always goes straight to your bank. We never hold it.

3. Files for AI tools

Prefer to do it by hand? Read the developer guide.

Share UPIDirect: WhatsApp LinkedIn X Facebook Email