> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/tuo-guan-zu-jian-ji-cheng/ka-pian/gong-zuo-yuan-li.md).

# 工作原理

本节介绍使用卡支付托管组件时的高级支付流程。该流程图展示了托管组件如何参与更广泛的卡交易生命周期。

<img src="https://coda-payments.gitbook.io/coda-public-technical-documentation/~gitbook/image?url=https%3A%2F%2F611292228-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fl56STCN5yoV1K1MhVEvU%252Fuploads%252FML9GA6WNjzDZX9RsMNrC%252FScreenshot%25202026-03-05%2520at%252010.03.32%25E2%2580%25AFAM.png%3Falt%3Dmedia%26token%3D345b7ba6-94f5-491a-bfe7-75565fdcb027&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=bfb6ba16&#x26;sv=2" alt="" height="1980" width="2332">

**高级流程描述**

1. **发起支付：**&#x7528;户发起支付。您的后端[通过调用 \`Coda.createPaymentSession\` 方法创建支付会话`POST /init.json`](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/initiate-a-payment-request)。Coda 返回一个交易 ID 和一个客户端密钥。
2. **初始化 SDK**：使用`clientSecret`后端提供的[SDK 初始化托管组件 SDK](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/interact-with-the-codacard-sdk)。卡片表单将在结账容器中安全地渲染。
3. **就绪状态监控：**&#x60A8;的前端会监听状态[`isReady`。](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/interact-with-the-codacard-sdk#on-event-callback)当用户填写完所有必填字段时，此状态会通知您的用户界面。
4. **提交：**&#x5F53;用户点击您的“支付”按钮时，您的前端会调用[SDK 的`submit()`方法](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/interact-with-the-codacard-sdk#submit)，该方法会将敏感数据直接转发给 Coda。
5. **身份验证（如果需要）**：如果卡片需要 3D 安全验证或其他身份验证，该组件会打开一个安全模态框，供用户完成验证流程。
6. **通知：**&#x4ED8;款成功后，付款状态将转换`SUCCESS`，并向您的后端发送通知。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/tuo-guan-zu-jian-ji-cheng/ka-pian/gong-zuo-yuan-li.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
