06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Laravel Cashier 271<br />

1 Route::post(<br />

2 'braintree/webhook',<br />

3 '\Laravel\Cashier\Http\Controllers\WebhookController@handleWebhook'<br />

4 );<br />

That’s it! Failed payments will be captured and handled by the controller. The controller will cancel<br />

the customer’s subscription when Braintree determines the subscription has failed (normally after<br />

three failed payment attempts). Don’t forget: you will need to configure the webhook URI in your<br />

Braintree control panel settings.<br />

Since Braintree webhooks need to bypass Laravel’s CSRF verification, be sure to list the URI as<br />

an exception in your VerifyCsrfToken middleware or list the route outside of the web middleware<br />

group:<br />

1 protected $except = [<br />

2 'braintree/*',<br />

3 ];<br />

Other Webhooks<br />

If you have additional Braintree webhook events you would like to handle, simply extend the<br />

Webhook controller. Your method names should correspond to Braintree’s expected convention,<br />

specifically, methods should be prefixed with handle and the “camel case” name of the Braintree<br />

webhook you wish to handle. For example, if you wish to handle the dispute_opened webhook, you<br />

should add a handleDisputeOpened method to the controller.<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!