# 创建支付链接

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

```yaml
openapi: 3.1.0
info:
  title: 创建支付链接
  version: 1.0.0
  description: 创建托管支付链接并返回 Payment Link ID 和收银台访问 URL。
paths:
  /v1/txn/paymentLink/add:
    post:
      summary: 创建支付链接
      description: 创建托管支付链接并返回 Payment Link ID 和收银台访问 URL。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantNo:
                  type: string
                  description: Onerway 分配的商户号；获取方式参见[接入准备](/zh/payments/get-started/setup#获取凭证)。
                linkName:
                  type: string
                  description: 支付链接展示名称，用于在列表查询和商户运营中识别链接。
                amount:
                  type: number
                  description: 指定货币的支付金额；零小数货币使用整数。格式要求详见[币种与金额校验](/zh/payments/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: 支付链接收银台页面是否采集买家姓名。
                sign:
                  type: string
                  description: 请求签名字符串；生成方式详见[请求签名](/zh/payments/get-started/request-signing)。
              required:
                - merchantNo
                - amount
                - currency
                - defaultCountry
                - itemName
                - sign
            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
                  sign: "{{SIGN}}"
      responses:
        "200":
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: 响应码；`20000`
                      表示请求处理成功，其余为错误码。完整码表见[响应码](/zh/payments/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: 业务数据对象，包含创建成功后的支付链接信息。
```
