Skip to content

Commit

Permalink
send the response asap, before processing the event
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Aug 8, 2024
1 parent 10c3c10 commit 35af04a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controllers/WebhooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public function actionHandle(): YiiResponse
return $this->asRaw('Err');
}

$this->response->setStatusCode(200);
// as per https://docs.stripe.com/webhooks#acknowledge-events-immediately - send response asap
$this->response->sendAndClose();

// Handle the event
$webhookService->processEvent($event);

$this->response->setStatusCode(200);
// leaving this in even after sendAndClose() so that the response type matches
return $this->asRaw('OK');
}

Expand Down

0 comments on commit 35af04a

Please sign in to comment.