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

如何通过Shopify API验证支付完成后的Charge ID

验证Shopify支付charge_id对应的金额

你可以通过Shopify Admin GraphQL API查询charge_id对应的订阅详情,获取定价金额完成交叉验证,具体操作如下:

1. 发送GraphQL查询请求

使用以下curl命令查询charge_id(即订阅的全局ID)的完整信息:

curl -X POST https://syzb.myshopify.com/admin/api/2022-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: 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' \
-d '{
  "query": "query GetAppSubscription($id: ID!) { node(id: $id) { ... on AppSubscription { id name lineItems { plan { ... on AppRecurringPricing { price { amount currencyCode } interval } ... on AppUsagePricing { cappedAmount { amount currencyCode } terms } } } } }",
  "variables": {
    "id": "替换为你的charge_id"
  }
}'

2. 解析结果验证金额

返回数据中的lineItems会包含订阅的定价细节:

  • 周期性订阅项:查看price.amount和price.currencyCode,对应你创建时设置的99.50 USD
  • 使用量订阅项:查看cappedAmount.amount和cappedAmount.currencyCode,对应你创建时设置的10.25 USD

注意事项

  • 确保你的访问令牌拥有read_own_subscriptions权限,否则会返回权限错误
  • 替换variables中的id为支付成功后返回URL查询参数里的charge_id(需为完整的Shopify全局ID,格式类似gid://shopify/AppSubscription/xxxxxx)

内容的提问来源于stack exchange,提问作者Jaskaran Singh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 15:09:22