Laravel 4 如何从带Laravel收银台的条纹计划中删除优惠券4

Laravel 4 如何从带Laravel收银台的条纹计划中删除优惠券4,laravel-4,stripe-payments,laravel-cashier,Laravel 4,Stripe Payments,Laravel Cashier,我目前正在尝试实施一种方法,将人们转移到一个新的计划中。我遇到的问题是,旧计划中的优惠券继续存在,用户不收费。每次我试图删除旧优惠券,它似乎不允许它 protected function swapToYearlyPlan(){ $user = Auth::user(); // Tried this, doesn't work // $user->subscription()->retrieve($user->stripe_subscription)-&g

我目前正在尝试实施一种方法,将人们转移到一个新的计划中。我遇到的问题是,旧计划中的优惠券继续存在,用户不收费。每次我试图删除旧优惠券,它似乎不允许它

protected function swapToYearlyPlan(){
    $user = Auth::user();
    // Tried this, doesn't work
    // $user->subscription()->retrieve($user->stripe_subscription)->deleteDiscount();

    // This works fine
    $user->subscription('Gold Annual Plan')->swap();

    // Tried this, doesn't work
    //$user->subscription()->applyCoupon(NULL);

    return 'Upgraded plan!';
}

思想是值得赞赏的。干杯。

以下是最终奏效的方法:

protected function swapToYearlyPlan(){
    $company = Auth::user()->company;
    $customer = $company->subscription()->getStripeCustomer();

    if($customer->subscription->discount instanceof Stripe_Object){
        $customer->subscription->deleteDiscount();
    }

    $company->subscription("Gold Annual Plan")->swapAndInvoice();

    // Dealing with GST is a whole other issue

    return 'Upgraded Gold Annual plan!';
}
我在这里处理的是遗留代码,所以有很多细节还不清楚。例如,
deleteDiscount
方法甚至不是Laravel出纳的功能,或者至少不是我正在使用的版本。该方法包含在我的项目中,位于此处的另一整套代码中:
vendor/stripe/stripe php/lib/stripe
,而Laravel-Cashier位于
vendor/Laravel/Cashier/src/Laravel/Cashier

总的来说,我发现Laravel文档再次缺乏详细性和示例。它说它可以处理优惠券,它展示了如何添加优惠券,而不是如何删除优惠券,所以我认为它不能,这可能是其他图书馆必须被包括在内的原因。但这都是猜测