Skip to content

Commit

Permalink
Document handling failed payments.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 4, 2014
1 parent 3aea342 commit 051d765
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Cancelling A Subscription](#cancelling-a-subscription)
- [Resuming A Subscription](#resuming-a-subscription)
- [Checking Subscription Status](#checking-subscription-status)
- [Handling Failed Payments](#handling-failed-payments)
- [Invoices](#invoices)

<a name="configuration"></a>
Expand Down Expand Up @@ -183,6 +184,35 @@ if ($user->everSubscribed())
}
```

<a name="handling-failed-payments"></a>
## Handling Failed Payments

What if a customer's credit card expires? No worries - Cashier includes a Webhook controller that can easily cancel the customer's subscription for you. Just point a route to the controller:

```php
Route::get('stripe/webhook', 'Laravel\Cashier\WebhookController@handleWebhook');
```

The `stripe/webhook` URI in this example is just for example. You will need to configure the URI in your Stripe settings.

If you have additional Stripe webhook events you would like to handle, simply extend the Webhook controller:

```php
class WebhookController extends Laravel\Cashier\WebhookController {

public function handleWebhook()
{
// Handle other events...

// Fallback to failed payment check...
return parent::handleWebhook();
}

}
```

> **Note:** In addition to updating the subscription information in your database, the Webhook controller will also cancel the subscription via the Stripe API.
<a name="invoices"></a>
## Invoices

Expand Down

0 comments on commit 051d765

Please sign in to comment.