首页产品文档APISaaS平台
首页
产品文档
收银台展示建议支付产品能力稳定币订阅支付自动货币转换
API
接入准备支付服务订阅服务退款服务Webhook 通知
SaaS平台
ShopifyWooCommerceShoplazzaSHOPYY
  • 接入准备

支付平台 API

  • 支付服务
  • 订阅服务
  • 退款服务
  • Webhook 通知
首页/API/订阅
StablePay 开发者文档
Home
Product
API
SaaS
Login
Register
GitHub
Home
Product
API
SaaS
Login
Register
GitHub
  • API 概览 / Overview

    • 接入准备 / Preparation
  • 支付平台 API / Payment API

    • 支付服务 / Payment Service
    • 订阅服务 / Subscription Service
    • 退款服务 / Refund Service
    • Webhook 通知 / Webhook

订阅 API

概述

  • Base URL: https://api.stablepay.co
  • API 前缀: /api/v1
  • 协议: HTTPS
  • 数据格式: JSON
  • 字符编码: UTF-8
  • Base URL: https://api.stablepay.co
  • API Prefix: /api/v1
  • Protocol: HTTPS
  • Data Format: JSON
  • Character Encoding: UTF-8

端点

订阅管理

方法端点描述
POST/api/v1/subscriptions/create创建订阅
GET/api/v1/subscriptions/:subscription_id查询订阅
GET/api/v1/subscriptions/列出订阅
POST/api/v1/subscriptions/:subscription_id/cancel取消订阅

账单管理

方法端点描述
GET/api/v1/invoices/:invoice_id查询账单
GET/api/v1/invoices/列出账单

支付查询

方法端点描述
GET/api/v1/payment/:payment_id查询支付会话(payment_id)
GET/api/v1/payment_method/:payment_method_id查询支付方式

退款管理

方法端点描述
POST/api/v1/refunds/create创建退款
GET/api/v1/refunds/:refund_id查询退款
POST/api/v1/refunds/:refund_id/cancel取消退款

Subscription Management

MethodEndpointDescription
POST/api/v1/subscriptions/createCreate subscription
GET/api/v1/subscriptions/:subscription_idGet subscription
GET/api/v1/subscriptions/List subscriptions
POST/api/v1/subscriptions/:subscription_id/cancelCancel subscription

Invoice Management

MethodEndpointDescription
GET/api/v1/invoices/:invoice_idGet invoice
GET/api/v1/invoices/List invoices

Payment Query

MethodEndpointDescription
GET/api/v1/payment/:payment_idGet payment session by payment_id
GET/api/v1/payment_method/:payment_method_idGet payment method

Refund Management

MethodEndpointDescription
POST/api/v1/refunds/createCreate refund
GET/api/v1/refunds/:refund_idGet refund
POST/api/v1/refunds/:refund_id/cancelCancel refund

接口列表

订阅管理

1. 创建订阅

接口地址

POST /api/v1/subscriptions/create

请求参数

参数类型必填说明
itemsarray是订阅项数组(当前仅支持 1 个)
items[].price_data.price_idstring是价格 ID
items[].price_data.currencystring是币种(USD)
items[].price_data.productstring是产品名
items[].price_data.unit_amountint64是单价(最小货币单位)
items[].price_data.recurring.intervalstring是周期:day/week/month/year
items[].quantityint否数量,默认 1
customerstring是客户外部 ID
customer_emailstring否客户邮箱
customer_phonestring否客户手机号
customer_namestring否客户姓名
currencystring否订阅币种(USD)
descriptionstring否订阅描述
success_urlstring否支付成功跳转地址
cancel_urlstring否支付取消跳转地址
trial_endint64否试用结束时间(Unix 秒)
billing_cycle_anchorint64否账期锚点(Unix 秒)
cancel_atint64否自动取消时间(Unix 秒),与 iterations 互斥
iterationsint否运行 N 个周期后自动取消,与 cancel_at 互斥
metadataobject否业务扩展字段

cancel_at 和 iterations 不能同时传入。

