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
products/
. Authoritative implementation facts come only from MCP tool calls — never from memory or training.
MCP PREFERENCE: Always prefer
juspay-mcp
tools for live merchant data (credentials, settings, gateway config, integration status). Use
juspay-docs-mcp
only for documentation structure and page content.

核心准则: 本文件是决策引擎,不包含任何产品知识。 产品知识存储在
products/
目录下。权威的实现信息仅来自MCP工具调用——绝不能依赖记忆或训练数据。
MCP优先级: 如需获取商户实时数据(凭证、设置、网关配置、集成状态),优先使用
juspay-mcp
工具。仅在获取文档结构和页面内容时使用
juspay-docs-mcp

AGENT SELF-CHECK (run mentally before each phase)

AGENT自检(每个阶段开始前在脑中执行)

  • Did I authenticate with
    juspay-mcp
    before calling any
    juspay-mcp
    tools? If not, Please trigger the authentication flow now.
  • Did I call
    juspay_get_merchant_details
    to establish merchant context before asking for credentials?
  • Did I read
    products/
    before calling
    explore_product
    ? Can I conclude from the catalog alone?
  • Did I scan the codebase before asking disambiguation questions (language, framework)?
  • Did I call
    doc_fetch_tool
    before writing any code?
  • 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:
FlagEffect
--product <id>
Skip recommendation. Confirm the product in one line, then go to Phase 1. Still run catalog-first check.
--platform <id>
Hint for platform selection in Phase 2 — still verify against codebase before asking.

开始前先提取标志:
标志作用
--product <id>
跳过推荐环节。用一句话确认产品后直接进入阶段1。仍需先执行目录检查。
--platform <id>
为阶段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
    juspay-mcp
    live data, or from the catalog
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
products/
. Each file has: product ID, platforms, use cases, and intent signals.
Store the full set as
$PRODUCT_CATALOG
. This is your local knowledge for matching — do not use training-data knowledge about products.
读取
products/
目录下的所有文件。每个文件包含:产品ID、平台、使用场景和意图信号。
将完整集合存储为
$PRODUCT_CATALOG
。这是用于匹配的本地知识——请勿使用关于产品的训练数据知识。

Step 0B — Auto-resolve integration type from merchant account

步骤0B — 通过商户账户自动解析集成类型

Call:
juspay-mcp:juspay_get_merchant_details()
Extract and store:
  • $MERCHANT_ID
    — from the
    merchantId
    field
  • $CLIENT_ID
    — always default to
    $MERCHANT_ID
    . Never extract this from the API response. Inform the user:
    "Client ID is typically the same as your merchant ID (
    $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.
  • $INTEGRATION_TYPE
    — from the
    integrationType
    field, which is an array; take the first element (e.g.
    ["PP"]
    "PP"
    )
Map
$INTEGRATION_TYPE
to a recommended product:
$INTEGRATION_TYPE
Recommended product ID
PP
hyper-checkout
ec_sdk
ec-headless
ec_api
ec-api
(anything else or absent)No inference — fall back to Step 0B-Fallback
调用:
juspay-mcp:juspay_get_merchant_details()
提取并存储:
  • $MERCHANT_ID
    — 来自
    merchantId
    字段
  • $CLIENT_ID
    — 始终默认使用
    $MERCHANT_ID
    绝不要从API响应中提取此字段。告知用户:
    "Client ID通常与您的商户ID(
    $MERCHANT_ID
    )相同。如果您使用不同的Client ID,请现在提供——否则我将使用
    $MERCHANT_ID
    继续。" 等待用户确认或提供自定义值后再继续。
  • $INTEGRATION_TYPE
    — 来自
    integrationType
    字段,该字段为数组;取第一个元素(例如
    ["PP"]
    "PP"
$INTEGRATION_TYPE
映射为推荐产品:
$INTEGRATION_TYPE
推荐产品ID
PP
hyper-checkout
ec_sdk
ec-headless
ec_api
ec-api
(其他值或为空)不进行推断——回退到步骤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]?
  1. Yes, proceed
  2. No, let me choose a different product type
  3. No, let me choose a specific product"
  • Option 1 → set
    $PRODUCT
    to the inferred product ID and skip to Phase 1
  • Option 2 → go to Step 0B-Fallback (product type list)
  • Option 3 → show the full flat product list from
    $PRODUCT_CATALOG
    and let the user pick directly
