Laravel - 收银员 | swap() 和 cancelNow() 为 null

Laravel - Cashier | swap() and cancelNow() on null

基本上我一直遇到这个问题。

用户订阅后,一切正常。他可以cancel/change订阅没问题。

但是,一旦他们更改了一次订阅,我就无法调用 swap 或 cancel 而不会在 null 上抛出错误

在 null 时调用成员函数 cancelNow() 在 null

上调用成员函数 Swap()

两者都表示 $user->subscription($membership_group) = null。

这可能是什么原因造成的?

这是我找到的解决方案,非常难看!我会报告这个错误。

    $user->subscription('current_plan')->swap('plan_to_subscribe');
    $user->save();

    // Messed up work around cause of swap method bug
    DB::update('update subscriptions set name = ? where user_id = ?', [
        $plan,
        $user->id
    ]);

无论如何暂时有效...

另外我想这已经修复了:https://github.com/laravel/cashier/commit/1e87a60f1bf5c8981730d2481350f74fccaf0947#diff-dde586b4ea0798ea4a467b9eba070a7e

等待发布。