> ## 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.

# 信用卡和借记卡

> 使用 Dodo Payments 在全球接受主要信用卡和借记卡网络。涵盖 3D Secure、已保存的卡、tokenization、测试卡和区域性网络。

每个支持的国家和货币中的每个 Dodo Payments checkout 都提供卡支付。Dodo Payments 接受主要卡网络，将卡号替换为 tokens，并执行卡支付所需的检查，因此您无需处理原始卡数据。

## 支持的卡片网络

Dodo Payments 接受全球性网络以及多个区域性网络。

### 全球性网络

| Network | Coverage |
| :- | :- |
| **Visa** | 全球领先，全球拥有超过 40 亿张卡 |
| **Mastercard** | 全球覆盖，具备强大的安全功能 |
| **American Express** | 高端持卡人，消费金额更高 |
| **Discover** | 以美国为重点，在全球不断发展 |
| **JCB** | 在日本占据领先地位，并扩展至整个亚洲 |
| **UnionPay** | 在中国占据主导地位 |
| **Diners Club** | 面向国际高端旅行者 |

### 区域网络

| Network | Region |
| :- | :- |
| **Interac** | 加拿大的借记卡网络 |
| **Cartes Bancaires** | 法国的国家级网络 |
| **Korean Local Cards** | 韩国本地网络 |
| **Rupay** | 印度的国家级网络 |

## 配置

Cards 在 `allowed_payment_method_types` 中使用两个值：

| Type | Description |
| :- | :- |
| `credit` | 所有信用卡 |
| `debit` | 所有借记卡 |

此会话仅提供卡支付：

```javascript theme={null}
// `client` is an initialized DodoPayments client.
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_123', quantity: 1 }],
  allowed_payment_method_types: ['credit', 'debit'],
  return_url: 'https://example.com/success'
});
```

> [!TIP]
>
> 除非有特定原因需要排除其中一个，否则请同时包含 `credit` 和 `debit`。许多客户更喜欢使用借记卡付款。

## 3D Secure 身份验证

3D Secure (3DS) 要求持卡人的银行确认持卡人身份，例如使用一次性代码、生物识别检查或在银行应用中批准。这可以减少欺诈和拒付。

### 触发 3DS 的情况

Dodo Payments 在以下情况下请求 3DS：

* 卡网络要求进行身份验证。
* 地区法规要求进行身份验证，例如欧洲的 PSD2。
* 交易被标记为高风险。

### 强制使用 3DS

如需为您的企业的每笔卡支付都要求 3DS，请在 **Settings → Pricing** 下开启 **3D Secure**。如需针对某个结账会话覆盖此设置，请传递 `force_3ds`：

```javascript theme={null}
// `client` is an initialized DodoPayments client.
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_123', quantity: 1 }],
  force_3ds: true,
  return_url: 'https://example.com/success'
});
```

> [!NOTE]
>
> 要求每笔交易都进行 3DS 可以减少欺诈，但可能降低转化率，因为部分客户会在身份验证期间放弃结账。

### 处理身份验证失败

当支付需要进行 3DS 身份验证时，支付会在成功或失败之前经历中间状态：

| Status | Meaning | What to do |
| - | - | - |
| `requires_customer_action` | 客户必须完成 3DS 挑战 | 让客户在结账期间完成身份验证 |
| `requires_payment_method` | 客户从未提供支付方式（未输入详细信息或放弃了提示）。这通常是客户流失，而不是支付被拒 | 重新联系客户，促使其完成结账。请参阅[弃购购物车恢复](/features/recovery/abandoned-cart-recovery) |

如果身份验证未完成，支付会因以下拒付代码之一而失败：

* `AUTHENTICATION_FAILURE`：无法验证客户身份。
* `AUTHENTICATION_REQUIRED`：需要身份验证，但未执行。
* `AUTHENTICATION_TIMEOUT`：客户未及时响应。

[Transaction Failures](/api-reference/transaction-failures) 参考文档列出了每个代码的建议操作。

#### 结账时与续订时