如果找到映射关系,展示单一确认选项:
"根据您的账户配置,看起来您已准备好集成**[产品名称]**。
是否继续集成**[产品名称]**?
  1. 是,继续
  2. 否,让我选择其他类型的产品
  3. 否,让我选择特定产品"
  • 选项1 → 将
    $PRODUCT
    设置为推断的产品ID,直接跳至阶段1
  • 选项2 → 进入步骤0B-Fallback(产品类型列表)
  • 选项3 → 展示
    $PRODUCT_CATALOG
    中的完整产品列表,让用户直接选择

Step 0B-Fallback — Ask the user what they want to build

步骤0B-Fallback — 询问用户的搭建需求

Only reached if
$INTEGRATION_TYPE
is absent, unrecognized, or the user chose Option 2 above.
What type of product are you looking to integrate?
  1. Checkout
  2. UPI
  3. Payouts
  4. Billing
  5. Not sure

仅当
$INTEGRATION_TYPE
不存在、无法识别,或用户选择上述选项2时进入此步骤。
您希望集成哪种类型的产品?
  1. 结账
  2. UPI
  3. 付款
  4. 账单
  5. 不确定

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
.
询问:
请描述您的使用场景,我将为您推荐合适的产品和集成流程。
将内容存储为
$INTENT

Step 0C — Match intent to candidates

步骤0C — 将意图与候选产品匹配

Using
$INTENT
and the
intent signals
field in each
$PRODUCT_CATALOG
entry, select 1–3 products as
$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.
使用
$INTENT
和每个
$PRODUCT_CATALOG
条目中的
intent signals
字段,选择1–3个产品作为
$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
explore_product
, check if the catalog entry is conclusive:
A catalog entry is conclusive if:
  • The
    platforms
    list either matches
    $DETECTED_PLATFORM
    exactly, or has only one option
  • No further platform disambiguation is required to start code generation
If conclusive → skip
explore_product
for this candidate and proceed. If not conclusive (e.g. multiple overlapping platforms, need page count for complexity signal) → call:
juspay-docs-mcp:explore_product({ product: <candidate-id> })
Extract only what you need for recommendation:
  • Product title
  • Platform IDs — runtime IDs signal a client SDK;
    docs
    only signals a server API; a mix signals both
  • 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_product
调用,直接继续。 如果不具有决定性(例如多个重叠平台、需要页面数量来判断复杂度)→ 调用:
juspay-docs-mcp:explore_product({ product: <candidate-id> })
仅提取推荐所需的信息:
  • 产品标题
  • 平台ID — 运行时ID表示客户端SDK;仅
    docs
    表示服务器API;混合表示两者兼具
  • 基础集成页面的编号数量(复杂度信号)
  • 如果是客户端SDK,列出支持的平台
在此步骤不要获取单个文档页面。

Step 0E — Recommend and confirm

步骤0E — 推荐并确认

Present your recommendation grounded in what you read from
products/
and
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
$PRODUCT_CATALOG
as a numbered reference so the user can override.
Store the confirmed choice as
$PRODUCT
(the product ID from the products/ file).

基于从
products/
explore_product
中获取的信息,展示推荐结果:
"根据您的描述,我推荐:
[产品标题] — [与您的意图相关的一句话理由]
(备选) [产品标题] — [理由]
您希望集成哪款?或从下方完整列表中选择:"
$PRODUCT_CATALOG
中的所有产品列为编号选项,以便用户可以覆盖推荐结果。
将用户确认的选择存储为
$PRODUCT
(来自products/文件的产品ID)。

PHASE 1 — Full Product Exploration

阶段1 — 完整产品探查

