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

ThriveCart测试模式下订阅创建与取消的测试及报错排查

解决ThriveCart订阅取消报错与测试流程

取消订阅报错处理

你遇到的"error": "You must provide matching customer IDs."错误,核心原因是接口参数中的订单、订阅与客户信息不匹配,或者缺少必要的客户参数:

  1. 核对参数关联性:检查webhook收到的订阅成功通知,确认order_id、subscription_id、customer_id属于同一用户,确保你存储的这三个值没有混淆
  2. 补充必要参数:根据ThriveCart的取消订阅接口要求,尝试在form_params中添加customer_id参数,修改后的代码片段如下:
use GuzzleHttp\Client;

$client = new Client();
$cancel_url = 'https://thrivecart.com/api/external/cancelSubscription?passthrough[type]=cancel';

try{
    Log::info("Canceling subscription plan");

    $res = $client->request(
        'POST',
        $cancel_url,
        [
            'headers' => [
                'Authorization' => 'Bearer ' . $api_key,
                'X-TC-Mode' => $api_mode,
            ],
            'form_params' => [
                'order_id' => $thrivecart_order_id,
                'subscription_id' => $thrivecart_subscription_id,
                'customer_id' => $thrivecart_customer_id // 新增客户ID参数
            ]
        ]
    );
} catch (\Exception $e) {
    Log::error("Cancel subscription failed: " . $e->getMessage());
}

ThriveCart订阅功能测试步骤

1. 配置测试环境

  • 在ThriveCart后台进入「设置→API&Webhooks」,启用测试模式,确保X-TC-Mode设置为test,同时使用测试专用的API密钥
  • 确保你的Laravel项目中,api_mode变量已设置为test,API密钥使用测试环境的密钥

2. 创建测试订阅商品

  • 在ThriveCart后台的商品管理中,创建一个订阅类型的商品,开启测试支付选项
  • 配置商品的订阅周期、金额等信息,确保测试模式下可以使用模拟支付

3. 完整测试订阅流程

  • 从你的Laravel项目页面点击「Select this plan」,跳转到ThriveCart测试结账页
  • 使用测试支付卡号(如Stripe测试卡4242 4242 4242 4242,有效期填未来月份,CVC填任意3位数字)完成支付
  • 确认你的Laravel项目收到ThriveCart发送的订阅成功webhook通知,记录返回的order_id、subscription_id、customer_id
  • 在ThriveCart后台的「测试订单」列表中查看该订单,确认所有信息正确关联

4. 验证与测试取消功能

  • 调用ThriveCart的查询订阅接口,传入subscription_id,确认订阅状态为「活跃」
  • 使用记录的正确order_id、subscription_id、customer_id调用取消订阅接口,验证是否能成功取消
  • 取消后,查看ThriveCart后台的订阅状态,确认已变为「已取消」,同时检查是否收到对应的webhook通知

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 01:06:03