-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for WebhookHandled event #803
Comments
A solution you could use in the meantime is to override the <?php
namespace App\Http\Controllers;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
use Illuminate\Http\Request;
use App\Events\WebhookHandled;
class MyWebhookController extends CashierController
{
public function handleWebhook(Request $request)
{
parent::handleWebhook($request);
event(new WebhookHandled($request));
}
} If you want the event to fire before the webhook is handled, move the dispatch above |
@cwilby Thanks. I already used the same solution as of now. Though I haven't fired the event, just put code there send an email via a job. |
With #810 two new events |
WebhookHandled Event Support
Cashier provides a great in-built way to handle webhook from Stripe. When some modification happens on a remote stripe website with the subscription it handles it and makes changes to subscriptions in the database.
Problem/Use Case
The additional use case that we came to last week was, When any customer is canceling a Subscription, we want to send him an email to know what was the reason he canceled his subscription and get the feedback. It needs to be done from both website as well as if a user is canceling subscription form the Stripe website directly.
There can be lots of other use cases, where if something happens on Stripe, we need to notify the user after his subscription changes have been recorded to databases via Webhook. E.g.
etc.
Proposed Solution
As a solution, Cashier can fire an event after successful webhook handling. A user can optionally listen for that event in code and then can read the payload and take whatever action he wanted to take by reading
$payload['type']
.How to listen to WebhookHandled Event
As per Laravel documentation here, create a listener to listen to the event.
I think by this way, we can give a very clean way if someone is optionally want to take some extra actions on webhooks.
The text was updated successfully, but these errors were encountered: