# 创建支付链接

> 创建托管支付链接并返回 Payment Link ID 和收银台访问 URL。

```yaml
openapi: 3.1.0
x-onerway-docs-version: v2
x-onerway-spec-key: payments/versions/v2/payment-links/create-payment-link
info:
  title: 创建支付链接
  version: v2
  description: 创建托管支付链接并返回 Payment Link ID 和收银台访问 URL。
servers:
  - url: https://sandbox-payment-api.onerway.com
    description: sandbox
  - url: https://payment-api.onerway.com
    description: production
paths:
  /v1/txn/paymentLink/add:
    post:
      summary: 创建支付链接
      description: 创建托管支付链接并返回 Payment Link ID 和收银台访问 URL。
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: 商户账户的 API Key，通过 `ApiKey`
            请求头传入。详见[请求认证](/zh/payments/versions/v2/get-started/authentication)。
          schema:
            type: string
            description: 商户账户的 API Key，通过 `ApiKey`
              请求头传入。详见[请求认证](/zh/payments/versions/v2/get-started/authentication)。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantNo:
                  type: string
                  description: Onerway
                    分配的商户号；获取方式参见[接入准备](/zh/payments/versions/v2/get-started/setup#获取凭证)。
                linkName:
                  type: string
                  description: 支付链接展示名称，用于在列表查询和商户运营中识别链接。
                amount:
                  type: number
                  description: 指定货币的支付金额；零小数货币使用整数。格式要求详见[币种与金额校验](/zh/payments/versions/v2/get-started/currency-and-amount)。
                currency:
                  type: string
                  description: 支付币种，[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 三位字母货币代码，需与
                    `amount` 匹配。
                defaultCountry:
                  type: string
                  description: 支付链接收银台页面使用的默认国家或地区代码，建议使用 [ISO 3166-1
                    alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
                    两位字母国家代码。
                itemName:
                  type: string
                  description: 商品或服务名称，展示给买家。
                description:
                  type: string
                  description: 商品或服务描述，展示给买家。
                collectEmail:
                  type: boolean
                  description: 支付链接收银台页面是否采集买家邮箱。
                collectName:
                  type: boolean
                  description: 支付链接收银台页面是否采集买家姓名。
              required:
                - merchantNo
                - amount
                - currency
                - defaultCountry
                - itemName
            examples:
              create-payment-link:
                summary: 创建支付链接
                value:
                  amount: 99.99
                  collectEmail: true
                  collectName: true
                  currency: USD
                  defaultCountry: US
                  description: Demo product description
                  itemName: Demo product
                  linkName: Demo payment link
                  merchantNo: replace_with_merchant_no
      responses:
        "200":
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: 响应码；`20000`
                      表示请求处理成功，其余为错误码。完整码表见[响应码](/zh/payments/versions/v2/api-reference/response-codes)。
                  respMsg:
                    type: string
                    description: 响应码对应的可读说明。
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Payment Link ID。
                      linkUrl:
                        type: string
                        description: 买家访问支付链接收银台页面的 URL。
                    description: 业务数据对象，包含创建成功后的支付链接信息。
      security:
        - apiKeyAuth:
            []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: ApiKey
```
