底辺SE奮闘記

年収300万SEブログ

【Stripe・Laravel Cashier】Stripe\Exception\InvalidRequestException: You cannot set the quantity for metered plans. エラー対処

現象

サブスクリプションプラン購入の下記コードで表題のエラー

$_user->newSubscription("main", $_planId)
    ->create($_paymentMethod);

環境

  • Laravel 5.8
  • Laravel Cashier 10.0

解法

数量を0とする

$_user->newSubscription("main", $_planId)
    ->quantity(0)
    ->create($_paymentMethod);