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

# 卡片标记化

该接口可安全地对卡片进行令牌化处理，用唯一令牌替换敏感的卡片信息。该令牌可用于未来的交易，确保符合安全标准（例如 PCI DSS），并减少存储或处理敏感卡片信息的需要。


## OpenAPI

````yaml openapi/zh/localpayment.json POST /api/card
openapi: 3.1.0
info:
  version: '1.0'
  title: Localpayment
  contact:
    name: Support
    url: mailto:support@localpayment.com
servers:
  - url: https://api.stage.localpayment.com
    description: Stage
security:
  - token: []
paths:
  /api/card:
    post:
      summary: 卡片标记化
      operationId: tokenize-card
      parameters:
        - name: Authorization
          in: header
          description: >-
            用于身份验证的 Bearer
            访问令牌。该令牌可从[获取访问令牌](/zh/reference/get-token)或[刷新访问令牌](/zh/reference/refresh-token)endpoint
            获取。
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: 持卡人姓名。**如果未提供 `token`，则为必填项。**
                number:
                  type: string
                  description: 卡号。**如果未提供 `token`，则为必填项。**
                cvv:
                  type: string
                  description: 卡片 CVV 码。**如果未提供 `token`，则为必填项。**
                expirationMonth:
                  type: string
                  description: 卡片到期月份。**如果未提供 `token`，则为必填项。**
                expirationYear:
                  type: string
                  description: 卡片到期年份。**如果未提供 `token`，则为必填项。**
                token:
                  type: string
                  description: 通过发送令牌来使用之前已令牌化的卡。
              required:
                - name
                - number
                - cvv
                - expirationMonth
                - expirationYear
              x-examples:
                Example 1:
                  name: NICOLAS CABRAL
                  number: '4000000000000002'
                  cvv: '123'
                  expirationMonth: '11'
                  expirationYear: '2026'
            examples:
              Save card:
                value:
                  name: John Doe
                  number: '4000000000000002'
                  cvv: '123'
                  expirationMonth: '11'
                  expirationYear: '2028'
              801 - Params error card number.:
                value:
                  name: John Doe
                  number: '400000000000000'
                  cvv: '123'
                  expirationMonth: '11'
                  expirationYear: '2028'
              820 - Unknown error Failed to save card.:
                value:
                  number: '4000000000000002'
                  cvv: '123'
                  expirationMonth: '11'
                  expirationYear: '2028'
              801 - Params error fullCardData.:
                value:
                  name: John Doe
                  number: '4000000000000002'
                  expirationMonth: '11'
                  expirationYear: '2028'
              801 - Params error expiration month, bad format.:
                value:
                  name: John Doe
                  number: '4000000000000002'
                  cvv: '123'
                  expirationYear: '2028'
              801 - Params error expiration year, bad format.:
                value:
                  name: John Doe
                  number: '4000000000000002'
                  cvv: '123'
                  expirationMonth: '11'
              Use a tokenized card:
                value:
                  token: WleV6CZ785IMx1x11SIrqzOn3JsGKcef8oBh2mbi56M%3D
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  card:
                    type: object
                    description: 卡片信息。
                    properties:
                      token:
                        type: string
                        description: 包含卡片信息的令牌。
                      bin:
                        type: string
                        description: 银行识别号码。
                      brand:
                        type: string
                        description: 卡支付网络。
                      Country:
                        type: string
                        enum:
                          - AR
                          - BO
                          - BR
                          - CL
                          - CO
                          - CR
                          - DO
                          - EC
                          - SV
                          - GT
                          - HN
                          - MX
                          - PA
                          - PY
                          - PE
                          - UY
                        title: 国家/地区
                        description: '[国家](/zh/reference/country-codes)。ISO 3166-1 alpha-2。'
                      name:
                        type: string
                        description: 信用卡持有人姓名。
                      last4:
                        type: string
                        description: 卡号后四位。
                      expirationYear:
                        type: integer
                        description: 到期年份`YYYY`格式。
                      expirationMonth:
                        type: integer
                        description: 到期月份`MM`格式。
                      Installments:
                        type: integer
                        description: 分期付款。
                    x-examples:
                      Example 1:
                        card:
                          token: Txf+Hf/YlDNiJOkIifR7nXDnvH0IsuZN+dwyzen5Ks0=
                          bin: '424242'
                          brand: VISA
                          country: GB
                          name: MANUEL CEDRO
                          last4: '4242'
                          expirationYear: 2025
                          expirationMonth: 11
                          installments: 0
                  errors:
                    type: array
                    description: 交易过程中发生的错误列表。
                    items:
                      type: object
                x-examples:
                  Example 1:
                    card:
                      token: xsWMaLnYjSNL1teBwxl465%2F2d8J85FXPAgBFIKfr0FA%3D
                      bin: '400000'
                      brand: VISA
                      country: US
                      name: NICOLAS CABRAL
                      last4: '0002'
                      expirationYear: 2028
                      expirationMonth: 11
                    errors: []
              examples:
                200 - Save card.:
                  value:
                    card:
                      token: xsWMaLcYjS3L11aBwxl465%2F2d8J85FXPAaBFIKfr0Fx%3D
                      bin: '400000'
                      brand: VISA
                      country: US
                      name: John Doe
                      last4: '0002'
                      expirationYear: 2028
                      expirationMonth: 11
                    errors: []
        '400':
          description: 错误的请求。
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    description: 交易过程中发生的错误列表。
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          description: 错误代码。
                        detail:
                          type: string
                          description: 错误详情。
                        description:
                          type: string
                          description: 错误描述。
                x-examples:
                  Example 1:
                    errors:
                      - code: '820'
                        description: REJECTED
                        detail: Unknown error Failed to save card.
              examples:
                820 - Unknown error Failed to save card.:
                  value:
                    errors:
                      - code: '820'
                        description: REJECTED
                        detail: Unknown error Failed to save card.
                801 - Params error card number.:
                  value:
                    errors:
                      - code: '801'
                        description: REJECTED
                        detail: Params error card number
                801 - Params error fullCardData.:
                  value:
                    errors:
                      - code: '801'
                        description: REJECTED
                        detail: Params error fullCardData
                801 - Params error expiration month, bad format.:
                  value:
                    errors:
                      - code: '801'
                        description: REJECTED
                        detail: Params error expiration month, bad format
                801 - Params error expiration year, bad format.:
                  value:
                    errors:
                      - code: '801'
                        description: REJECTED
                        detail: Params error expiration year, bad format
        '401':
          description: 未经授权。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 回复的补充信息。
                  code:
                    type: string
                    description: 状态码。
                  messages:
                    type: array
                    description: 消息列表。
                    items:
                      type: object
                      properties:
                        token_class:
                          type: string
                          description: Token 类。
                        token_type:
                          type: string
                          description: 令牌类型。
                        message:
                          type: string
                          description: 包含补充信息的消息。
                x-examples:
                  Example 1:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
              examples:
                401 - Token is invalid or expired:
                  value:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
      security:
        - token: []
      servers:
        - url: https://api.stage.localpayment.com
          description: Stage
components:
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

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