Only call
explore_product
if it wasn't already called in Phase 0D for
$PRODUCT
.
If already called and
$DOC_MAP
is populated → skip directly to Phase 1A.
Otherwise call:
juspay-docs-mcp:explore_product({ product: $PRODUCT })
Read the full response. This is the authoritative doc structure.
仅当阶段0D中未针对
$PRODUCT
调用
explore_product
时,才调用该工具。
如果已调用且
$DOC_MAP
已填充 → 直接跳至阶段1A。
否则调用:
juspay-docs-mcp:explore_product({ product: $PRODUCT })
读取完整响应。这是权威的文档结构。

1A — Parse into $DOC_MAP

1A — 解析为$DOC_MAP

Extract and store:
  • Product title and description
  • platforms[]
    — every platform entry with its ID and title
  • For each platform:
    sections[]
    → for each section:
    sectionTitle
    ,
    pages[]
  • For each page:
    pageTitle
    and the
    md content link
    URL
Pages numbered "1. …", "2. …" are base integration pages in required order. Preserve that order exactly.
提取并存储:
  • 产品标题和描述
  • platforms[]
    — 每个平台条目及其ID和标题
  • 每个平台对应的
    sections[]
    → 每个章节对应的
    sectionTitle
    pages[]
  • 每个页面对应的
    pageTitle
    md content link
    URL
编号为"1. …"、"2. …"的页面是按要求顺序排列的基础集成页面。必须严格保留该顺序。

1B — Classify product type

1B — 产品类型分类

Platform IDs observedClassification
Runtime IDs:
android
,
ios
,
web
,
flutter
,
react-native
,
cordova
,
capacitor
,
iframe-web
$PRODUCT_TYPE = sdk
Only
docs
$PRODUCT_TYPE = api-only
Mix of
docs
+ runtime IDs
$PRODUCT_TYPE = hybrid
Store as
$PRODUCT_TYPE
.

观察到的平台ID分类
运行时ID:
android
ios
web
flutter
react-native
cordova
capacitor
iframe-web
$PRODUCT_TYPE = sdk
仅包含
docs
$PRODUCT_TYPE = api-only
docs
+ 运行时ID混合
$PRODUCT_TYPE = hybrid
将结果存储为
$PRODUCT_TYPE

PHASE 2 — Adaptive Flow

阶段2 — 自适应流程

Branch on
$PRODUCT_TYPE
:
根据
$PRODUCT_TYPE
分支处理:

If
api-only

如果是
api-only

No platform question. Backend language comes from
$DETECTED_LANG
— only ask if not detected.
无需询问平台。后端语言来自
$DETECTED_LANG
— 仅当未检测到时才询问用户。

If
sdk

如果是
sdk

Step 2-SDK-A — Detect platform from codebase
Before asking the user, scan the working directory for platform signals:
File / pattern foundDetected platform
pubspec.yaml
flutter
package.json
with
react-native
in dependencies
react-native
package.json
with
@capacitor/core
in dependencies
capacitor
config.xml
or
package.json
with
cordova
in dependencies
cordova
build.gradle
or
AndroidManifest.xml
(no Flutter/RN/Cordova/Capacitor signals)
android
*.xcodeproj
or
Podfile
(no Flutter/RN signals)
ios
package.json
with no mobile framework signals, or
index.html
/
.html
files
web
or
iframe-web
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]?
  1. Yes, use [Platform]
  2. 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_MAP
.
Step 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
    web
    and
    iframe-web
    are in the doc map, ask which variant
Store as
$PLATFORM
. Filter
$DOC_MAP
to the chosen platform's pages.
步骤2-SDK-A — 从代码库检测平台
询问用户前,扫描工作目录寻找平台信号:
找到的文件/模式检测到的平台
pubspec.yaml
flutter
package.json
的依赖中包含
react-native
react-native
package.json
的依赖中包含
@capacitor/core
capacitor
config.xml
package.json
的依赖中包含
cordova
cordova
build.gradle
AndroidManifest.xml
(无Flutter/RN/Cordova/Capacitor信号)
android
*.xcodeproj
Podfile
(无Flutter/RN信号)
ios
package.json
无移动框架信号,或存在
index.html
/
.html
文件
web
iframe-web
如果以较高置信度检测到平台,将其作为预选推荐展示给用户:
"我检测到您的项目是**[平台]**应用(找到
[信号文件]
)。
是否继续使用**[平台]**?
  1. 是,使用[平台]
  2. 否,让我选择其他平台"
