【发布时间】:2020-02-04 18:09:05
【问题描述】:
好吧,这对我来说毫无意义。订阅的方法显然返回 true,但随后取消返回“call to member function cancel on null”。这应该根据 Cashier 的文档工作。有谁知道它为什么会这样做?
public function cancel() {
$user = auth()->user();
if( $user->subscribed('CkWraps Subscription') ) {
$user->subscription('CKWraps Subscription')->cancel();
}
return back()->with('status', 'Your subscription has been canceled. We\'re sorry to see you go!');
}
【问题讨论】:
-
那么
cancel()调用会抛出异常吗?你能分享堆栈跟踪吗? -
没有堆栈跟踪,只有那个错误。如果我 dd out $user->subscribed('CkWraps Subscription') 它返回 true,但如果我 dd out $user->subscription('CKWraps Subscription') 它返回 null,这根本没有意义。
-
实际上,如果我在取消它返回订阅对象之前转储 $user->subscription('CKWraps Subscription') ......这只会变得更愚蠢
-
也许改用
cancelNow()? -
我做了,结果一模一样。
标签: php stripe-payments laravel-cashier