diff --git a/src/Http/Controllers/WebhookController.php b/src/Http/Controllers/WebhookController.php index b2d40e71..4b55590e 100644 --- a/src/Http/Controllers/WebhookController.php +++ b/src/Http/Controllers/WebhookController.php @@ -13,6 +13,7 @@ use Laravel\Cashier\Http\Middleware\VerifyWebhookSignature; use Laravel\Cashier\Payment; use Laravel\Cashier\Subscription; +use Stripe\Stripe as Stripe; use Stripe\Subscription as StripeSubscription; use Symfony\Component\HttpFoundation\Response; @@ -44,6 +45,8 @@ public function handleWebhook(Request $request) WebhookReceived::dispatch($payload); if (method_exists($this, $method)) { + $this->setMaxNetworkRetries(); + $response = $this->{$method}($payload); WebhookHandled::dispatch($payload); @@ -314,4 +317,15 @@ protected function missingMethod($parameters = []) { return new Response; } + + /** + * Set the number of automatic retries due to an object lock timeout from Stripe. + * + * @param int $retries + * @return void + */ + protected function setMaxNetworkRetries($retries = 3) + { + Stripe::setMaxNetworkRetries($retries); + } }