ParameterTypeRequiredDescription
itemsarrayYesSubscription items (currently only one item is supported)
items[].price_data.price_idstringYesPrice ID
items[].price_data.currencystringYesCurrency (USD)
items[].price_data.productstringYesProduct name
items[].price_data.unit_amountint64YesUnit amount in minor unit
items[].price_data.recurring.intervalstringYesInterval: day/week/month/year
items[].quantityintNoQuantity, default 1
customerstringYesExternal customer ID
customer_emailstringNoCustomer email
customer_phonestringNoCustomer phone
customer_namestringNoCustomer name
currencystringNoSubscription currency (USD)
descriptionstringNoSubscription description
success_urlstringNoRedirect URL after success
cancel_urlstringNoRedirect URL after cancellation
trial_endint64NoTrial end time (Unix seconds)
billing_cycle_anchorint64NoBilling cycle anchor (Unix seconds)
cancel_atint64NoScheduled cancel time (Unix seconds), mutually exclusive with iterations
iterationsintNoAuto-cancel after N cycles, mutually exclusive with cancel_at
metadataobjectNoMetadata

cancel_at and iterations are mutually exclusive and cannot be provided together.

请求示例

{
  "items": [
    {
      "price_data": {
        "price_id": "price_monthly_001",
        "currency": "USD",
        "product": "Pro Plan",
        "unit_amount": 1999,
        "recurring": {
          "interval": "month"
        }
      },
      "quantity": 1,
      "metadata": {
        "seat_plan": "pro"
      }
    }
  ],
  "customer": "cust_001",
  "customer_email": "alice@example.com",
  "customer_name": "Alice",
  "currency": "USD",
  "description": "Pro Monthly Plan",
  "success_url": "https://merchant.example/success",
  "cancel_url": "https://merchant.example/cancel",
  "metadata": {
    "merchant_order_no": "sub_order_1001"
  }
}

响应示例

{
  "id": "202603311103103101010000000001",
  "object": "subscription",
  "customer": "cust_001",
  "store_id": "store_001",
  "currency": "USD",
  "description": "Pro Monthly Plan",
  "status": "incomplete",
  "items": [
    {
      "price_data": {
        "price_id": "price_monthly_001",
        "currency": "USD",
        "product": "Pro Plan",
        "unit_amount": 1999,
        "recurring": {
          "interval": "month"
        }
      },
      "quantity": 1
    }
  ],
  "payment_method_id": "202603311103101003010000000001",
  "billing_cycle_anchor": 1774886400,
  "current_period_start": 1774886400,
  "current_period_end": 1777478400,
  "latest_invoice": "202603311103103103010000000001",
  "checkout_url": "https://cashier.stablepay.co/subscription/202603311103103101010000000001",
  "metadata": {
    "merchant_order_no": "sub_order_1001"
  },
  "created": 1774924800
}

状态码

  • 200 OK: 创建成功
  • 400 Bad Request: 参数错误
  • 409 Conflict: 幂等冲突

2. 查询订阅

接口地址

GET /api/v1/subscriptions/:subscription_id

路径参数

参数类型必填说明
subscription_idstring是订阅 ID
ParameterTypeRequiredDescription
subscription_idstringYesSubscription ID

查询参数

参数类型必填说明
expandstring / array否可选:latest_invoice、customer、payment_method
ParameterTypeRequiredDescription
expandstring / arrayNoOptional: latest_invoice, customer, payment_method

请求示例

{
  "subscription_id": "202603311103103101010000000001",
  "expand": ["latest_invoice", "payment_method"]
}

响应示例

{
  "id": "202603311103103101010000000001",
  "object": "subscription",
  "customer": "cust_001",
  "currency": "USD",
  "status": "active",
  "current_period_start": 1774886400,
  "current_period_end": 1777478400,
  "latest_invoice": "202603311103103103010000000001",
  "latest_invoice_object": {
    "id": "202603311103103103010000000001",
    "status": "paid",
    "amount_due": 1999,
    "amount_paid": 1999,
    "currency": "USD"
  },
  "payment_method_object": {
    "id": "202603311103101003010000000001",
    "type": "crypto_wallet",
    "status": "active"
  },
  "created": 1774924800
}