如果用户确认,跳至歧义消除步骤。如果用户选择选项2,或未检测到信号,展示
$DOC_MAP
中的完整平台列表。
步骤2-SDK-B — 歧义消除
确认平台后执行:
  • Android:询问Java还是Kotlin
  • iOS:询问Swift还是Objective-C,CocoaPods还是SPM
  • Web:如果文档映射中同时存在
    web
    iframe-web
    ,询问使用哪种变体
将结果存储为
$PLATFORM
。过滤
$DOC_MAP
,仅保留所选平台的页面。

If
hybrid

如果是
hybrid

Ask first:
"This product has both a backend API and a client SDK. What do you need?
  1. Backend API only
  2. Client SDK only
  3. Both"
Then follow the
api-only
path,
sdk
path, or both, as appropriate.

首先询问:
"该产品同时包含后端API和客户端SDK。您需要哪种?
  1. 仅后端API
  2. 仅客户端SDK
  3. 两者都要"
然后根据选择,分别遵循
api-only
流程、
sdk
流程,或两者兼顾。

PHASE 3 — Doc Fetch

阶段3 — 文档获取

Always use
doc_fetch_tool
. Only fall back to WebFetch if MCP returns an explicit error on a valid URL.
juspay-docs-mcp:doc_fetch_tool({ url: "<md content link from $DOC_MAP>" })
Fetch order:
  1. Pre-Requisites / Overview — always first; defines credentials, auth format, version constraints
  2. Numbered base integration pages — in exact numbered order from
    explore_product
  3. Webhooks, Order Status API
  4. Error Codes (resources section)
  5. Advanced sections — only if user asks
While reading each page, extract and store:
  • $PARAMS
    — every request field, method param, constructor arg (required vs optional)
  • $CODE_EXAMPLES
    — exact method names, class names, key identifiers from the docs
  • $ERROR_CODES
    — all status values, error codes, failure reasons
  • $VERSION_CONSTRAINTS
    — min SDK version, min language/platform version
  • $WARNINGS
    — any "note", "important", "warning" callout blocks

始终使用
doc_fetch_tool
。仅当MCP对有效URL返回明确错误时,才回退使用WebFetch。
juspay-docs-mcp:doc_fetch_tool({ url: "<来自$DOC_MAP的md content link>" })
获取顺序:
  1. 先决条件/概述 — 始终优先获取;定义凭证、认证格式、版本约束
  2. 编号的基础集成页面 — 严格按照
    explore_product
    返回的编号顺序获取
  3. Webhooks、订单状态API
  4. 错误码(资源章节)
  5. 高级章节 — 仅当用户要求时获取
读取每个页面时,提取并存储:
  • $PARAMS
    — 每个请求字段、方法参数、构造函数参数(必填/可选)
  • $CODE_EXAMPLES
    — 文档中的精确方法名、类名、关键标识符
  • $ERROR_CODES
    — 所有状态值、错误码、失败原因
  • $VERSION_CONSTRAINTS
    — 最小SDK版本、最小语言/平台版本
  • $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
, and
$INTEGRATION_TYPE
were already fetched in Phase 0B — reuse those values. Do not call
juspay_get_merchant_details()
again.
Then call both in parallel:
juspay-mcp:juspay_get_webhook_settings()
juspay-mcp:juspay_get_general_settings()
From webhook settings, extract:
  • $WEBHOOK_URL
    — existing webhook URL if configured (check if non-empty)
  • $WEBHOOK_EVENTS
    — currently subscribed events
From general settings, extract:
  • $RETURN_URL
    — existing return URL if configured (check if non-empty)
