> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stripe - 连接 & 原始卡片API访问

> 利用 Dodo Payments 的 PCI DSS AOC 启用 Stripe 的原始卡数据API访问，然后将您的 Stripe 账户连接到自带支付处理器（BYOP）。

<Note>
  当您通过[自带支付处理器（BYOP）](/features/byop)连接 **Stripe** 作为自己的处理器时，适用于本指南。如需帮助，[联系我们](mailto:founders@dodopayments.com)。
</Note>

## 启用原始卡数据访问

为了通过您的 Stripe 账户路由支付，同时由 Dodo Payments 支持账单，Dodo 需要使用 Stripe 的 **原始卡数据API** 代您传递卡片详细信息。

默认情况下，Stripe 账户不能直接将原始卡号（PAN）发送到其API。Stripe 通过一个确认处理原始卡数据的系统符合 **PCI DSS 标准**的批准来限制此功能。使用 BYOP 时，处理卡数据的系统是 **Dodo Payments**，其符合 PCI DSS 一级标准——因此您使用 Dodo Payments 的认证来证明合规，而不是您自己的。每个账户只需请求一次此访问。

当您请求访问时，Stripe 会要求提供一段简短的描述说明卡数据的处理方式——说明 **Dodo Payments**，您的 PCI DSS 一级合规支付提供商，处理原始卡数据，而您自己的系统从未存储或处理原始卡号（PAN）。因为 Dodo Payments 处理数据，您无需自己准备 SAQ D；提交 **Dodo Payments 的合规证明（AOC）** 作为您的证明：

<Card title="Dodo Payments PCI DSS Attestation of Compliance (AOC)" icon="file-shield" href="https://pub-2a89184e4c954b599464449d23f506bb.r2.dev/dodo-payments-pci-dss-aoc.pdf">
  下载 Dodo Payments 当前的 AOC 并在请求原始卡数据访问时提交给 Stripe。
</Card>

<Tip>
  **测试模式不需要文档。** 您可以立即要求 Stripe 启用 **测试模式** 的原始卡数据API，以便构建和验证您的 BYOP 设置。实时模式仍然需要上面的 Dodo Payments AOC。
</Tip>

通过 Stripe 的官方指南直接请求访问，并在 Stripe 要求 PCI 文档时提交 Dodo Payments AOC：

<Card title="Enabling access to raw card data APIs" icon="stripe" href="https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis">
  Stripe 关于请求您帐户上原始卡数据API访问的指南。
</Card>

## 您需要准备的

一旦 Stripe 确认了原始卡数据访问权限，在 **设置 → BYOP** 中连接 Stripe。从您的 Stripe 仪表板收集两个值：

| 值               | 来源             |
| --------------- | -------------- |
| **Secret key**  | 开发者 → API keys |
| **Webhook签名密钥** | 添加 webhook 时生成 |

<Info>
  Stripe 维护 **测试** 和 **实时** 凭据分开——在仪表板中通过 **Test mode / Live mode** 切换。生成与您在 Dodo 中配置模式匹配的环境中的凭据。
</Info>

## 步骤 1：获取您的 secret key

<Steps>
  <Step title="Open API keys">
    在 Stripe 仪表板中，前往 **开发者 → API keys**。使用 **Test mode / Live mode** 开关来匹配您配置的环境。
  </Step>

  <Step title="Copy your secret key">
    复制 **Secret key** — 它以 `sk_test_` 开头用于测试模式，或以 `sk_live_` 开头用于实时模式（若您希望限定权限，限制密钥 `rk_...` 也可使用）。您将其粘贴到 Dodo 的 **Secret Key** 字段。
  </Step>
</Steps>

## 步骤 2：设置 webhook 和签名密钥

当您保存 Stripe 连接时，Dodo 会生成一个 **Webhook Endpoint** URL。将其添加为 Stripe 中的 webhook，然后复制签名密钥。

<Steps>
  <Step title="Add an endpoint">
    在 Stripe 仪表板中，前往 **开发者 → Webhooks** 并选择 **Add endpoint**。粘贴 Dodo 生成的 **Webhook Endpoint** URL（它必须是 HTTPS 且公开可访问的），并选择要监听的事件。
  </Step>

  <Step title="Reveal the signing secret">
    打开 endpoint 的详细页面并选择 **Reveal secret** 以查看 **Signing secret** — 它以 `whsec_` 开头。此密钥对每个 endpoint 来说都是唯一的，测试和实时 endpoints 拥有不同的密钥。
  </Step>

  <Step title="Paste the signing secret into Dodo">
    返回 **设置 → BYOP**，将签名密钥粘贴到 **Webhook Signing Secret** 字段中以完成连接。

    <Card title="Set up BYOP" icon="shuffle" href="/features/byop">
      按照完整的自带支付处理器设置流程。
    </Card>
  </Step>
</Steps>

<Tip>
  保存后，使用 Dodo 的 **验证连接** 运行针对 Stripe 的测试调用，并在上线前确认您的 secret key 和 webhook 签名密钥有效。
</Tip>

## 常见问题

<AccordionGroup>
  <Accordion title="Do I need my own PCI certification (SAQ D)?">
    不需要。因为 **Dodo Payments 代表您处理原始卡数据**且符合 **PCI DSS 一级标准**，您提交 **Dodo Payments 的合规证明（AOC）** 给 Stripe，而不是完成您自己的 SAQ D 或进行单独的审计。
  </Accordion>

  <Accordion title="Why can't Stripe just enable this by default?">
    将原始卡号发送到API会使发送系统处于 PCI DSS 范围内。Stripe 要求在启用原始卡数据API之前提供 PCI 合规证明，以确保持卡人数据的安全。Dodo Payments 是 **PCI DSS 一级合规**的，因此您提供 Dodo Payments 的AOC作为证明。
  </Accordion>

  <Accordion title="Can I test BYOP before getting live approval?">
    是的。要求 Stripe 在 **测试模式** 启用原始卡数据API，不需要 PCI 文档，然后在 Dodo 中以测试模式连接 Stripe。在处理实际支付前需要获得实时模式的批准。
  </Accordion>

  <Accordion title="I lost my secret key or signing secret, what now?">
    在 **开发者 → API keys** 下生成一个新密钥，或打开 webhook endpoint 并选择 **Reveal secret** 以再次查看签名密钥，然后在 **设置 → BYOP** 中更新该值。
  </Accordion>
</AccordionGroup>

## 参考资料

* [Dodo Payments PCI DSS 合规证明（AOC）](https://pub-2a89184e4c954b599464449d23f506bb.r2.dev/dodo-payments-pci-dss-aoc.pdf)
* [Stripe 支持：启用原始卡数据API访问](https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis)
* [Stripe：API keys](https://docs.stripe.com/keys)
* [Stripe：Webhook签名密钥](https://docs.stripe.com/webhooks/signature)
