Skip to content

Commit

Permalink
[13.x] Handle Stripe Object lock timeout (#1259)
Browse files Browse the repository at this point in the history
* Handle Stripe Object lock timeout

* Update WebhookController.php

* Update WebhookController.php

* Update WebhookController.php

* Update WebhookController.php

Co-authored-by: Dries Vints <dries@vints.io>
  • Loading branch information
kyranb and driesvints authored Oct 8, 2021
1 parent 3d945a2 commit 3123282
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 3123282

Please sign in to comment.