-
-
Notifications
You must be signed in to change notification settings - Fork 4
3. Webhook
-
Webhook is the URL to which instamojo send's the payment details as a POST request.
-
Quoting the Instamojo API docs:
We recommend passing both webhook and redirect_url URLs while creating the Payment link because users sometimes close the tab before redirection can happen and in that case, the webhook request comes in handy and will save you from manual updation of the database.
-
As said, our migrated table "mojo_payment_details" is updated through this webhook to avoid the risk of accidentally closing of the browser tab/window.
-
This controller will handle all incoming webhook requests and dispatch them to the proper controller method:
Route::post(
'instamojo/webhook',
'\Lubusin\Mojo\Controllers\WebhookController@handleWebhook'
);
- Since instamojo webhooks need to bypass Laravel's CSRF protection, be sure to list the URI as an exception in your VerifyCsrfToken middleware or list the route outside of the web middleware group:
protected $except = [
'instamojo/*',
];
NOTE: The Webhook URL should be a publicly available URL. Since instamojo sends a POST request to it, the localhost alias isn't available as it is not possible to access a local client. To test it locally you can try something like localtunnel
Since we are done with accepting payments, let's move to the next page to see how to show the transaction details to the users