状态码

  • 200 OK: 查询成功
  • 404 Not Found: 订阅不存在

3. 列出订阅

接口地址

GET /api/v1/subscriptions/

查询参数

参数类型必填说明
customerstring否客户 ID
statusstring否订阅状态过滤
limitint否返回条数,默认 10,最大 100
starting_afterstring否向后分页游标
ending_beforestring否向前分页游标
ParameterTypeRequiredDescription
customerstringNoCustomer ID
statusstringNoFilter by subscription status
limitintNoPage size, default 10, max 100
starting_afterstringNoForward pagination cursor
ending_beforestringNoBackward pagination cursor

请求示例

{
  "customer": "cust_001",
  "status": "active",
  "limit": 2
}

响应示例

{
  "object": "list",
  "data": [
    {
      "id": "202603311103103101010000000001",
      "object": "subscription",
      "customer": "cust_001",
      "currency": "USD",
      "status": "active",
      "current_period_start": 1774886400,
      "current_period_end": 1777478400,
      "created": 1774924800
    },
    {
      "id": "202603311103103101010000000002",
      "object": "subscription",
      "customer": "cust_001",
      "currency": "USD",
      "status": "trialing",
      "current_period_start": 1774928400,
      "current_period_end": 1777520400,
      "created": 1774928400
    }
  ],
  "has_more": false,
  "url": "/api/v1/subscriptions/?customer=cust_001&status=active&limit=2"
}

4. 取消订阅

接口地址

POST /api/v1/subscriptions/:subscription_id/cancel

路径参数

参数类型必填说明
subscription_idstring是订阅 ID
ParameterTypeRequiredDescription
subscription_idstringYesSubscription ID

请求参数

参数类型必填说明
cancel_at_period_endbool否是否账期结束后取消
cancellation_reasonstring否取消原因
cancellation_commentstring否取消备注
ParameterTypeRequiredDescription
cancel_at_period_endboolNoCancel at period end
cancellation_reasonstringNoCancellation reason
cancellation_commentstringNoCancellation comment

请求示例

{
  "subscription_id": "202603311103103101010000000001",
  "cancel_at_period_end": true,
  "cancellation_reason": "user_requested",
  "cancellation_comment": "downgrade next month"
}

响应示例

{
  "id": "202603311103103101010000000001",
  "object": "subscription",
  "status": "active",
  "cancel_at": 1777478400,
  "canceled_at": null,
  "current_period_end": 1777478400,
  "updated": 1774929000
}

账单管理

5. 查询账单

接口地址

GET /api/v1/invoices/:invoice_id

路径参数

参数类型必填说明
invoice_idstring是账单 ID
ParameterTypeRequiredDescription
invoice_idstringYesInvoice ID

请求示例

{
  "invoice_id": "202603311103103103010000000001"
}

响应示例

{
  "id": "202603311103103103010000000001",
  "object": "invoice",
  "subscription_id": "202603311103103101010000000001",
  "customer": "cust_001",
  "amount_due": 1999,
  "amount_paid": 1999,
  "amount_remaining": 0,
  "currency": "USD",
  "status": "paid",
  "payment_status": "paid",
  "billing_reason": "subscription_cycle",
  "period_start": 1774886400,
  "period_end": 1777478400,
  "payment_id": "202603311103101001010000000001",
  "paid_at": 1774925100,
  "due_date": 1775011200,
  "metadata": {
    "cycle": "2026-04"
  },
  "created": 1774924800
}

6. 列出账单

接口地址

GET /api/v1/invoices/

查询参数

参数类型必填说明
subscription_idstring否订阅 ID
customerstring否客户 ID
statusstring否open / paid / void
limitint否返回条数,默认 10,最大 100
starting_afterstring否向后分页游标
ending_beforestring否向前分页游标
ParameterTypeRequiredDescription
subscription_idstringNoSubscription ID
customerstringNoCustomer ID
statusstringNoopen / paid / void
limitintNoPage size, default 10, max 100
starting_afterstringNoForward pagination cursor
ending_beforestringNoBackward pagination cursor

请求示例

