> 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/bao-cun-ka-xiang-qing.md).

# 保存卡详情

#### 概述 <a href="#overview" id="overview"></a>

Codapay 支持保存回头客的银行卡信息，以简化和加快结账流程。符合条件的商户和已启用此功能的卡组织可在托管支付页面上使用此功能。

启用此功能后，用户可以在结账时安全地存储银行卡，并在以后的交易中重复使用。

> ⚠️**注意：**&#x6B64;功能**目前**在**印度和印度尼西亚不可用**

#### 资格和激活 <a href="#eligibility-and-activation" id="eligibility-and-activation"></a>

只有已明确启用此功能的商户才能使用已保存的卡片功能。

要启用已保存卡片功能，请联系您的 Codapay 客户经理或支持团队。

如果商家未启用此功能，付款将正常处理，但不会保存银行卡信息。`/v2.0/Payment/Component/init.json`在这种情况下，响应中会返回警告信息。

#### 用户识别与购物者地图 <a href="#user-identification-and-shopper-mapping" id="user-identification-and-shopper-mapping"></a>

用户必须先登录您的平台，才能发起涉及保存或使用已保存银行卡的付款。

您需要`partner_shopper_id`在`/v2.0/Payment/Component/init.json`请求中传递一个字段。此字段代表您系统中的唯一用户 ID。它必须：

* 唯一标识单个用户
* 在所有会话和设备上保持一致
* 包含在所有已保存的卡片相关请求中

当添加第一张已保存的银行卡时，Codapay 会创建一个关联对象`shopper_id`，并将其链接到提供的关联对象`partner_shopper_id`。之后，所有已保存的银行卡都会与此关联对象关联`shopper_id`。

Codapay 利用此链接实现以下功能：

* 在下次结账时检索已保存的银行卡
* 将新保存的卡片附加到正确的用户
* 无需用户额外输入即可处理定期付款或商家发起的付款

#### 集成概述 <a href="#integration-overview" id="integration-overview"></a>

`/v2.0/Payment/Component/init.json`要在托管支付页面上启用已保存卡片功能，请在您的请求中包含以下字段：

| `enableSavePaymentMethod`       | Boolean | 允许用户保存他们的银行卡。        |
| ------------------------------- | ------- | -------------------- |
| `displaySavedPaymentMethodList` | Boolean | 向用户显示之前保存的卡片         |
| `userInitiated`                 | Boolean | 指示用户是否参与支付流程         |
| `shopper`                       | Object  | 识别用户并传递用于创建令牌的账单详细信息 |

**购物者对象**

`shopper`请求中的字段是`/v2.0/Payment/Component/init.json`一个键值对列表`shopper.entry[]`。

每个密钥对应于购物者身份或账单信息，用于检索或创建购物者个人资料并支持已保存的卡片功能。

| `partnerShopperId`    | Yes\* | 您系统的唯一用户 ID（区分大小写）              |
| --------------------- | ----- | ------------------------------- |
| `id`                  | No    | Codapay 签发`shopper_id`用于找回已知购物者 |
| `email`               | No    | 购物者电子邮件地址（创建新购物者时必需）            |
| `phoneNumber`         | No    | 购物者的电话号码                        |
| `billingFirstName`    | No    | 购物者名字（用于计费和创建购物者信息）             |
| `billingLastName`     | No    | 购物者姓氏（账单处理和创建购物者信息时必需）          |
| `billingDocumentType` | 有条件的  | 某些市场要求提供的国家身份证件类型（例如，CPF）。      |
| `billingDocumentId`   | 有条件的  | 国民身份证件的值，和`documentType`匹配      |
| `billingAddress`      | No    | 街道地址                            |
| `billingCity`         | No    | 城市名称                            |
| `billingRegion`       | No    | 州或省                             |
| `billingCountry`      | No    | ISO alpha-2 国家代码（例如，`US`）       |
| `billingZipCode`      | No    | <p></p><p>邮政编码</p>              |

> \* 首次保存卡片时需要填写。