If
$WEBHOOK_URL
is empty or not configured:
First, scan the codebase for an existing webhook handler (e.g.
api/juspay/webhook
,
api/webhook
,
webhooks
route). If one exists, note its path as
$WEBHOOK_PATH
.
Then ask the user:
"No webhook URL is configured. Your app has a webhook handler at
$WEBHOOK_PATH
. Please provide your deployed base URL so I can set it to
https://<your-domain>/$WEBHOOK_PATH
.
If you don't have a deployed URL yet, you can:
  • Run
    ngrok http <port>
    locally to get a temporary public URL
  • Leave this for now and configure it on the Juspay dashboard before going live"
Do not set a placeholder URL (e.g.
https://www.webhook.com
) — only call
juspay_update_webhook_settings
if the user provides a real, publicly reachable HTTPS URL that routes to the webhook handler.
Once 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
<url>
. The following events are now enabled:
  • EVENT_NAME_1
  • EVENT_NAME_2
  • (list every event where the value is
    true
    in the updated config)
    "
Store the final URL as
$WEBHOOK_URL
.
If
$RETURN_URL
is empty or not configured:
First, 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_URL
.
Environment is always production. Do not ask the user. Use production host URLs from the docs.
$MERCHANT_ID
$CLIENT_ID
$INTEGRATION_TYPE
已在阶段0B中获取 — 复用这些值。请勿再次调用
juspay_get_merchant_details()
然后并行调用:
juspay-mcp:juspay_get_webhook_settings()
juspay-mcp:juspay_get_general_settings()
从webhook设置中提取:
  • $WEBHOOK_URL
    — 如果已配置,获取现有webhook URL(检查是否非空)
  • $WEBHOOK_EVENTS
    — 当前已订阅的事件
从常规设置中提取:
  • $RETURN_URL
    — 如果已配置,获取现有返回URL(检查是否非空)
如果
$WEBHOOK_URL
为空或未配置:
首先,扫描代码库寻找现有webhook处理程序(例如
api/juspay/webhook
api/webhook
webhooks
路由)。如果存在,将其路径记录为
$WEBHOOK_PATH
然后询问用户:
"未配置webhook URL。您的应用在
$WEBHOOK_PATH
处有一个webhook处理程序。 请提供您的部署基础URL,以便我将其设置为
https://<your-domain>/$WEBHOOK_PATH
如果您还没有部署URL,可以:
  • 在本地运行
    ngrok http <port>
    获取临时公共URL
  • 暂时跳过此步骤,在上线前在Juspay仪表板上配置"
不要设置占位符URL(例如
https://www.webhook.com
)——仅当用户提供可公开访问的真实HTTPS URL且该URL可路由至webhook处理程序时,才调用
juspay_update_webhook_settings
提供有效URL后,调用:
juspay-mcp:juspay_update_webhook_settings({
  webHookurl: <base-url> + "/" + <$WEBHOOK_PATH>,
  webhookEvents: <将现有$WEBHOOK_EVENTS与该产品的标准事件合并>
})
更新后,确认设置内容:
"Webhook URL已设置为
<url>
。现已启用以下事件:
  • EVENT_NAME_1
  • EVENT_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
$API_KEY
. Warn the user:
"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:
  1. 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)
  2. Platform version check (SDK path only) — if docs specify a minimum version
  3. Backend language — if not already detected from codebase

按顺序询问:
  1. 必填参数 — 用户必须提供的每个必填字段(跳过自动生成的字段和已解析的内容:$MERCHANT_ID、$CLIENT_ID、$API_KEY、$WEBHOOK_URL)
  2. 平台版本检查(仅SDK流程)— 如果文档指定了最低版本
  3. 后端语言 — 如果尚未从代码库中检测到

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:
  1. Auth / credentials setup — use environment variables, never hardcode values
  2. Core integration — API call or SDK install → init → open → response handler
  3. Webhook handler — if docs have a webhooks section; include signature verification
  4. Status verification utility — if docs have a status/order API
  5. 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).
  6. Error handling — use error codes from the docs to show how to handle different cases