{
  "subscription_id": "202603311103103101010000000001",
  "status": "paid",
  "limit": 2
}

响应示例

{
  "object": "list",
  "data": [
    {
      "id": "202603311103103103010000000001",
      "object": "invoice",
      "subscription_id": "202603311103103101010000000001",
      "customer": "cust_001",
      "amount_due": 1999,
      "amount_paid": 1999,
      "currency": "USD",
      "status": "paid",
      "payment_status": "paid",
      "created": 1774924800
    }
  ],
  "has_more": false,
  "url": "/api/v1/invoices/?subscription_id=202603311103103101010000000001&status=paid&limit=2"
}

支付查询

7. 查询支付会话(payment_id)

接口地址

GET /api/v1/payment/:payment_id

路径参数

参数类型必填说明
payment_idstring是支付 ID
ParameterTypeRequiredDescription
payment_idstringYesPayment ID

请求示例

{
  "payment_id": "202603311103101001010000000001"
}

响应示例

{
  "id": "202603311103101001010000000001",
  "amount_total": 1999,
  "currency": "USD",
  "payment_status": "paid",
  "created": 1774924800,
  "expires_at": 1774928400,
  "url": "https://cashier.stablepay.co/pay/202603311103101001010000000001",
  "line_items": [
    {
      "price_data": {
        "currency": "USD",
        "unit_amount": 1999,
        "product_data": {
          "name": "Pro Plan"
        }
      },
      "quantity": 1
    }
  ],
  "tax_amount": 0,
  "shipping_amount": 0,
  "exchange_rate": "1.0000",
  "target_currency": "USDT",
  "target_amount_total": 1999,
  "rate_locked_at": 1774924800,
  "subscription_id": "202603311103103101010000000001",
  "invoice_id": "202603311103103103010000000001"
}

8. 查询支付方式

接口地址

GET /api/v1/payment_method/:payment_method_id

路径参数

参数类型必填说明
payment_method_idstring是支付方式 ID
ParameterTypeRequiredDescription
payment_method_idstringYesPayment method ID

请求示例

{
  "payment_method_id": "202603311103101003010000000001"
}

响应示例

{
  "id": "202603311103101003010000000001",
  "customer_id": "cust_001",
  "merchant_id": "mch_001",
  "type": "crypto_wallet",
  "address": "TXYZ***********abcd",
  "status": "active",
  "metadata": {
    "network": "TRON"
  },
  "created_at": 1774920000,
  "updated_at": 1774924800
}

退款管理

9. 创建退款

接口地址

POST /api/v1/refunds/create

请求参数

参数类型必填说明
payment_idstring是支付 ID(服务端映射会话)
refund_idstring是退款 ID(幂等)
amountint64是退款金额(最小货币单位)
currencystring是USDT / USDC
reasonstring否退款原因
descriptionstring否退款描述
metadataobject否业务扩展字段
ParameterTypeRequiredDescription
payment_idstringYesPayment ID (mapped to session server-side)
refund_idstringYesRefund ID (idempotent)
amountint64YesRefund amount in minor unit
currencystringYesUSDT / USDC
reasonstringNoRefund reason
descriptionstringNoRefund description
metadataobjectNoMetadata

请求示例

{
  "payment_id": "202603311103101101010000000001",
  "refund_id": "merchant_refund_20260331_0001",
  "amount": 999,
  "currency": "USDT",
  "reason": "requested_by_customer",
  "description": "partial refund",
  "metadata": {
    "ticket_id": "cs_12345"
  }
}

响应示例

{
  "refund_id": "merchant_refund_20260331_0001",
  "payment_id": "202603311103101101010000000001",
  "order_id": "order_202603310001",
  "amount": 999,
  "currency": "USDT",
  "status": "pending",
  "reason": "requested_by_customer",
  "description": "partial refund",
  "created_at": 1774929600,
  "invoice_id": "202603311103103103010000000001",
  "subscription_id": "202603311103103101010000000001",
  "metadata": {
    "ticket_id": "cs_12345"
  }
}

10. 查询退款

接口地址

GET /api/v1/refunds/:refund_id

路径参数

