跳转到主要内容
POST
Create a payment link
请使用属于该产品所在组织、且为全部权限或勾选了 products:payment_links:write 权限(控制台中“可创建和修改”下的支付链接)的 API 密钥进行认证。只有 Owner 和 Admin 角色可以授予该权限。
  • id 是你组织内的产品 ID,无论该产品是通过 API 还是在控制台创建的。其他组织的产品或不存在的产品返回 404。
  • 每次调用都会为该产品新建一个价格及其付款链接,因此一个产品可以有多个价格。
  • 必填请求头 Idempotency-Key(1–255 个 ASCII 字符,范围为 0x21 至 0x7E,不允许空格),规则与结账会话相同。相同的键加相同的请求体,返回第一次创建的链接(201),不会重复创建。相同的键但请求体不同,或用于另一个产品,返回 409。如果该键创建的链接之后被删除,重试也会返回 409,请换一个新的键。
  • pricingType 为 ONE_TIME 或 SUBSCRIPTION。pricing 是以主单位表示的字符串,如 "9.99"。不传 pricing 即为灵活的“自定义金额”,仅限 ONE_TIME,此时 minAmount 和 maxAmount 可选。
  • SUBSCRIPTION 价格必须提供 billingInterval(DAY、MONTH 或 YEAR)。billingIntervalCount 可选,默认为 1。
  • successUrl 是客户付款后跳转的绝对 HTTPS 地址。不传则客户看到 Anyway 的收据页。
  • 款项通过 Anyway 平台账户收取。通过 API 创建的链接仅支持银行卡付款,不支持加密货币付款链接。
  • 未知字段会被拒绝,返回 400。
  • 请原样分享返回的 paymentLinkUrl。响应结构与读取产品付款链接中的条目相同。
结账会话无法销售灵活金额。若要让客户自行决定付款金额,请在此创建灵活的一次性付款链接。

授权

X-API-Key
string
header
必填

Merchant API key (format: ak_BASE64)

请求头

Idempotency-Key
string
必填

Unique creation request key: 1-255 ASCII characters in the range 0x21-0x7E (no spaces or control characters)

Required string length: 1 - 255

路径参数

id
string
必填

Product ID

请求体

application/json

Price and payment link

pricingType
enum<string>
必填
可用选项:
SUBSCRIPTION,
ONE_TIME
currency
string
必填

Currency code, for example USD

pricing
string

Fixed amount in major units, for example "9.99". Omit for a flexible (pay what you want) amount, which is ONE_TIME only.

minAmount
number

Optional minimum for a flexible amount (ONE_TIME only)

maxAmount
number

Optional maximum for a flexible amount (ONE_TIME only)

billingInterval
enum<string>
可用选项:
DAY,
MONTH,
YEAR
billingIntervalCount
integer

Number of intervals between charges (SUBSCRIPTION). Defaults to 1.

pricingName
string

Name of the price

successUrl
string

Absolute HTTPS URL to send the customer to after paying. Defaults to the Anyway receipt.

响应

Created

data
object
error
object
message
string
success
boolean