How to Handle subscription when customer's credit card expires / insufficient fund? Laravel Cashier

时间:2019-03-17 22:49:22

标签: laravel laravel-5 laravel-5.2 stripe-payments laravel-cashier

I know this thing will be handled by the webhooks, so i have added

Route::post(
   'stripe/webhook',
   '\Laravel\Cashier\Http\Controllers\WebhookController@handleWebhook'
   );

Also Added in VerifyCsrfToken Middleware

protected $except = [
    'stripe/*',
];

Now i don't know what to do next. Can anyone please explain the next steps? Also I am interesting to know what we have to do at stripe dashboard. i haven't done any thing at the stripe end. i mean no webhook started, please explain,

Thanks in Advance!!

1 个答案:

答案 0 :(得分:0)

https://stripe.com/docs/billing/lifecycle

通过阅读文档,如果付款过期/无法处理,您的Webhook将收到不完整/不完整的过期推送。

然后要处理并取消链接到与Webhook链接的用户的订阅,这是您的工作。

$user->subscription('main')->cancelNow()

https://laravel.com/docs/5.8/billing#cancelling-subscriptions

我以前没有使用过它,但是无论发送到您的Webhook的是什么,使用可用的数据来标识Webhook推送属于谁的订阅,并使用上面的行来取消订阅。