参数类型必填说明
refund_idstring是退款 ID
ParameterTypeRequiredDescription
refund_idstringYesRefund ID

请求示例

{
  "refund_id": "merchant_refund_20260331_0001"
}

响应示例

{
  "refund_id": "merchant_refund_20260331_0001",
  "payment_id": "202603311103101101010000000001",
  "order_id": "order_202603310001",
  "amount": 999,
  "currency": "USDT",
  "status": "succeeded",
  "reason": "requested_by_customer",
  "description": "partial refund",
  "failure_reason": "",
  "transaction_hash": "0xdef456abc789",
  "receipt_number": "rcpt_10001",
  "created_at": 1774929600,
  "processed_at": 1774930200,
  "metadata": {
    "ticket_id": "cs_12345"
  }
}

11. 取消退款

接口地址

POST /api/v1/refunds/:refund_id/cancel

路径参数

参数类型必填说明
refund_idstring是退款 ID
ParameterTypeRequiredDescription
refund_idstringYesRefund ID

请求示例

{
  "refund_id": "merchant_refund_20260331_0001"
}

响应示例

{
  "refund_id": "merchant_refund_20260331_0001",
  "status": "canceled",
  "canceled_at": 1774930800
}

Webhook 事件

Webhook 请求头

Header说明
Content-Type固定为 application/json
X-StablePay-SignatureWebhook 签名值(HMAC-SHA256)
X-StablePay-Timestamp签名时间戳(Unix 秒)
X-StablePay-Nonce随机串(防重放)
X-StablePay-Event-Type事件类型(如 subscription.active)
X-StablePay-Event-ID事件唯一 ID(通知记录 ID)
User-Agent固定 StablePay-Webhook/1.0

签名串(来自 stablepay-notification 实现):

sign_payload = nonce + "." + request_body
HeaderDescription
Content-TypeAlways application/json
X-StablePay-SignatureWebhook signature (HMAC-SHA256)
X-StablePay-TimestampSignature timestamp (Unix seconds)
X-StablePay-NonceRandom nonce (anti-replay)
X-StablePay-Event-TypeEvent type (for example subscription.active)
X-StablePay-Event-IDUnique event ID (notification record ID)
User-AgentAlways StablePay-Webhook/1.0

Signature payload (from stablepay-notification):

sign_payload = nonce + "." + request_body

订阅事件(逐条)

事件类型触发条件data.object.status主要字段
subscription.created订阅创建成功后incomplete(常见)subscription_id、customer_id、items、checkout_url
subscription.trialing完成授权且进入试用trialingsubscription_id、current_period_start/end
subscription.active首次/续费支付成功后激活activesubscription_id、current_period_start/end
subscription.past_due续费失败进入催缴past_duesubscription_id、current_period_start/end
subscription.canceled主动取消或重试耗尽自动取消canceledsubscription_id、canceled_at
subscription.updated订阅对象发生更新按实际状态subscription_id、可变字段
subscription.incomplete_expired初次授权超时失效incomplete_expiredsubscription_id

订阅事件 body(API 渠道最终推送)字段:

字段类型说明
idstring事件 ID(evt_ 前缀)
typestring上表事件类型
created_atint64订阅创建时间戳(秒)
data.object.subscription_idstring订阅 ID
data.object.customer_idstring客户 ID
data.object.statusstring订阅状态
data.object.cancel_at_period_endbool是否账期结束取消
data.object.current_period_startint64当前周期开始(可选)
data.object.current_period_endint64当前周期结束(可选)
data.object.checkout_urlstring订阅支付链接(可选)
data.object.canceled_atint64实际取消时间(可选)
data.object.sourcestring来源系统(api/shopify/...)
data.object.items[]array订阅项列表
data.object.items[].price_idstring价格 ID
data.object.items[].quantityint64数量
data.object.items[].currencystring币种
data.object.items[].product_idstring产品名
data.object.items[].intervalstring周期(day/week/month/year)
data.object.items[].interval_countint64周期间隔数
data.object.items[].amountint64金额(最小货币单位)
Event TypeTriggerdata.object.statusPrimary Fields
subscription.createdAfter subscription is createdincomplete (common)subscription_id, customer_id, items, checkout_url
subscription.trialingAuthorized and entered trialtrialingsubscription_id, current_period_start/end
subscription.activeActivated after first/renewal payment successactivesubscription_id, current_period_start/end
subscription.past_dueRenewal failed and moved to dunningpast_duesubscription_id, current_period_start/end
subscription.canceledUser cancellation or retries exhaustedcanceledsubscription_id, canceled_at
subscription.updatedSubscription object updatedactual statussubscription_id, changed fields
subscription.incomplete_expiredInitial authorization timeoutincomplete_expiredsubscription_id