规则:以获取的文档中的代码示例和方法名为基础,替换收集到的值。绝不要使用文档中未出现的方法或类名。
按顺序生成:
  1. 认证/凭证设置 — 使用环境变量,绝不硬编码值
  2. 核心集成 — API调用或SDK安装 → 初始化 → 打开 → 响应处理程序
  3. Webhook处理程序 — 如果文档包含webhooks章节;包含签名验证
  4. 状态验证工具 — 如果文档包含状态/订单API
  5. 数据库模式 — 读取现有代码库,生成用于存储交易/订单ID、状态及对账和状态检查所需其他相关信息的数据库模式。使用文档中的字段名。
    • 根据检测到的后端语言/框架,询问用户是查看原始SQL还是Prisma/TypeORM/Mongoose模式。
    • 如果产品具有状态API,包含用于存储Juspay订单/交易ID的字段,以便与内部订单关联。
    • 根据文档中提到的约束(例如最大长度、必填字段)生成验证规则。
  6. 错误处理 — 使用文档中的错误码展示如何处理不同情况

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
根据实际获取的内容生成检查清单 — 每个条目必须反映该产品文档中的真实内容。
undefined

Integration 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
:
$PRODUCTproduct_integrated
hyper-checkoutPayment Page Session
ec-headlessEC + SDK
ec-apiEC Only
(others)Payment Page Session
Platform mapping for
platform
:
$PLATFORMplatform
web, iframe-webWeb
androidAndroid
iosIOS
flutter, react-native, cordova, capacitorAndroid
api-only productsBackend
Render the response as a checklist. For each stage where
visibilityResult
is
true
and
disableStage
is
false
:
undefined
调用:

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
产品映射表:
$PRODUCTproduct_integrated
hyper-checkoutPayment Page Session
ec-headlessEC + SDK
ec-apiEC Only
(其他)Payment Page Session
platform
平台映射表:
$PLATFORMplatform
web, iframe-webWeb
androidAndroid
iosIOS
flutter, react-native, cordova, capacitorAndroid
api-only产品Backend
将响应渲染为检查清单。对于每个
visibilityResult
true
disableStage
false
的阶段:
undefined

