【问题标题】:How to pass quantity in the swapAndInvoice Laravel Cashier's method?如何在 swapAndInvoice Laravel Cashier 的方法中传递数量?
【发布时间】:2021-03-03 18:59:53
【问题描述】:

我正在尝试使以下工作:

$company->subscription('default')->swapAndInvoice($price_id,['quantity'=>$quantity]);

但我收到以下消息:

收到项目和数量参数。请只传一个。

我也试过这个:

$company->subscription('default')->swapAndInvoice($price_id,['items' => ['quantity'=>$quantity]]);

然后我得到一个无效的数组错误:

[2020-11-20 10:48:53] local.ERROR: Invalid array {"userId":1,"exception":"[object] (Stripe\\Exception\\InvalidRequestException(code: 0): Invalid array at C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\Exception\\ApiErrorException.php:38)
[stacktrace]
#0 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\Exception\\InvalidRequestException.php(35): Stripe\\Exception\\ApiErrorException::factory('Invalid array', 400, '{\
  \"error\": {\
...', Array, Object(Stripe\\Util\\CaseInsensitiveArray), NULL)
#1 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(187): Stripe\\Exception\\InvalidRequestException::factory('Invalid array', 400, '{\
  \"error\": {\
...', Array, Object(Stripe\\Util\\CaseInsensitiveArray), NULL, 'items')
#2 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(149): Stripe\\ApiRequestor::_specificAPIError('{\
  \"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray), Array, Array)
#3 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(461): Stripe\\ApiRequestor->handleErrorResponse('{\
  \"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray), Array)
#4 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(118): Stripe\\ApiRequestor->_interpretResponse('{\
  \"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray))
#5 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiOperations\\Request.php(63): Stripe\\ApiRequestor->request('post', '/v1/subscriptio...', Array, Array)

切换到新计划时传递新数量的正确方法是什么?

【问题讨论】:

    标签: stripe-payments laravel-cashier


    【解决方案1】:

    所以我一直在挖掘,我发现它的称呼是:

    $company->subscription('default')->swapAndInvoice([$price_id => ['quantity' => $quantity]]);
    

    当我从this issue 转到this commit 时,我最终发现了这一点。有一个名为 test_swapping_subscription_and_adopting_new_quantity 的函数,您可以在其中查看它是如何完成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-13
      • 1970-01-01
      • 2021-09-26
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 2019-01-21
      相关资源
      最近更新 更多