checkoutSessionId 和 clientSecret 即可快速集成支付功能,无需处理复杂的支付参数配置。checkoutSessionId 和 clientSecretcreatePaymentElement() 创建支付表单组件loadActions() 获取支付操作方法actions.confirm() 提交支付| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
apiKey | string | ✅ | 可发布密钥,格式:UseePay_PK_*** 或 UseePay_PK_TEST_*** |
UseePay 实例| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
options | InitCheckoutOptions | ✅ | Checkout 配置对象 |
options.checkoutSessionId | string | ✅ | Checkout Session ID,格式:cs_xxxxxxxxxxxx |
options.clientSecret | string | ✅ | 客户端密钥,格式:cs_xxxxxxxxxxxx_xxxxxxxxxxxxxxx |
Checkout 实例checkoutSessionId 和 clientSecret 必须从服务端获取clientSecret 具有时效性,过期后需重新创建 SessionPaymentElement 实例mount() 方法才能显示| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
domId | string | ✅ | DOM 元素的 ID(不含 # 前缀) |
voidwidth: 60vw)voidmount() 再次挂载Promise<LoadActionsResult>actions 对象包含 confirm() 方法Promise<{ session?: CheckoutSession; error?: Error }>| 字段 | 类型 | 说明 |
|---|---|---|
session | object | 支付成功时返回的 Session 对象 |
session.checkout_session_id | string | Checkout Session ID |
session.payment_status | string | 支付状态:'paid'、'un_paid' 等 |
session.payment_intent_id | string | Payment Intent ID,用于追踪支付意图 |
session.payment_intent_status | string | Payment Intent 状态 |
session.status | string | Checkout Session 整体状态 |
error | object | 支付失败时的错误信息 |
error.message | string | 错误描述信息 |
error.type | string | 错误类型(可选) |
clientSecret 不要暴露在公开代码仓库中loadActions(),不要等到用户点击支付按钮UseePay_PK_TEST_***)进行开发