【发布时间】:2019-03-20 10:31:56
【问题描述】:
我正在尝试将使用记录添加到我的订阅中。使用条带创建使用记录端点 (https://stripe.com/docs/api#usage_record_create)。
运行我的函数时我收到一个错误返回说Class 'Stripe\UsageRecord' not found in file 我还没有定义命名空间,因为我已经使用\Stripe\ 直接引用条纹访问它,我使用composer 引入。我试过composer update,但这似乎没有奏效。我猜它缺少 composer install 中的 UsageRecord.php 文件,但我不知道在哪里将文件的副本添加到条带包中
public function stripeUsageRecord()
{
$authUser = auth()->user();
$business = $authUser['business_id'];
$user_amount = Transactions::select("user_id")
->where("business_id", "=", $business)
->groupBy("user_id")->count();
$current_time = Carbon::now()->toDateTimeString();
\Stripe\Stripe::setApiKey(env("STRIPE_SECRET"));
\Stripe\UsageRecord::create(array(
"quantity" => $user_amount,
"timestamp" => $current_time,
"subscription_item" => 'sub_DnAKVwNY2Sc4zf',
"action" => 'set'
));
}
【问题讨论】:
-
如果你使用作曲家,你的文件中是否包含自动加载器?你是在向
use指定的班级声明你的意图吗? -
是的,我是。我的问题是条纹包确实缺少
UsageRecord.php
标签: php laravel composer-php stripe-payments