Reputation: 510
I'm working with the Classic Paypal API and I'm stuck on a problem of responding before I process the request data.
public function store() {
// Send an empty HTTP 200 OK response to acknowledge receipt of the notification
response("", 200);
// Build the required acknowledgement message out of the notification just received
// Once it hits this point, nothing is sent to the client.
}
I know that in order for the client to receive the HTTP 200 response, I will need to add the return keyword in front of it. However, if I return the response immediately, then the processing of the request will not occur. I looked into before and after middlewares, but unfortunately they are not asynchronous. Is there any way of accomplishing a send then process in Laravel 5?
Upvotes: 5
Views: 5050
Reputation: 15
I found this, looks cleaner
response('Response', 200)->send();
// Continue with the script
// Don't forget to exit the script
Upvotes: 1
Reputation: 510
I found a hack solution to this problem:
try {
return response("", 200);
} finally {
// Controller logic here
}
Upvotes: 15