【问题标题】:"Received unknown parameter: 0" Stripe Api error“收到未知参数:0”条纹 Api 错误
【发布时间】:2020-06-23 11:56:34
【问题描述】:

我正在为 Web 应用程序实现订阅方法,现在创建所有内容,但订阅本身已经工作。 Buen 在尝试使用条带文档创建订阅时会抛出“收到的未知参数:0”,我不知道为什么。

//
$stripe = new \Stripe\StripeClient('KEY');    

$stripe->subscriptions->create([
        'cus_HWAaGjkeQMmJdj',
        'items' => [['price' => 'price_1GxAadBKTcCfnJHQwxEIcqNt']],
    ]);

我正在使用我知道存在的客户和价格,但我会抛出相同的错误。该示例与我的代码相同。任何人都知道为什么会发生此错误?

【问题讨论】:

    标签: php stripe-payments backend


    【解决方案1】:

    使用面向服务的模型[1],正确的语法是:

    $stripe->subscriptions->create([
      'customer' => 'cus_xxx',
      'items' => [
        ['price' => 'price_xxx'],
      ],
    ]);
    
    

    希望有帮助!

    [1]https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0

    【讨论】:

      【解决方案2】:

      customer 字段在创建 Stripe 订阅时是必需的。

      所以:

      $stripe->subscriptions->create([
              'cus_HWAaGjkeQMmJdj',
              'items' => [['price' => 'price_1GxAadBKTcCfnJHQwxEIcqNt']],
              'customer' => CUSTOMER_ID
          ]);
      

      您可以在他们的 API 文档页面上查看更多信息。 Press here

      【讨论】:

      • 谢谢,我尝试了这两个代码,但看起来我们在这里发送了两次 customer_id,一个是开头和 un "customer" => CUSTOMER_ID,两者都是客户 ID。
      猜你喜欢
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-20
      • 2020-02-12
      • 2019-10-19
      • 2020-01-16
      • 2019-09-10
      相关资源
      最近更新 更多