Subscription event body fields (final API channel payload):

FieldTypeDescription
idstringEvent ID (evt_ prefix)
typestringEvent type from table above
created_atint64Subscription created timestamp (seconds)
data.object.subscription_idstringSubscription ID
data.object.customer_idstringCustomer ID
data.object.statusstringSubscription status
data.object.cancel_at_period_endboolCancel at period end
data.object.current_period_startint64Current period start (optional)
data.object.current_period_endint64Current period end (optional)
data.object.checkout_urlstringCheckout URL (optional)
data.object.canceled_atint64Canceled timestamp (optional)
data.object.sourcestringSource system (api/shopify/...)
data.object.items[]arraySubscription items
data.object.items[].price_idstringPrice ID
data.object.items[].quantityint64Quantity
data.object.items[].currencystringCurrency
data.object.items[].product_idstringProduct name
data.object.items[].intervalstringInterval (day/week/month/year)
data.object.items[].interval_countint64Interval count
data.object.items[].amountint64Amount in minor unit

订阅事件示例

{
  "id": "evt_1774924800123456789",
  "type": "subscription.active",
  "created_at": 1774924800,
  "data": {
    "object": {
      "subscription_id": "202603311103103101010000000001",
      "customer_id": "cust_001",
      "status": "active",
      "cancel_at_period_end": false,
      "current_period_start": 1774886400,
      "current_period_end": 1777478400,
      "checkout_url": "https://cashier.stablepay.co/subscription/202603311103103101010000000001",
      "source": "api",
      "items": [
        {
          "price_id": "price_monthly_001",
          "quantity": 1,
          "currency": "USD",
          "product_id": "Pro Plan",
          "interval": "month",
          "interval_count": 1,
          "amount": 1999
        }
      ]
    }
  }
}

账单事件(逐条)

事件类型触发条件data.object.status主要字段
invoice.created生成新账单(首期/续费)open / draftinvoice_id、amount_due、period_start/end
invoice.paid账单支付成功paidinvoice_id、amount_paid、paid_at
invoice.payment_failed账单支付失败open / payment_failedinvoice_id、amount_remaining

账单事件 body(API 渠道最终推送)字段:

字段类型说明
idstring事件 ID(evt_ 前缀)
typestringinvoice.created / invoice.paid / invoice.payment_failed
created_atint64账单创建时间戳(秒)
data.object.invoice_idstring账单 ID
data.object.subscription_idstring订阅 ID
data.object.customer_idstring客户 ID
data.object.amount_dueint64应付金额
data.object.amount_paidint64已付金额
data.object.amount_remainingint64未付金额
data.object.currencystring币种
data.object.statusstring账单状态
data.object.payment_statusstring支付状态
data.object.billing_reasonstring账单生成原因
data.object.period_startint64账期开始
data.object.period_endint64账期结束
data.object.paid_atint64付款时间(可选)
data.object.sourcestring来源系统
Event TypeTriggerdata.object.statusPrimary Fields
invoice.createdNew invoice generated (initial/renewal)open / draftinvoice_id, amount_due, period_start/end
invoice.paidInvoice payment succeededpaidinvoice_id, amount_paid, paid_at
invoice.payment_failedInvoice payment failedopen / payment_failedinvoice_id, amount_remaining

Invoice event body fields (final API channel payload):

