You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Chilkat库调用eBay REST API获取未付款/已付款未发货订单

适用的eBay REST API说明

你对Buy Order API的理解是正确的,该接口仅面向买家侧采购场景,卖家查询店铺销售订单应使用Sell Fulfillment API下的getOrders接口,这是官方提供的卖家订单查询REST接口,完全匹配你的需求。

订单筛选规则

你需要的两类订单可以通过接口的filter参数直接筛选,不需要二次处理返回结果:

  • 买家未付款订单:筛选条件为 orderPaymentStatus:{NOT_PAID}
  • 买家已付款未发货订单:筛选条件为 orderPaymentStatus:{PAID} AND orderFulfillmentStatus:{NOT_FULFILLED}
    两种条件可通过OR拼接,单次请求即可拉取所有目标订单。

VB6/VBA 结合 Chilkat ActiveX 调用示例

前置准备

首先需要在eBay开发者平台申请权限范围为https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly的OAuth2访问令牌,确认账号有卖家数据访问权限。

调用代码示例

' 首先加载Chilkat Http组件
Dim http As New ChilkatHttp
Dim success As Long

' 组件解锁,替换为你自己的Chilkat激活码
success = http.UnlockComponent("你的Chilkat激活码")
If success <> 1 Then
    MsgBox http.LastErrorText
    Exit Sub
End If

' 设置OAuth2访问令牌
http.AuthToken = "你申请到的eBay OAuth2令牌"

' 构造请求URL,注意filter参数需要URL编码,这里示例是拼接两种订单的筛选条件
Dim reqUrl As String
reqUrl = "https://api.ebay.com/sell/fulfillment/v1/orders?filter=orderPaymentStatus%3A%7BNOT_PAID%7D%20OR%20%28orderPaymentStatus%3A%7BPAID%7D%20AND%20orderFulfillmentStatus%3A%7BNOT_FULFILLED%7D%29"

' 发送GET请求
Dim respStr As String
respStr = http.QuickGetStr(reqUrl)
If http.LastMethodSuccess <> 1 Then
    MsgBox http.LastErrorText
    Exit Sub
End If

' 解析返回的JSON结果
Dim json As New ChilkatJsonObject
success = json.Load(respStr)
If success <> 1 Then
    MsgBox json.LastErrorText
    Exit Sub
End If

' 遍历订单列表
Dim orderCount As Long
orderCount = json.SizeOfArray("orders")
Dim i As Long
For i = 0 To orderCount - 1
    json.I = i
    ' 读取订单号、买家信息、金额等字段,可根据需要自行扩展
    Debug.Print "订单ID:" & json.StringOf("orders[i].orderId")
    Debug.Print "付款状态:" & json.StringOf("orders[i].orderPaymentStatus")
    Debug.Print "发货状态:" & json.StringOf("orders[i].orderFulfillmentStatus")
Next

注意事项

  • 测试阶段可使用eBay沙箱环境,将请求域名替换为https://api.sandbox.ebay.com即可
  • 接口有调用频率限制,可根据业务需求合理控制请求间隔
  • 返回的订单数据中包含所有交易相关信息,可根据实际需要解析对应字段

内容的提问来源于stack exchange,提问作者Daniel Alexander Karr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 04:21:03