In their 2019-03-14 API update, Stripe changed the way they handle new subscriptions when card payment fails. Instead of letting the creation of the subscription fail, the subscription is failed with an "incomplete" status. Because of this a Cashier customer will always get a successful subscription. Previously a card exception was thrown.
To accommodate for this new behavior from now on Cashier will cancel that subscription immediately and throw a custom SubscriptionCreationFailed
exception when a subscription is created with an "incomplete" or "incomplete_expired" status. We've decided to do this because in general you want to let a customer only start using your product when payment was received.
If you were relying on catching the \Stripe\Error\Card
exception before you should now rely on catching the Laravel\Cashier\Exceptions\SubscriptionCreationFailed
exception instead.
Previously, when a user attempted to change subscription plans and their payment failed, the resulting exception bubbled up to the end user and the update to the subscription in the application was not performed. However, the subscription was still updated in Stripe itself resulting in the application and Stripe becoming out of sync.
However, Cashier will now catch the payment failure exception while allowing the plan swap to continue. The payment failure will be handled by Stripe and Stripe may attempt to retry the payment at a later time. If the payment fails during the final retry attempt, Stripe will execute the action you have configured in your billing settings: https://stripe.com/docs/billing/lifecycle#settings
Therefore, you should ensure you have configured Cashier to handle Stripe's webhooks. When configured properly, this will allow Cashier to mark the subscription as cancelled when the final payment retry attempt fails and Stripe notifies your application via a webhook request. Please refer to our instructions for setting up Stripe webhooks with Cashier..
Like the latest releases of the Laravel framework, Laravel Cashier now requires PHP >= 7.1.3. We encourage you to upgrade to the latest versions of PHP and Laravel before upgrading to Cashier 9.0.
The updateCard
call was extracted from the createAsStripeCustomer
method on the Billable
trait in PR #588. In addition, the $token
parameter was removed.
If you were calling the createAsStripeCustomer
method directly you now should call the updateCard
method separately after calling the createAsStripeCustomer
method. This provides the opportunity for more granularity when handling errors for the two calls.
Instead of calling the Stripe API to verify incoming webhook events, Cashier now only uses webhook signatures to verify that events it receives are authentic as of PR #591.
The VerifyWebhookSignature
middleware is now automatically added to the WebhookController
if the services.stripe.webhook.secret
value is set in your services.php
configuration file. By default, this configuration value uses the STRIPE_WEBHOOK_SECRET
environment variable.
If you manually added the VerifyWebhookSignature
middleware to your Cashier webhook route, you may remove it since it will now be added automatically.
If you were using the CASHIER_ENV
environment variable to test incoming webhooks, you should set the STRIPE_WEBHOOK_SECRET
environment variable to null
to achieve the same behavior.
More information about verifying webhooks can be found in the Cashier documentation.