FieldTypeDescription
idstringEvent ID (evt_ prefix)
typestringinvoice.created / invoice.paid / invoice.payment_failed
created_atint64Invoice created timestamp (seconds)
data.object.invoice_idstringInvoice ID
data.object.subscription_idstringSubscription ID
data.object.customer_idstringCustomer ID
data.object.amount_dueint64Amount due
data.object.amount_paidint64Amount paid
data.object.amount_remainingint64Remaining amount
data.object.currencystringCurrency
data.object.statusstringInvoice status
data.object.payment_statusstringPayment status
data.object.billing_reasonstringBilling reason
data.object.period_startint64Billing period start
data.object.period_endint64Billing period end
data.object.paid_atint64Paid timestamp (optional)
data.object.sourcestringSource system

账单事件示例

{
  "id": "evt_1774924900123456789",
  "type": "invoice.paid",
  "created_at": 1774924800,
  "data": {
    "object": {
      "invoice_id": "202603311103103103010000000001",
      "subscription_id": "202603311103103101010000000001",
      "customer_id": "cust_001",
      "amount_due": 1999,
      "amount_paid": 1999,
      "amount_remaining": 0,
      "currency": "USD",
      "status": "paid",
      "payment_status": "paid",
      "billing_reason": "subscription_cycle",
      "period_start": 1774886400,
      "period_end": 1777478400,
      "paid_at": 1774925100,
      "source": "api"
    }
  }
}

退款事件(逐条)

事件类型触发条件data.object.status主要字段
refund.succeeded退款处理成功completedrefund_id、refund_amount、refund_currency
refund.failed退款处理失败failedrefund_id、refund_amount、refund_currency

退款事件 body(API 渠道最终推送)字段:

字段类型说明
idstring事件 ID(evt_ 前缀)
typestringrefund.succeeded / refund.failed
created_atint64退款状态更新时间戳(秒)
data.object.session_idstring原支付会话 ID
data.object.order_idstring商户订单 ID
data.object.refund_idstring系统退款 ID
data.object.external_refund_idstring商户退款 ID(可选)
data.object.refund_amountint64退款金额(最小货币单位)
data.object.refund_currencystring退款币种
data.object.original_currencystring原订单币种(可选)
data.object.statusstring退款状态(completed / failed)
data.object.sourcestring来源系统
Event TypeTriggerdata.object.statusPrimary Fields
refund.succeededRefund completed successfullycompletedrefund_id, refund_amount, refund_currency
refund.failedRefund failedfailedrefund_id, refund_amount, refund_currency

Refund event body fields (final API channel payload):

FieldTypeDescription
idstringEvent ID (evt_ prefix)
typestringrefund.succeeded / refund.failed
created_atint64Refund status update timestamp (seconds)
data.object.session_idstringOriginal payment session ID
data.object.order_idstringMerchant order ID
data.object.refund_idstringInternal refund ID
data.object.external_refund_idstringMerchant refund ID (optional)
data.object.refund_amountint64Refund amount in minor unit
data.object.refund_currencystringRefund currency
data.object.original_currencystringOriginal order currency (optional)
data.object.statusstringRefund status (completed / failed)
data.object.sourcestringSource system

退款事件示例

{
  "id": "evt_1774925000123456789",
  "type": "refund.succeeded",
  "created_at": 1774929600,
  "data": {
    "object": {
      "session_id": "202603311103101001010000000001",
      "order_id": "order_202603310001",
      "refund_id": "202603311103101003010000000099",
      "external_refund_id": "merchant_refund_20260331_0001",
      "refund_amount": 999,
      "refund_currency": "USDT",
      "original_currency": "USD",
      "status": "completed",
      "source": "api"
    }
  }
}

错误响应

{
  "error": "subscription_id is required"
}
{
  "error": {
    "code": "resource_not_found",
    "message": "invoice not found",
    "param": "invoice_id",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_missing",
    "message": "Missing required parameter: merchant_id",
    "param": "merchant_id",
    "doc_url": "https://docs.stablepay.co/errors#parameter_missing"
  },
  "request_id": "req_xxx",
  "timestamp": 1774924800
}
最后更新 / Last Updated: 2026/3/31 16:37
Prev
支付服务 / Payment Service
Next
退款服务 / Refund Service