出纳员Laravel创建新订阅时出错 [英] Cashier Laravel error on create new Subscription

查看:82
本文介绍了出纳员Laravel创建新订阅时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中实施laravel收银员.我有laravel 5.5和收银员7.2.2.

I'm trying to implements laravel cashier in my project. I have laravel 5.5 and cashier 7.2.2.

我尝试创建NewSubscription时遇到问题.

I have a problem when I try to createNewSubscription.

在我的控制器中,我有:

In my controller I have:

$user = User::find(3);
$subscription = $user->newSubscription('Base', 'price_45asd456a1sa56sd4');
$subscription->create($token);

但是我收到此错误:

在null上调用成员函数create()"在/var/www/html/vendor/laravel/cashier/src/Billable.php

"Call to a member function create() on null" on line 415 of /var/www/html/vendor/laravel/cashier/src/Billable.php

问题在于特质返回错误:

The problem is that in trait return error in:

$card = $customer->sources->create(['source' => $token]);

因为 $ customer-> sources 为空.但是为什么呢?

Because $customer->sources is null. But why?

我可以看到在我的数据库中设置了stripe_id,并在Stripe的仪表板中创建了Customer.

I can see that in my db the stripe_id is setted, and in dashboard of stripe the Customer is created.

推荐答案

我遇到了相同的错误,并且在本地发生,但是在生产环境中有效.因此,我检查了我正在使用的Stripe API版本(最新版本),因此如果您在此处,您将看到默认情况下不再包含客户的 sources 属性"所以可能这就是为什么我们会收到此错误.

I'm with the same bug and was happening locally, but on production works. So I checked the Stripe API version that I'm using (the latest) so if you check here you will see that "The sources property on Customers is no longer included by default" so probably this is why we're getting this error.

这篇关于出纳员Laravel创建新订阅时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