* **结账时（客户在场）：** 3DS 挑战会在结账期间显示。如果失败，请客户重试或使用其他卡。
* **订阅续订时（客户不在场）：** 无法实时显示 3DS 挑战。如果续订需要身份验证但失败，订阅会转为 `on_hold`；如果设置了[宽限期](/features/subscription#grace-period)，则会先转为 `past_due`。要恢复订阅，请提示客户返回并更新其支付方式。请参阅 [Handle Payment Failures](/developer-resources/handle-payment-failures) 和 [Subscription Dunning](/features/recovery/subscription-dunning)。

## 已保存的支付方式

回头客可以使用之前结账时保存的卡付款。

> **Tokenized**
>
> 原始卡号绝不会被存储。

> **PCI Compliant**
>
> Dodo Payments 负责 PCI 合规。

> **Customer-Scoped**
>
> 每张已保存的卡都属于一位客户。

### 启用已保存的卡

如需在结账时显示回头客已保存的卡，请将 `show_saved_payment_methods: true` 与现有的 `customer_id` 一起传递。默认值为 `false`。

```javascript theme={null}
// `client` is an initialized DodoPayments client.
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_123', quantity: 1 }],
  show_saved_payment_methods: true,
  customer: { customer_id: 'cus_existing_123' },
  return_url: 'https://example.com/success'
});
```

### 一键购买

如需在不显示结账页面的情况下向已保存的卡收费，请将其 `payment_method_id` 与 `confirm: true` 以及现有的 `customer_id` 一起传递。该会话会直接向卡收费，并且不会返回 `checkout_url`，因此请使用 webhooks 了解支付结果。

```javascript theme={null}
// `client` is an initialized DodoPayments client.
// Get the customer's saved payment methods
const methods = await client.customers.retrievePaymentMethods('cus_123');

// Charge the first saved card
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_123', quantity: 1 }],
  customer: { customer_id: 'cus_123' },
  payment_method_id: methods.items[0].payment_method_id,
  confirm: true,
  return_url: 'https://example.com/success'
});
```

## 测试

在 test mode 中使用以下卡。有关更多测试数据，请参阅 [Testing Process](/miscellaneous/testing-process)。

**Successful Payments**

| Region | Brand | Card Number | Expiry | CVV |
| :- | :- | :- | :- | :- |
| US | Visa | `4242424242424242` | 06/32 | 123 |
| US | Mastercard | `5555555555554444` | 06/32 | 123 |
| India | Visa | `4576238912771450` | 06/32 | 123 |
| India | Mastercard | `5409162669381034` | 06/32 | 123 |

**Declined Payments**

| Region | Brand | Card Number | Scenario |
| :- | :- | :- | :- |
| US | Visa | `4000000000000002` | 通用拒付 |
| US | Visa | `4000000000009995` | 余额不足 |
| India | Visa | `4706131211212123` | 通用拒付 |
| India | Mastercard | `5105105105105100` | 通用拒付 |

> [!WARNING]
>
> 测试卡仅在 test mode 中有效。在 live mode 中，使用测试卡进行的支付会失败。

## 安全与合规

Dodo Payments 为卡支付提供以下保护措施：

| Feature | Description |
| :- | :- |
| **PCI DSS Level 1** | PCI DSS 认证的最高级别 |
| **Tokenization** | 卡号在输入时进行令牌化 |
| **Fraud Scoring** | 实时风险评估 |
| **CVV Validation** | 安全码验证 |
| **3D Secure** | 持卡人身份验证 |

## 最佳实践

> **Accept all major networks**
>
> 除非确有必要，否则不要限制卡类型。客户希望使用自己偏好的卡完成支付。

> **Display card logos**
>
> 在您的网站上展示 Visa、Mastercard 和 Amex 的标志，以建立信任。

> **Handle declines gracefully**
>
> 显示清晰的错误消息。不要向客户显示原始错误代码。

> **Enable saved cards for returning customers**
>
> 已保存的支付方式可以让回头客更快完成重复购买。

## 故障排除

> **Card declined**
>
> **原因：** 余额不足、卡已过期、CVV 不正确或银行的欺诈防护措施。
>
> **解决方案：** 请客户检查其信息或尝试使用其他卡。在 [Transaction Failures](/api-reference/transaction-failures) 参考文档中查找拒付的错误代码及其建议操作。请参阅 [Handle Payment Failures](/developer-resources/handle-payment-failures)，了解如何在代码中处理拒付。

> **3DS authentication failed**
>
> **原因：** 客户放弃了挑战，银行系统不可用，或挑战超时。
>
> **解决方案：** 重试，或让客户联系其银行。请参阅[处理身份验证失败](#handling-authentication-failures)，了解涉及的支付状态和拒付代码。

> **Card not supported**
>
> **原因：** 不支持该区域网络，或该卡是受限的预付卡。
>
> **解决方案：** 请客户尝试使用主要卡网络发行的卡。

## 相关页面

> **[Payment Methods Overview](/features/payment-methods)**
>
> 所有受支持的支付方式。

> **[Upsells & Downsells](/features/upsells-and-downsells)**
>
> 使用已保存卡的一键购买。

> **[Testing Process](/miscellaneous/testing-process)**
>
> 每种支付方式的测试数据。

> **[Subscriptions](/features/subscription)**
>
> 使用卡进行周期性计费。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.