* 如果`id`存在，Codapay 会尝试检索与该关联的现有购物者`shopper_id`。
* 如果`id`未提供，则会创建一个新的购物者并将其与提供的购物者关联`partnerShopperId`。
* 除了此处记录的标准字段外，此处列出的字段也是必填[项](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-payment-page-integration/initiate-a-payment-request#request-parameters)。

有关使用此结构的请求有效负载，请参阅下面的“场景和示例”部分。

#### 场景和示例 <a href="#scenarios-and-examples" id="scenarios-and-examples"></a>

本节概述了集成卡片保存功能时最常见的几种用例。每种用例都包含所需的参数和示例请求格式。

1. [首次用户 - 保存卡片选项](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/saving-card-details#id-1.-first-time-user-save-card-option)
2. [老用户 – 显示已保存的卡片](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/saving-card-details#id-2.-returning-user-show-saved-cards)
3. [老用户 - 无需用户界面即可使用已保存的银行卡付款](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/saving-card-details#id-3.-returning-user-charge-saved-card-without-ui)
4. [商户发起的付款 - 用户不在场](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/saving-card-details#id-4.-merchant-initiated-payment-user-not-present)

**1. 首次用户 – 保存卡片选项**

允许用户在结账时保存他们的银行卡信息。

<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%252FWTP8d3mtNmXPI2CYFqlr%252FScreenshot%25202026-03-05%2520at%25204.31.34%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D9e0be746-cd85-44d4-9ad9-09d2e942c1e3&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=596fe555&#x26;sv=2" alt="" height="502" width="898">

**要求**

```
{
  "initRequest": {
    "country": 360,
    "payType": 400,
    "apiKey": "",
    "projectId": "31",
    "orderId": "20250611113402",
    "currency": 360,
    "items": [
      {
        "code": "12ds",
        "price": 10000.00,
        "name": "Star Diamond"
      }
    ],
    "profile": {
      "entry": [
        {
          "key": "user_id",
          "value": "105"
        }
      ]
    },
    "enableSavePaymentMethod": true,
    "displaySavedPaymentMethodList": true,
    "userInitiated": true,
    "shopper": {
      "entry": [
        {
          "key": "partnerShopperId",
          "value": "test_partner_123_Id"
        },
        {
          "key": "email",
          "value": "test@example.com"
        }
      ]
    }
  }
}
```

**回复**

```
{
  "initResult": {
    "resultCode": 0,
    "txnId": 7503012627171645973
  }
}
```

**商户通知**

```
{
  "eventType": "PAYMENT_METHOD_ADDED",
  "timestamp": "2025-06-19T02:48:39.568907Z",
  "shopper": {
    "id": "shp_sg197861636b40021",
    "partner_shopper_id": "test_partner_123_Id",
    "email": "test@example.com"
  },
  "paymentMethod": {
    "id": "pmt_sg1978616a1900024",
    "type": "card",
    "card": {
      "lastFour": "7263",
      "expirationMonth": "04",
      "expirationYear": "2027"
    }
  }
}
```

**2. 老用户 – 显示已保存的卡片**

显示之前保存的卡片供用户选择。

<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%252FRYhnPKmGIprhndYYKOzk%252FScreenshot%25202026-03-05%2520at%25204.32.55%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D5fe15e15-dd39-43ae-aedb-ab9a42652cc4&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=831bfab5&#x26;sv=2" alt="" height="558" width="886">

**要求**

```
{
  "initRequest": {
    "country": 360,
    "payType": 400,
    "apiKey": "",
    "projectId": "31",
    "orderId": "20250611113402",
    "currency": 360,
    "items": [
      {
        "code": "12ds",
        "price": 10000.00,
        "name": "Star Diamond"
      }
    ],
    "profile": {
      "entry": [
        {
          "key": "user_id",
          "value": "105"
        }
      ]
    },
    "enableSavePaymentMethod": true,
    "displaySavedPaymentMethodList": true,
    "userInitiated": true,
    "shopper": {
      "entry": [
        {
          "key": "id",
          "value": "shp_sg197861636b40021"
        }
      ]
    }
  }
}
```

**回复**

```
{
  "initResult": {
    "resultCode": 0,
    "txnId": 7503016855911597963
  }
}
```

**3.【即将推出】老用户 – 无需用户界面即可使用已保存的银行卡付款**

**要求**

```
{
  "initRequest": {
    "country": 360,
    "payType": 400,
    "apiKey": "",
    "projectId": "31",
    "orderId": "20250611113402",
    "currency": 360,
    "items": [
      {
        "code": "12ds",
        "price": 10000.00,
        "name": "Star Diamond"
      }
    ],
    "profile": {
      "entry": [
        {
          "key": "user_id",
          "value": "105"
        }
      ]
    },
    "enableSavePaymentMethod": true,
    "displaySavedPaymentMethodList": false,
    "userInitiated": true,
    "shopper": {
      "entry": [
        {
          "key": "id",
          "value": "shp_sg197861636b40021"
        }
      ]
    }
  }
}
```

**回复**

```
{
  "initResult": {
    "resultCode": 0,
    "txnId": 7503016855911597963
  }
}
```

**4. \[即将推出] 商户发起支付 - 用户不在场**

**要求**

```
{
  "initRequest": {
    "country": 360,
    "payType": 400,
    "apiKey": "",
    "projectId": "31",
    "orderId": "20250611113402",
    "currency": 360,
    "items": [
      {
        "code": "12ds",
        "price": 10000.00,
        "name": "Star Diamond"
      }
    ],
    "profile": {
      "entry": [
        {
          "key": "user_id",
          "value": "105"
        }
      ]
    },
    "enableSavePaymentMethod": true,
    "displaySavedPaymentMethodList": false,
    "userInitiated": false,
    "shopper": {
      "entry": [
        {
          "key": "id",
          "value": "shp_sg197861636b40021"
        }
      ]
    }
  }
}
```

**回复**

```
{
  "initResult": {
    "resultCode": 0,
    "txnId": 7503016855911597963
  }
}
```

[<br>](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/styling-and-customization)<br>


---

# 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/bao-cun-ka-xiang-qing.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.