[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
  • 切换到生产环境和密钥
  • 生产环境端到端测试通过
undefined

Error Reference

错误参考

undefined
undefined

Error Codes

错误码

Code / StatusMeaningRecommended action
[from $ERROR_CODES]
undefined
代码 / 状态含义建议操作
[来自$ERROR_CODES]
undefined

What's next

下一步

Briefly offer to go deeper on sections from
$DOC_MAP
that weren't part of the base integration — but only mention things you actually saw in the doc map.

简要提供深入了解
$DOC_MAP
中不属于基础集成的章节的选项 — 但仅提及您在文档映射中实际看到的内容。

PHASE 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:
SignalCommand
package.json
with
"dev"
script
npm run dev
(or
yarn dev
)
pubspec.yaml
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 override
.env
files in Vite/Node. Before starting the server, check if any required env vars (e.g.
JUSPAY_API_KEY
) are already set in the shell and would conflict with the project's
.env
. Unset them if they don't belong to this project.
扫描代码库寻找启动命令:
信号命令
package.json
包含
"dev"
脚本
npm run dev
(或
yarn dev
pubspec.yaml
无法运行 — 跳至步骤7C
纯移动端项目(无web服务器)无法运行 — 跳至步骤7C
在后台启动服务器,等待其就绪后再继续。
重要提示: 在Vite/Node中,Shell环境变量会覆盖
.env
文件。启动服务器前,检查是否有任何必填环境变量(例如
JUSPAY_API_KEY
)已在Shell中设置且与项目的
.env
冲突。如果不属于此项目,取消设置这些变量。

Step 7B — Run backend API tests

步骤7B — 运行后端API测试

For each backend endpoint generated in Phase 5, send a real HTTP request using
curl
and verify both the HTTP response AND any DB/state side-effects:
  1. Session / order creation endpoint — POST with a real order ID from the DB; expect a payment link back; verify
    juspay_order_id
    is written to the DB row.
  2. Order status endpoint — GET with the Juspay order ID from step 1; expect a status response from Juspay.
  3. Webhook endpoint — POST a synthetic
    ORDER_SUCCEEDED
    payload using the
    juspay_order_id
    from step 1; use
    curl -w "%{http_code}"
    and 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 contains
    {"status":"ok"}
    and query the DB to confirm
    payment_status
    and
    juspay_payment_id
    were updated.
  4. Webhook endpoint (failure) — POST a synthetic
    ORDER_FAILED
    payload; assert HTTP 200 and verify
    payment_status = failed
    in the DB.
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中生成的每个后端端点,使用
curl
发送真实HTTP请求,并验证HTTP响应和任何数据库/状态副作用:
  1. 会话/订单创建端点 — 使用数据库中的真实订单ID发送POST请求;期望返回支付链接;验证
    juspay_order_id
    已写入数据库行。
  2. 订单状态端点 — 使用步骤1中的Juspay订单ID发送GET请求;期望从Juspay返回状态响应。
  3. Webhook端点 — 使用步骤1中的
    juspay_order_id
    发送模拟
    ORDER_SUCCEEDED
    负载;使用
    curl -w "%{http_code}"
    并断言HTTP状态码为200(Juspay会将任何非200响应标记为“未通知”并逐步延迟重试);同时验证响应体包含
    {"status":"ok"}
    ,并查询数据库确认
    payment_status
    juspay_payment_id
    已更新。
  4. Webhook端点(失败场景) — 发送模拟
    ORDER_FAILED
    负载;断言HTTP 200并验证数据库中
    payment_status = failed
如果任何测试失败:
  • 读取服务器日志获取实际错误消息
  • 诊断并修复根本原因(错误的环境变量、无效的请求头、类型不匹配等)
  • 重新运行直到测试通过

Step 7C — Run browser-based integration stage tests (SDK/web redirect products only)

步骤7C — 运行基于浏览器的集成阶段测试(仅SDK/网页跳转类产品)

This step applies when
$PRODUCT_TYPE = sdk
or
$PRODUCT_TYPE = hybrid
and the product uses a Juspay-hosted payment page (web redirect flow).
The 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:
  • $TEST_CARDS
    — card numbers, expiry, CVV for the Dummy PG / simulator
  • $TEST_UPI_VPA
    — VPA values for UPI success/failure (e.g.
    success@upi
    ,
    failure@upi
    )
  • $DUMMY_PG_FLOWS
    — how to trigger success vs failure for each payment method on the simulator
此步骤适用于
$PRODUCT_TYPE = sdk
$PRODUCT_TYPE = hybrid
且产品使用Juspay托管支付页面(网页跳转流程)的情况。
阶段6中的集成检查清单阶段(新卡、UPI Collect、UPI Intent、钱包等)仅当真实交易流经Juspay托管支付页面时,才会在Juspay服务器上注册。其中一些可以通过curl测试,明确说明无法测试的内容,不要跳过。
步骤7C-1: 获取测试凭证
获取该平台的测试资源页面:
juspay-docs-mcp:doc_fetch_tool({ url: "<来自$DOC_MAP的测试资源md content link>" })
提取:
  • $TEST_CARDS
    — 虚拟PG/模拟器的卡号、有效期、CVV
  • $TEST_UPI_VPA
    — 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
products/*.md
| Load product summaries for intent matching | | Phase 0B |
juspay_get_merchant_details()
| Auto-resolve merchant ID, client ID, integration type — infer recommended product | | Phase 0D |
explore_product(candidate-id)
| Probe type and platforms before recommending | | Phase 1 |
explore_product($PRODUCT)
| Get full doc structure and page URLs | | Phase 3 |
doc_fetch_tool(url)
| Fetch individual doc pages for implementation details | | Phase 4A |
juspay_get_webhook_settings()
| Check if webhook URL is already configured | | Phase 4A |
juspay_get_general_settings()
| Check if return URL is already configured | | Phase 4A |
juspay_update_webhook_settings(...)
| Configure webhook URL if not already set | | Phase 4A |
juspay_update_general_settings(...)
| Configure return URL if not already set | | Phase 4B |
juspay_create_api_key(...)
| Provision a new API key; returned plaintext shown once | | Phase 6 |
juspay_integration_monitoring_status(...)
| Fetch live integration stages; render as checklist with criticality + description (no status) | | Fallback only | WebFetch | Only if
doc_fetch_tool
returns an error on a valid URL |
Never construct doc URLs yourself. All URLs come from the
md content link
field in
explore_product
responses.

时机工具用途
阶段0A读取
products/*.md
加载产品摘要用于意图匹配
阶段0B
juspay_get_merchant_details()
自动解析商户ID、Client ID、集成类型 — 推断推荐产品
阶段0D
explore_product(candidate-id)
推荐前探查产品类型和平台
阶段1
explore_product($PRODUCT)
获取完整文档结构和页面URL
阶段3
doc_fetch_tool(url)
获取单个文档页面以获取实现细节
阶段4A
juspay_get_webhook_settings()
检查webhook URL是否已配置
阶段4A
juspay_get_general_settings()
检查返回URL是否已配置
阶段4A
juspay_update_webhook_settings(...)
如果未配置,设置webhook URL
阶段4A
juspay_update_general_settings(...)
如果未配置,设置返回URL
阶段4B
juspay_create_api_key(...)
生成新的API密钥;返回的明文仅显示一次
阶段6
juspay_integration_monitoring_status(...)
获取实时集成阶段;渲染为包含关键程度和描述的检查清单(不包含状态)
仅回退使用WebFetch仅当
doc_fetch_tool
对有效URL返回错误时使用
绝不要自行构造文档URL。所有URL均来自
explore_product
响应中的
md content link
字段。

GUARDRAILS

防护规则

  1. No product knowledge in this file. Product IDs, platform lists, and credential names come from
    products/
    or MCP responses — never from this file or training data.
  2. Read
    products/
    before matching intent.
    Do not guess which product fits based on training-data familiarity.
  3. Call
    explore_product
    before recommending.
    Phase 0D is mandatory. You must know the product's type and integration complexity before presenting it as a recommendation.
  4. Never construct doc URLs. All URLs come from the
    md content link
    field in
    explore_product
    responses.
  5. 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.
  6. Product type comes from
    explore_product
    .
    Do not infer type from the product name or training data.
  7. Platform list comes from
    $DOC_MAP
    .
    Present exactly the platforms that
    explore_product
    returned — no more, no less.
  8. API-only products never get a platform question. If
    $DOC_MAP
    has no runtime platform IDs, skip platform selection entirely.
  9. 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.
  10. Parameters come from the docs. The actual required fields are what the fetched pages say.
  11. Code uses doc-sourced names only. If a method or class name doesn't appear in the fetched pages, do not use it.
  12. Error codes come from the docs. Collect them from every page you fetch. Do not invent them.
  1. 本文件不包含产品知识。 产品ID、平台列表和凭证名称来自
    products/
    或MCP响应 — 绝不能来自本文件或训练数据。
  2. 匹配意图前先读取
    products/
    不要基于训练数据的熟悉度猜测哪种产品合适。
  3. 推荐前必须调用
    explore_product
    阶段0D是强制性步骤。在将产品作为推荐结果展示前,必须了解产品类型和集成复杂度。
  4. 绝不要自行构造文档URL。 所有URL均来自
    explore_product
    响应中的
    md content link
    字段。
  5. 绝不要编造内容。 如果页面未加载或文档中不存在某个章节,如实告知用户。提供原始URL供用户手动查看。
  6. 产品类型来自
    explore_product
    不要从产品名称或训练数据推断类型。
  7. 平台列表来自
    $DOC_MAP
    准确展示
    explore_product
    返回的平台 — 不多不少。
  8. 纯API产品无需询问平台。 如果
    $DOC_MAP
    中没有运行时平台ID,完全跳过平台选择步骤。
  9. 代码示例来自文档。 使用从获取的文档页面中得到的精确方法名、类名和代码结构作为事实来源。
  10. 参数来自文档。 实际必填字段以获取的页面内容为准。
  11. 代码仅使用文档中的名称。 如果方法或类名未出现在获取的页面中,不要使用。
  12. 错误码来自文档。 从获取的每个页面收集错误码。不要自行编造。