integrate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/integrate — Juspay Integration Orchestrator
/integrate — Juspay集成编排器
PRIME DIRECTIVE: This file is a decision engine. It contains no product knowledge. Product knowledge lives in. Authoritative implementation facts come only from MCP tool calls — never from memory or training.products/MCP PREFERENCE: Always prefertools for live merchant data (credentials, settings, gateway config, integration status). Usejuspay-mcponly for documentation structure and page content.juspay-docs-mcp
核心准则: 本文件是决策引擎,不包含任何产品知识。 产品知识存储在目录下。权威的实现信息仅来自MCP工具调用——绝不能依赖记忆或训练数据。products/MCP优先级: 如需获取商户实时数据(凭证、设置、网关配置、集成状态),优先使用工具。仅在获取文档结构和页面内容时使用juspay-mcp。juspay-docs-mcp
AGENT SELF-CHECK (run mentally before each phase)
AGENT自检(每个阶段开始前在脑中执行)
- Did I authenticate with before calling any
juspay-mcptools? If not, Please trigger the authentication flow now.juspay-mcp - Did I call to establish merchant context before asking for credentials?
juspay_get_merchant_details - Did I read before calling
products/? Can I conclude from the catalog alone?explore_product - Did I scan the codebase before asking disambiguation questions (language, framework)?
- Did I call before writing any code?
doc_fetch_tool - Am I using method names and field names from the fetched docs, not from memory?
- For SDK/web redirect products: did I fetch test resources and run tests for each checklist stage wherever possible
- 在调用任何工具前,我是否已通过
juspay-mcp完成认证?如果没有,请立即触发认证流程。juspay-mcp - 在请求凭证前,我是否调用了来确立商户上下文?
juspay_get_merchant_details - 在调用前,我是否已读取
explore_product目录下的内容?能否仅通过产品目录得出结论?products/ - 在询问歧义问题(语言、框架)前,我是否已扫描代码库?
- 在编写任何代码前,我是否已调用?
doc_fetch_tool - 我是否使用从获取的文档中得到的方法名和字段名,而非记忆中的内容?
- 对于SDK/网页跳转类产品:是否在每个检查清单阶段尽可能获取测试资源并运行测试?
FLAG PARSING
标志解析
Extract flags before starting:
| Flag | Effect |
|---|---|
| Skip recommendation. Confirm the product in one line, then go to Phase 1. Still run catalog-first check. |
| Hint for platform selection in Phase 2 — still verify against codebase before asking. |
开始前先提取标志:
| 标志 | 作用 |
|---|---|
| 跳过推荐环节。用一句话确认产品后直接进入阶段1。仍需先执行目录检查。 |
| 为阶段2的平台选择提供提示——但在询问用户前仍需与代码库进行验证。 |
UI INTERACTION RULES
UI交互规则
Whenever the user must choose between fixed options:
- Use native select / choice UI
- Do NOT ask for free-text replies if options are known
- Wait for a selection before continuing
- Do NOT rephrase the same question again after rendering choices
- Do NOT ask for information you can derive — from the codebase, from live data, or from the catalog
juspay-mcp
Format choices as structured options, not inline prose.
当用户必须从固定选项中选择时:
- 使用原生选择/选项UI
- 如果选项已知,绝不要求用户输入自由文本回复
- 等待用户选择后再继续
- 展示选项后,绝不重复表述同一问题
- 绝不询问可推导的信息——从代码库、实时数据或产品目录中获取的信息无需询问
juspay-mcp
将选项格式化为结构化选项,而非行内散文。
PHASE 0 — Intent Collection and Product Selection
阶段0 — 意图收集与产品选择
Step 0A — Load product catalog
步骤0A — 加载产品目录
Read all files in . Each file has: product ID, platforms, use cases, and intent signals.
products/Store the full set as . This is your local knowledge for matching — do not use training-data knowledge about products.
$PRODUCT_CATALOG读取目录下的所有文件。每个文件包含:产品ID、平台、使用场景和意图信号。
products/将完整集合存储为。这是用于匹配的本地知识——请勿使用关于产品的训练数据知识。
$PRODUCT_CATALOGStep 0B — Auto-resolve integration type from merchant account
步骤0B — 通过商户账户自动解析集成类型
Call:
juspay-mcp:juspay_get_merchant_details()Extract and store:
- — from the
$MERCHANT_IDfieldmerchantId - — always default to
$CLIENT_ID. Never extract this from the API response. Inform the user:$MERCHANT_ID"Client ID is typically the same as your merchant ID (). If you use a different client ID, please provide it now — otherwise I'll proceed with$MERCHANT_ID." Wait for confirmation or a custom value before continuing.$MERCHANT_ID - — from the
$INTEGRATION_TYPEfield, which is an array; take the first element (e.g.integrationType→["PP"])"PP"
Map to a recommended product:
$INTEGRATION_TYPE | Recommended product ID |
|---|---|
| |
| |
| |
| (anything else or absent) | No inference — fall back to Step 0B-Fallback |
调用:
juspay-mcp:juspay_get_merchant_details()提取并存储:
- — 来自
$MERCHANT_ID字段merchantId - — 始终默认使用
$CLIENT_ID。绝不要从API响应中提取此字段。告知用户:$MERCHANT_ID"Client ID通常与您的商户ID()相同。如果您使用不同的Client ID,请现在提供——否则我将使用$MERCHANT_ID继续。" 等待用户确认或提供自定义值后再继续。$MERCHANT_ID - — 来自
$INTEGRATION_TYPE字段,该字段为数组;取第一个元素(例如integrationType→["PP"])"PP"
将映射为推荐产品:
$INTEGRATION_TYPE | 推荐产品ID |
|---|---|
| |
| |
| |
| (其他值或为空) | 不进行推断——回退到步骤0B-Fallback |
Step 0B-Confirm — Present inferred recommendation
步骤0B-确认 — 展示推断的推荐结果
If a mapping was found, present a single confirmation:
"Based on your account configuration, it looks like you're set up for [Product Name].Shall I proceed with integrating [Product Name]?
- Yes, proceed
- No, let me choose a different product type
- No, let me choose a specific product"
- Option 1 → set to the inferred product ID and skip to Phase 1
$PRODUCT - Option 2 → go to Step 0B-Fallback (product type list)
- Option 3 → show the full flat product list from and let the user pick directly
$PRODUCT_CATALOG
如果找到映射关系,展示单一确认选项:
"根据您的账户配置,看起来您已准备好集成**[产品名称]**。是否继续集成**[产品名称]**?
- 是,继续
- 否,让我选择其他类型的产品
- 否,让我选择特定产品"
- 选项1 → 将设置为推断的产品ID,直接跳至阶段1
$PRODUCT - 选项2 → 进入步骤0B-Fallback(产品类型列表)
- 选项3 → 展示中的完整产品列表,让用户直接选择
$PRODUCT_CATALOG
Step 0B-Fallback — Ask the user what they want to build
步骤0B-Fallback — 询问用户的搭建需求
Only reached if is absent, unrecognized, or the user chose Option 2 above.
$INTEGRATION_TYPEWhat type of product are you looking to integrate?
- Checkout
- UPI
- Payouts
- Billing
- Not sure
仅当不存在、无法识别,或用户选择上述选项2时进入此步骤。
$INTEGRATION_TYPE您希望集成哪种类型的产品?
- 结账
- UPI
- 付款
- 账单
- 不确定
Step 0B1 — Ask the User to Choose a Product
步骤0B1 — 让用户选择产品
Based on the selected category, ask the relevant follow-up question.
根据用户选择的类别,提出相关的后续问题。
If the user selects Checkout
如果用户选择结账
Which Checkout product would you like to integrate?
- Hyper Checkout
- Express Checkout SDK
- Express Checkout API
您希望集成哪款结账产品?
- Hyper Checkout
- Express Checkout SDK
- Express Checkout API
If the user selects UPI
如果用户选择UPI
Which UPI product would you like to integrate?
- UPI TPAP
- Hyper UPI
and so on for Payouts and Billing categories...
您希望集成哪款UPI产品?
- UPI TPAP
- Hyper UPI
付款和账单类别的后续问题以此类推...
If the user selects Not sure
如果用户选择不确定
ask:
Please describe your use case and I'll recommend the right product and integration flow.
Store as .
$INTENT询问:
请描述您的使用场景,我将为您推荐合适的产品和集成流程。
将内容存储为。
$INTENTStep 0C — Match intent to candidates
步骤0C — 将意图与候选产品匹配
Using and the field in each entry, select 1–3 products as .
$INTENTintent signals$PRODUCT_CATALOG$CANDIDATES[]Matching rules:
- "checkout UI", "payment page", "mobile SDK" → prefer products with runtime platforms (android, ios, web, etc.)
- "API only", "server-side", "REST", "backend" → prefer products with no runtime platforms
- "recurring", "subscriptions", "mandates" → billing/mandate products
- "payout", "transfer", "disburse" → payout products
- "UPI", "TPAP", "P2P", "P2M" → UPI products
Aim for 1–3 candidates. Fewer is better.
使用和每个条目中的字段,选择1–3个产品作为。
$INTENT$PRODUCT_CATALOGintent signals$CANDIDATES[]匹配规则:
- "checkout UI"、"payment page"、"mobile SDK" → 优先选择支持运行时平台(android、ios、web等)的产品
- "API only"、"server-side"、"REST"、"backend" → 优先选择不支持运行时平台的产品
- "recurring"、"subscriptions"、"mandates" → 账单/授权类产品
- "payout"、"transfer"、"disburse" → 付款类产品
- "UPI"、"TPAP"、"P2P"、"P2M" → UPI类产品
目标是1–3个候选产品,数量越少越好。
Step 0D — Catalog-first product resolution
步骤0D — 基于目录的产品决议
Before calling , check if the catalog entry is conclusive:
explore_productA catalog entry is conclusive if:
- The list either matches
platformsexactly, or has only one option$DETECTED_PLATFORM - No further platform disambiguation is required to start code generation
If conclusive → skip for this candidate and proceed.
If not conclusive (e.g. multiple overlapping platforms, need page count for complexity signal) → call:
explore_productjuspay-docs-mcp:explore_product({ product: <candidate-id> })Extract only what you need for recommendation:
- Product title
- Platform IDs — runtime IDs signal a client SDK; only signals a server API; a mix signals both
docs - Number of numbered base integration pages (complexity signal)
- List of supported platforms if a client SDK is present
Do not fetch individual doc pages here.
在调用前,检查目录条目是否具有决定性:
explore_product如果满足以下条件,目录条目具有决定性:
- 列表与
platforms完全匹配,或仅有一个选项$DETECTED_PLATFORM - 开始代码生成前无需进一步的平台歧义消除
如果具有决定性 → 跳过对此候选产品的调用,直接继续。
如果不具有决定性(例如多个重叠平台、需要页面数量来判断复杂度)→ 调用:
explore_productjuspay-docs-mcp:explore_product({ product: <candidate-id> })仅提取推荐所需的信息:
- 产品标题
- 平台ID — 运行时ID表示客户端SDK;仅表示服务器API;混合表示两者兼具
docs - 基础集成页面的编号数量(复杂度信号)
- 如果是客户端SDK,列出支持的平台
在此步骤不要获取单个文档页面。
Step 0E — Recommend and confirm
步骤0E — 推荐并确认
Present your recommendation grounded in what you read from and :
products/explore_product"Based on what you described, here's what I recommend:[Product Title] — [one-line reason tied to their intent](Alternative) [Product Title] — [reason]Which would you like to integrate? Or pick from the full list below:"
List all products from as a numbered reference so the user can override.
$PRODUCT_CATALOGStore the confirmed choice as (the product ID from the products/ file).
$PRODUCT基于从和中获取的信息,展示推荐结果:
products/explore_product"根据您的描述,我推荐:[产品标题] — [与您的意图相关的一句话理由](备选) [产品标题] — [理由]您希望集成哪款?或从下方完整列表中选择:"
将中的所有产品列为编号选项,以便用户可以覆盖推荐结果。
$PRODUCT_CATALOG将用户确认的选择存储为(来自products/文件的产品ID)。
$PRODUCTPHASE 1 — Full Product Exploration
阶段1 — 完整产品探查
Only call if it wasn't already called in Phase 0D for .
explore_product$PRODUCTIf already called and is populated → skip directly to Phase 1A.
$DOC_MAPOtherwise call:
juspay-docs-mcp:explore_product({ product: $PRODUCT })Read the full response. This is the authoritative doc structure.
仅当阶段0D中未针对调用时,才调用该工具。
$PRODUCTexplore_product如果已调用且已填充 → 直接跳至阶段1A。
$DOC_MAP否则调用:
juspay-docs-mcp:explore_product({ product: $PRODUCT })读取完整响应。这是权威的文档结构。
1A — Parse into $DOC_MAP
1A — 解析为$DOC_MAP
Extract and store:
- Product title and description
- — every platform entry with its ID and title
platforms[] - For each platform: → for each section:
sections[],sectionTitlepages[] - For each page: and the
pageTitleURLmd content link
Pages numbered "1. …", "2. …" are base integration pages in required order. Preserve that order exactly.
提取并存储:
- 产品标题和描述
- — 每个平台条目及其ID和标题
platforms[] - 每个平台对应的→ 每个章节对应的
sections[]、sectionTitlepages[] - 每个页面对应的和
pageTitleURLmd content link
编号为"1. …"、"2. …"的页面是按要求顺序排列的基础集成页面。必须严格保留该顺序。
1B — Classify product type
1B — 产品类型分类
| Platform IDs observed | Classification |
|---|---|
Runtime IDs: | |
Only | |
Mix of | |
Store as .
$PRODUCT_TYPE| 观察到的平台ID | 分类 |
|---|---|
运行时ID: | |
仅包含 | |
| |
将结果存储为。
$PRODUCT_TYPEPHASE 2 — Adaptive Flow
阶段2 — 自适应流程
Branch on :
$PRODUCT_TYPE根据分支处理:
$PRODUCT_TYPEIf api-only
api-only如果是api-only
api-onlyNo platform question. Backend language comes from — only ask if not detected.
$DETECTED_LANG无需询问平台。后端语言来自 — 仅当未检测到时才询问用户。
$DETECTED_LANGIf sdk
sdk如果是sdk
sdkStep 2-SDK-A — Detect platform from codebase
Before asking the user, scan the working directory for platform signals:
| File / pattern found | Detected platform |
|---|---|
| |
| |
| |
| |
| |
| |
| |
If a platform is detected with confidence, present it as the pre-selected recommendation:
"I detected your project is a [Platform] app (found).[signal file]Shall I proceed with [Platform]?
- Yes, use [Platform]
- No, let me choose a different platform"
If the user confirms, skip to disambiguation. If they choose option 2, or if no signal is found, present the full platform list from .
$DOC_MAPStep 2-SDK-B — Disambiguation
Apply after platform is confirmed:
- Android: ask Java vs Kotlin
- iOS: ask Swift vs Objective-C, CocoaPods vs SPM
- Web: if both and
webare in the doc map, ask which variantiframe-web
Store as . Filter to the chosen platform's pages.
$PLATFORM$DOC_MAP步骤2-SDK-A — 从代码库检测平台
询问用户前,扫描工作目录寻找平台信号:
| 找到的文件/模式 | 检测到的平台 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
如果以较高置信度检测到平台,将其作为预选推荐展示给用户:
"我检测到您的项目是**[平台]**应用(找到)。[信号文件]是否继续使用**[平台]**?
- 是,使用[平台]
- 否,让我选择其他平台"
如果用户确认,跳至歧义消除步骤。如果用户选择选项2,或未检测到信号,展示中的完整平台列表。
$DOC_MAP步骤2-SDK-B — 歧义消除
确认平台后执行:
- Android:询问Java还是Kotlin
- iOS:询问Swift还是Objective-C,CocoaPods还是SPM
- Web:如果文档映射中同时存在和
web,询问使用哪种变体iframe-web
将结果存储为。过滤,仅保留所选平台的页面。
$PLATFORM$DOC_MAPIf hybrid
hybrid如果是hybrid
hybridAsk first:
"This product has both a backend API and a client SDK. What do you need?
- Backend API only
- Client SDK only
- Both"
Then follow the path, path, or both, as appropriate.
api-onlysdk首先询问:
"该产品同时包含后端API和客户端SDK。您需要哪种?
- 仅后端API
- 仅客户端SDK
- 两者都要"
然后根据选择,分别遵循流程、流程,或两者兼顾。
api-onlysdkPHASE 3 — Doc Fetch
阶段3 — 文档获取
Always use . Only fall back to WebFetch if MCP returns an explicit error on a valid URL.
doc_fetch_tooljuspay-docs-mcp:doc_fetch_tool({ url: "<md content link from $DOC_MAP>" })Fetch order:
- Pre-Requisites / Overview — always first; defines credentials, auth format, version constraints
- Numbered base integration pages — in exact numbered order from
explore_product - Webhooks, Order Status API
- Error Codes (resources section)
- Advanced sections — only if user asks
While reading each page, extract and store:
- — every request field, method param, constructor arg (required vs optional)
$PARAMS - — exact method names, class names, key identifiers from the docs
$CODE_EXAMPLES - — all status values, error codes, failure reasons
$ERROR_CODES - — min SDK version, min language/platform version
$VERSION_CONSTRAINTS - — any "note", "important", "warning" callout blocks
$WARNINGS
始终使用。仅当MCP对有效URL返回明确错误时,才回退使用WebFetch。
doc_fetch_tooljuspay-docs-mcp:doc_fetch_tool({ url: "<来自$DOC_MAP的md content link>" })获取顺序:
- 先决条件/概述 — 始终优先获取;定义凭证、认证格式、版本约束
- 编号的基础集成页面 — 严格按照返回的编号顺序获取
explore_product - Webhooks、订单状态API
- 错误码(资源章节)
- 高级章节 — 仅当用户要求时获取
读取每个页面时,提取并存储:
- — 每个请求字段、方法参数、构造函数参数(必填/可选)
$PARAMS - — 文档中的精确方法名、类名、关键标识符
$CODE_EXAMPLES - — 所有状态值、错误码、失败原因
$ERROR_CODES - — 最小SDK版本、最小语言/平台版本
$VERSION_CONSTRAINTS - — 任何“注意”“重要”“警告”提示块
$WARNINGS
PHASE 4 — Parameter Collection
阶段4 — 参数收集
Tell the user:
"I've read the documentation. I'll collect what I need."
告知用户:
"我已阅读文档。我将收集所需的参数。"
Step 4A — Auto-resolve merchant context via MCP
步骤4A — 通过MCP自动解析商户上下文
$MERCHANT_ID$CLIENT_ID$INTEGRATION_TYPEjuspay_get_merchant_details()Then call both in parallel:
juspay-mcp:juspay_get_webhook_settings()
juspay-mcp:juspay_get_general_settings()From webhook settings, extract:
- — existing webhook URL if configured (check if non-empty)
$WEBHOOK_URL - — currently subscribed events
$WEBHOOK_EVENTS
From general settings, extract:
- — existing return URL if configured (check if non-empty)
$RETURN_URL
If is empty or not configured:
$WEBHOOK_URLFirst, scan the codebase for an existing webhook handler (e.g. , , route). If one exists, note its path as .
api/juspay/webhookapi/webhookwebhooks$WEBHOOK_PATHThen ask the user:
"No webhook URL is configured. Your app has a webhook handler at. Please provide your deployed base URL so I can set it to$WEBHOOK_PATH.https://<your-domain>/$WEBHOOK_PATHIf you don't have a deployed URL yet, you can:
- Run
locally to get a temporary public URLngrok http <port>- Leave this for now and configure it on the Juspay dashboard before going live"
Do not set a placeholder URL (e.g. ) — only call if the user provides a real, publicly reachable HTTPS URL that routes to the webhook handler.
https://www.webhook.comjuspay_update_webhook_settingsOnce a valid URL is provided, call:
juspay-mcp:juspay_update_webhook_settings({
webHookurl: <base-url> + "/" + <$WEBHOOK_PATH>,
webhookEvents: <merge existing $WEBHOOK_EVENTS with standard events for this product>
})After updating, confirm what was set:
"Webhook URL set to. The following events are now enabled:<url>
EVENT_NAME_1EVENT_NAME_2- (list every event where the value is
in the updated config)"true
Store the final URL as .
$WEBHOOK_URLIf is empty or not configured:
$RETURN_URLFirst, scan the codebase for an existing return URL page or handler that can receive the Juspay redirect and handle order status response. If one exists, note its path and use that when asking the user.
Ask the user:
"No return URL is configured for your account. Please provide the URL customers should be redirected to after payment completes. This must be a real route in your app that can handle the payment return/order status response."
After the user provides a URL, validate that it matches an existing route or handler in the codebase.
- If it matches, call:
juspay-mcp:juspay_update_general_settings({ returnUrl: <user-provided URL> })- If it does not match, warn the user:
"The URL you provided does not appear to exist in the current codebase as a return handler. Are you sure you want to use this?"
Store the final URL as .
$RETURN_URLEnvironment is always production. Do not ask the user. Use production host URLs from the docs.
$MERCHANT_ID$CLIENT_ID$INTEGRATION_TYPEjuspay_get_merchant_details()然后并行调用:
juspay-mcp:juspay_get_webhook_settings()
juspay-mcp:juspay_get_general_settings()从webhook设置中提取:
- — 如果已配置,获取现有webhook URL(检查是否非空)
$WEBHOOK_URL - — 当前已订阅的事件
$WEBHOOK_EVENTS
从常规设置中提取:
- — 如果已配置,获取现有返回URL(检查是否非空)
$RETURN_URL
如果为空或未配置:
$WEBHOOK_URL首先,扫描代码库寻找现有webhook处理程序(例如、、路由)。如果存在,将其路径记录为。
api/juspay/webhookapi/webhookwebhooks$WEBHOOK_PATH然后询问用户:
"未配置webhook URL。您的应用在处有一个webhook处理程序。 请提供您的部署基础URL,以便我将其设置为$WEBHOOK_PATH。https://<your-domain>/$WEBHOOK_PATH如果您还没有部署URL,可以:
- 在本地运行
获取临时公共URLngrok http <port>- 暂时跳过此步骤,在上线前在Juspay仪表板上配置"
不要设置占位符URL(例如)——仅当用户提供可公开访问的真实HTTPS URL且该URL可路由至webhook处理程序时,才调用。
https://www.webhook.comjuspay_update_webhook_settings提供有效URL后,调用:
juspay-mcp:juspay_update_webhook_settings({
webHookurl: <base-url> + "/" + <$WEBHOOK_PATH>,
webhookEvents: <将现有$WEBHOOK_EVENTS与该产品的标准事件合并>
})更新后,确认设置内容:
"Webhook URL已设置为。现已启用以下事件:<url>
EVENT_NAME_1EVENT_NAME_2- (列出更新配置中值为
的所有事件)"true
将最终URL存储为。
$WEBHOOK_URL如果为空或未配置:
$RETURN_URL首先,扫描代码库寻找现有返回URL页面或处理程序,该页面/程序可接收Juspay跳转并处理订单状态响应。如果存在,记录其路径并在询问用户时使用。
询问用户:
"您的账户未配置返回URL。请提供支付完成后客户应跳转至的URL。该URL必须是您应用中的真实路由,能够处理支付返回/订单状态响应。"
用户提供URL后,验证其是否与代码库中的现有路由或处理程序匹配。
- 如果匹配,调用:
juspay-mcp:juspay_update_general_settings({ returnUrl: <用户提供的URL> })- 如果不匹配,向用户发出警告:
"您提供的URL似乎不存在于当前代码库的返回处理程序中。确定要使用此URL吗?"
将最终URL存储为。
$RETURN_URL环境始终为生产环境。无需询问用户。使用文档中的生产主机URL。
Step 4B — Auto-provision API key
步骤4B — 自动生成API密钥
Do not ask the user for an API key. Instead, call:
juspay-mcp:juspay_create_api_key({ description: "integrate-skill-<product>-<date>" })Store the returned plaintext value as . Warn the user:
$API_KEY"A new API key has been created for your account for testing this integration"
Never display the key to the user.
不要询问用户索要API密钥。而是调用:
juspay-mcp:juspay_create_api_key({ description: "integrate-skill-<product>-<date>" })将返回的明文值存储为。向用户发出警告:
$API_KEY"已为您的账户创建一个新的API密钥,用于测试此集成"
绝不要向用户显示该密钥。
Step 4C — Collect remaining required params
步骤4C — 收集剩余必填参数
Ask in order:
- Required params — each required field the user must supply (skip auto-generated fields and anything already resolved: $MERCHANT_ID, $CLIENT_ID, $API_KEY, $WEBHOOK_URL)
- Platform version check (SDK path only) — if docs specify a minimum version
- Backend language — if not already detected from codebase
按顺序询问:
- 必填参数 — 用户必须提供的每个必填字段(跳过自动生成的字段和已解析的内容:$MERCHANT_ID、$CLIENT_ID、$API_KEY、$WEBHOOK_URL)
- 平台版本检查(仅SDK流程)— 如果文档指定了最低版本
- 后端语言 — 如果尚未从代码库中检测到
PHASE 5 — Code Generation
阶段5 — 代码生成
Rule: use code examples and method names from fetched docs as the base. Substitute collected values. Do not use method or class names you did not see in the docs.
Generate in order:
-
Auth / credentials setup — use environment variables, never hardcode values
-
Core integration — API call or SDK install → init → open → response handler
-
Webhook handler — if docs have a webhooks section; include signature verification
-
Status verification utility — if docs have a status/order API
-
DB schema — Read existing codebase to generate a DB schema for storing transaction/order IDs, statuses, and any other relevant info for reconciliation and status checks. Use field names from the docs.
- Ask the user if they want to see the raw SQL or a Prisma/TypeORM/Mongoose schema based on their detected backend language/framework.
- If the product has a status API, include fields for storing Juspay order/transaction IDs to correlate with their internal orders.
- Generate validation rules based on any constraints mentioned in the docs (e.g. max length, required fields).
-
Error handling — use error codes from the docs to show how to handle different cases
规则:以获取的文档中的代码示例和方法名为基础,替换收集到的值。绝不要使用文档中未出现的方法或类名。
按顺序生成:
-
认证/凭证设置 — 使用环境变量,绝不硬编码值
-
核心集成 — API调用或SDK安装 → 初始化 → 打开 → 响应处理程序
-
Webhook处理程序 — 如果文档包含webhooks章节;包含签名验证
-
状态验证工具 — 如果文档包含状态/订单API
-
数据库模式 — 读取现有代码库,生成用于存储交易/订单ID、状态及对账和状态检查所需其他相关信息的数据库模式。使用文档中的字段名。
- 根据检测到的后端语言/框架,询问用户是查看原始SQL还是Prisma/TypeORM/Mongoose模式。
- 如果产品具有状态API,包含用于存储Juspay订单/交易ID的字段,以便与内部订单关联。
- 根据文档中提到的约束(例如最大长度、必填字段)生成验证规则。
-
错误处理 — 使用文档中的错误码展示如何处理不同情况
PHASE 6 — Checklist and Error Reference
阶段6 — 检查清单与错误参考
Checklist
检查清单
Generate a checklist from what you actually fetched — every item must reflect something real in this product's docs.
undefined根据实际获取的内容生成检查清单 — 每个条目必须反映该产品文档中的真实内容。
undefinedIntegration Checklist — [Product] on [Platform or API]
集成检查清单 — [产品] 在 [平台或API]
Credentials
凭证
- [credential from docs] stored as env var
- API key generated via dashboard or juspay-mcp
- [文档中的凭证] 存储为环境变量
- API密钥通过仪表板或juspay-mcp生成
[Backend / API]
[后端 / API]
[items derived from API doc pages]
[从API文档页面提取的条目]
[Frontend / SDK] (if applicable)
[前端 / SDK](如适用)
[items derived from SDK doc pages]
[从SDK文档页面提取的条目]
Testing
测试
- Successful sandbox transaction
- Error case from $ERROR_CODES tested
- Webhooks verified end-to-end
- 成功完成沙箱交易
- 测试了$ERROR_CODES中的错误案例
- Webhooks端到端验证通过
Integration Stages (from Juspay)
集成阶段(来自Juspay)
Call:
juspay-mcp:juspay_integration_monitoring_status({
platform: <$PLATFORM mapped to "Backend" | "Web" | "Android" | "IOS">,
product_integrated: <mapped from $PRODUCT — see mapping below>,
merchant_id: $MERCHANT_ID,
start_time: <30 days ago in YYYY-MM-DDTHH:MM:SSZ>,
end_time: <now in YYYY-MM-DDTHH:MM:SSZ>
})
Product mapping for :
product_integrated| $PRODUCT | product_integrated |
|---|---|
| hyper-checkout | Payment Page Session |
| ec-headless | EC + SDK |
| ec-api | EC Only |
| (others) | Payment Page Session |
Platform mapping for :
platform| $PLATFORM | platform |
|---|---|
| web, iframe-web | Web |
| android | Android |
| ios | IOS |
| flutter, react-native, cordova, capacitor | Android |
| api-only products | Backend |
Render the response as a checklist. For each stage where is and is :
visibilityResulttruedisableStagefalseundefined调用:
juspay-mcp:juspay_integration_monitoring_status({
platform: <$PLATFORM映射为"Backend" | "Web" | "Android" | "IOS">,
product_integrated: <从$PRODUCT映射而来 — 见下方映射表>,
merchant_id: $MERCHANT_ID,
start_time: <30天前,格式为YYYY-MM-DDTHH:MM:SSZ>,
end_time: <现在,格式为YYYY-MM-DDTHH:MM:SSZ>
})
product_integrated| $PRODUCT | product_integrated |
|---|---|
| hyper-checkout | Payment Page Session |
| ec-headless | EC + SDK |
| ec-api | EC Only |
| (其他) | Payment Page Session |
platform| $PLATFORM | platform |
|---|---|
| web, iframe-web | Web |
| android | Android |
| ios | IOS |
| flutter, react-native, cordova, capacitor | Android |
| api-only产品 | Backend |
将响应渲染为检查清单。对于每个为且为的阶段:
visibilityResulttruedisableStagefalseundefined[sectionDisplayName or section key]
[sectionDisplayName或章节键]
- [stageDisplayName] ⚠️ Critical ← only if criticalResult is true [stageDescription]
- Do **not** show `status` — it is not updated in real time
- Mark stages with `criticalResult: true` as ⚠️ Critical
- Group stages by their parent section key- [stageDisplayName] ⚠️ 关键 ← 仅当criticalResult为true时标记 [stageDescription]
- 不要展示`status` — 它不会实时更新
- 将`criticalResult: true`的阶段标记为⚠️ 关键
- 按父章节键对阶段进行分组Go-Live
上线准备
- Switched to production environment and keys
- Production end-to-end test passed
undefined- 切换到生产环境和密钥
- 生产环境端到端测试通过
undefinedError Reference
错误参考
undefinedundefinedError Codes
错误码
| Code / Status | Meaning | Recommended action |
|---|---|---|
| [from $ERROR_CODES] |
undefined| 代码 / 状态 | 含义 | 建议操作 |
|---|---|---|
| [来自$ERROR_CODES] |
undefinedWhat's next
下一步
Briefly offer to go deeper on sections from that weren't part of the base integration — but only mention things you actually saw in the doc map.
$DOC_MAP简要提供深入了解中不属于基础集成的章节的选项 — 但仅提及您在文档映射中实际看到的内容。
$DOC_MAPPHASE 7 — Live Testing
阶段7 — 实时测试
Always attempt to run the server and test the integration yourself. Do not tell the user to test manually if you can do it.
始终尝试自行启动服务器并测试集成。如果可以自行完成,绝不要让用户手动测试。
Step 7A — Start the dev server
步骤7A — 启动开发服务器
Scan the codebase for the start command:
| Signal | Command |
|---|---|
| |
| Cannot run — skip to Step 7C |
| Mobile-only project (no web server) | Cannot run — skip to Step 7C |
Run the server in the background, wait for it to be ready, then proceed.
Important: Shell environment variables overridefiles in Vite/Node. Before starting the server, check if any required env vars (e.g..env) are already set in the shell and would conflict with the project'sJUSPAY_API_KEY. Unset them if they don't belong to this project..env
扫描代码库寻找启动命令:
| 信号 | 命令 |
|---|---|
| |
| 无法运行 — 跳至步骤7C |
| 纯移动端项目(无web服务器) | 无法运行 — 跳至步骤7C |
在后台启动服务器,等待其就绪后再继续。
重要提示: 在Vite/Node中,Shell环境变量会覆盖文件。启动服务器前,检查是否有任何必填环境变量(例如.env)已在Shell中设置且与项目的JUSPAY_API_KEY冲突。如果不属于此项目,取消设置这些变量。.env
Step 7B — Run backend API tests
步骤7B — 运行后端API测试
For each backend endpoint generated in Phase 5, send a real HTTP request using and verify both the HTTP response AND any DB/state side-effects:
curl- Session / order creation endpoint — POST with a real order ID from the DB; expect a payment link back; verify is written to the DB row.
juspay_order_id - Order status endpoint — GET with the Juspay order ID from step 1; expect a status response from Juspay.
- Webhook endpoint — POST a synthetic payload using the
ORDER_SUCCEEDEDfrom step 1; usejuspay_order_idand assert the HTTP status code is 200 (Juspay marks a webhook as "not notified" for any non-200 response and retries with progressive delays); also verify the body containscurl -w "%{http_code}"and query the DB to confirm{"status":"ok"}andpayment_statuswere updated.juspay_payment_id - Webhook endpoint (failure) — POST a synthetic payload; assert HTTP 200 and verify
ORDER_FAILEDin the DB.payment_status = failed
If any test fails:
- Read the server logs for the actual error message
- Diagnose and fix the root cause (wrong env var, bad header, type mismatch, etc.)
- Re-run until the test passes
对于阶段5中生成的每个后端端点,使用发送真实HTTP请求,并验证HTTP响应和任何数据库/状态副作用:
curl- 会话/订单创建端点 — 使用数据库中的真实订单ID发送POST请求;期望返回支付链接;验证已写入数据库行。
juspay_order_id - 订单状态端点 — 使用步骤1中的Juspay订单ID发送GET请求;期望从Juspay返回状态响应。
- Webhook端点 — 使用步骤1中的发送模拟
juspay_order_id负载;使用ORDER_SUCCEEDED并断言HTTP状态码为200(Juspay会将任何非200响应标记为“未通知”并逐步延迟重试);同时验证响应体包含curl -w "%{http_code}",并查询数据库确认{"status":"ok"}和payment_status已更新。juspay_payment_id - Webhook端点(失败场景) — 发送模拟负载;断言HTTP 200并验证数据库中
ORDER_FAILED。payment_status = failed
如果任何测试失败:
- 读取服务器日志获取实际错误消息
- 诊断并修复根本原因(错误的环境变量、无效的请求头、类型不匹配等)
- 重新运行直到测试通过
Step 7C — Run browser-based integration stage tests (SDK/web redirect products only)
步骤7C — 运行基于浏览器的集成阶段测试(仅SDK/网页跳转类产品)
This step applies when or and the product uses a Juspay-hosted payment page (web redirect flow).
$PRODUCT_TYPE = sdk$PRODUCT_TYPE = hybridThe integration checklist stages from Phase 6 (New Card, UPI Collect, UPI Intent, Wallet, etc.) are registered on Juspay's servers only when real transactions flow through Juspay's hosted payment page. Some of these can be tested via curls, call out clearly what you can't test instead of silently skipping.
Step 7C-1: Fetch test credentials
fetch the test resources page for the platform:
juspay-docs-mcp:doc_fetch_tool({ url: "<test-resources md content link from $DOC_MAP>" })Extract:
- — card numbers, expiry, CVV for the Dummy PG / simulator
$TEST_CARDS - — VPA values for UPI success/failure (e.g.
$TEST_UPI_VPA,success@upi)failure@upi - — how to trigger success vs failure for each payment method on the simulator
$DUMMY_PG_FLOWS
此步骤适用于或且产品使用Juspay托管支付页面(网页跳转流程)的情况。
$PRODUCT_TYPE = sdk$PRODUCT_TYPE = hybrid阶段6中的集成检查清单阶段(新卡、UPI Collect、UPI Intent、钱包等)仅当真实交易流经Juspay托管支付页面时,才会在Juspay服务器上注册。其中一些可以通过curl测试,明确说明无法测试的内容,不要跳过。
步骤7C-1: 获取测试凭证
获取该平台的测试资源页面:
juspay-docs-mcp:doc_fetch_tool({ url: "<来自$DOC_MAP的测试资源md content link>" })提取:
- — 虚拟PG/模拟器的卡号、有效期、CVV
$TEST_CARDS - — UPI成功/失败的VPA值(例如
$TEST_UPI_VPA、success@upi)failure@upi - — 如何在模拟器上触发每种支付方式的成功/失败场景
$DUMMY_PG_FLOWS
Step 7D — Report results
步骤7D — 报告结果
After all testing, report a unified pass/fail table covering both backend and browser tests:
| Test | Type | Result |
|------|------|--------|
| POST /api/juspay/session → payment link + DB write | Backend | ✅ / ❌ |
| GET /api/juspay/order-status | Backend | ✅ / ❌ |
| POST /api/juspay/webhook ORDER_SUCCEEDED → DB updated | Backend | ✅ / ❌ |
| POST /api/juspay/webhook ORDER_FAILED → DB updated | Backend | ✅ / ❌ |
| Payment Page Opens | Browser | ✅ / ❌ |
| New Card — success | Browser | ✅ / ❌ |
| New Card — failure | Browser | ✅ / ❌ |
| UPI Collect — success | Browser | ✅ / ❌ |
| UPI Collect — failure | Browser | ✅ / ❌ |
| [other visible stages] | Browser | ✅ / ❌ |If a browser test cannot be completed (Juspay payment page blocks headless browsers, CAPTCHA, etc.), say so explicitly — do not silently skip it.
完成所有测试后,生成涵盖后端和浏览器测试的统一通过/失败表格:
| 测试 | 类型 | 结果 |
|------|------|--------|
| POST /api/juspay/session → 支付链接 + 数据库写入 | 后端 | ✅ / ❌ |
| GET /api/juspay/order-status | 后端 | ✅ / ❌ |
| POST /api/juspay/webhook ORDER_SUCCEEDED → 数据库更新 | 后端 | ✅ / ❌ |
| POST /api/juspay/webhook ORDER_FAILED → 数据库更新 | 后端 | ✅ / ❌ |
| 支付页面打开 | 浏览器 | ✅ / ❌ |
| 新卡 — 成功 | 浏览器 | ✅ / ❌ |
| 新卡 — 失败 | 浏览器 | ✅ / ❌ |
| UPI Collect — 成功 | 浏览器 | ✅ / ❌ |
| UPI Collect — 失败 | 浏览器 | ✅ / ❌ |
| [其他可见阶段] | 浏览器 | ✅ / ❌ |如果浏览器测试无法完成(Juspay支付页面阻止无头浏览器、验证码等),明确说明 — 不要跳过。
TOOL CALL REFERENCE
工具调用参考
| When | Tool | Purpose |
| ------------- | ------------------------------------------- | ----------x----------------------------------------------------------------------------------- |
| Phase 0A | Read | Load product summaries for intent matching |
| Phase 0B | | Auto-resolve merchant ID, client ID, integration type — infer recommended product |
| Phase 0D | | Probe type and platforms before recommending |
| Phase 1 | | Get full doc structure and page URLs |
| Phase 3 | | Fetch individual doc pages for implementation details |
| Phase 4A | | Check if webhook URL is already configured |
| Phase 4A | | Check if return URL is already configured |
| Phase 4A | | Configure webhook URL if not already set |
| Phase 4A | | Configure return URL if not already set |
| Phase 4B | | Provision a new API key; returned plaintext shown once |
| Phase 6 | | Fetch live integration stages; render as checklist with criticality + description (no status) |
| Fallback only | WebFetch | Only if returns an error on a valid URL |
products/*.mdjuspay_get_merchant_details()explore_product(candidate-id)explore_product($PRODUCT)doc_fetch_tool(url)juspay_get_webhook_settings()juspay_get_general_settings()juspay_update_webhook_settings(...)juspay_update_general_settings(...)juspay_create_api_key(...)juspay_integration_monitoring_status(...)doc_fetch_toolNever construct doc URLs yourself. All URLs come from the field in responses.
md content linkexplore_product| 时机 | 工具 | 用途 |
|---|---|---|
| 阶段0A | 读取 | 加载产品摘要用于意图匹配 |
| 阶段0B | | 自动解析商户ID、Client ID、集成类型 — 推断推荐产品 |
| 阶段0D | | 推荐前探查产品类型和平台 |
| 阶段1 | | 获取完整文档结构和页面URL |
| 阶段3 | | 获取单个文档页面以获取实现细节 |
| 阶段4A | | 检查webhook URL是否已配置 |
| 阶段4A | | 检查返回URL是否已配置 |
| 阶段4A | | 如果未配置,设置webhook URL |
| 阶段4A | | 如果未配置,设置返回URL |
| 阶段4B | | 生成新的API密钥;返回的明文仅显示一次 |
| 阶段6 | | 获取实时集成阶段;渲染为包含关键程度和描述的检查清单(不包含状态) |
| 仅回退使用 | WebFetch | 仅当 |
绝不要自行构造文档URL。所有URL均来自响应中的字段。
explore_productmd content linkGUARDRAILS
防护规则
-
No product knowledge in this file. Product IDs, platform lists, and credential names come fromor MCP responses — never from this file or training data.
products/ -
Readbefore matching intent. Do not guess which product fits based on training-data familiarity.
products/ -
Callbefore recommending. Phase 0D is mandatory. You must know the product's type and integration complexity before presenting it as a recommendation.
explore_product -
Never construct doc URLs. All URLs come from thefield in
md content linkresponses.explore_product -
Never fabricate. If a page didn't load or a section wasn't in the docs, say so. Offer the raw URL for the user to check manually.
-
Product type comes from. Do not infer type from the product name or training data.
explore_product -
Platform list comes from. Present exactly the platforms that
$DOC_MAPreturned — no more, no less.explore_product -
API-only products never get a platform question. Ifhas no runtime platform IDs, skip platform selection entirely.
$DOC_MAP -
Code examples come from the docs. Use the exact method names, class names, and code structure from the fetched documentation pages as your source of truth.
-
Parameters come from the docs. The actual required fields are what the fetched pages say.
-
Code uses doc-sourced names only. If a method or class name doesn't appear in the fetched pages, do not use it.
-
Error codes come from the docs. Collect them from every page you fetch. Do not invent them.
-
本文件不包含产品知识。 产品ID、平台列表和凭证名称来自或MCP响应 — 绝不能来自本文件或训练数据。
products/ -
匹配意图前先读取。 不要基于训练数据的熟悉度猜测哪种产品合适。
products/ -
推荐前必须调用。 阶段0D是强制性步骤。在将产品作为推荐结果展示前,必须了解产品类型和集成复杂度。
explore_product -
绝不要自行构造文档URL。 所有URL均来自响应中的
explore_product字段。md content link -
绝不要编造内容。 如果页面未加载或文档中不存在某个章节,如实告知用户。提供原始URL供用户手动查看。
-
产品类型来自。 不要从产品名称或训练数据推断类型。
explore_product -
平台列表来自。 准确展示
$DOC_MAP返回的平台 — 不多不少。explore_product -
纯API产品无需询问平台。 如果中没有运行时平台ID,完全跳过平台选择步骤。
$DOC_MAP -
代码示例来自文档。 使用从获取的文档页面中得到的精确方法名、类名和代码结构作为事实来源。
-
参数来自文档。 实际必填字段以获取的页面内容为准。
-
代码仅使用文档中的名称。 如果方法或类名未出现在获取的页面中,不要使用。
-
错误码来自文档。 从获取的每个页面收集错误码。不要自行编造。