Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions includes/class-wc-gateway-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,29 @@ public function process_webhooks() {
return;
}


// Tell PHP to keep running even if Paystack closes the connection early
ignore_user_abort( true );

// Send 200 OK immediately to satisfy Paystack's webhook timeout
http_response_code( 200 );

// Close the connection to the client so they don't hang, but keep the script running
if ( function_exists( 'fastcgi_finish_request' ) ) {
fastcgi_finish_request();
} elseif ( function_exists( 'litespeed_finish_request' ) ) {
litespeed_finish_request();
} else {
// Fallback for standard server environments
header( 'Connection: close' );
header( 'Content-Length: ' . ob_get_length() );
ob_end_flush();
@ob_flush();
flush();
}



sleep( 10 );

$paystack_response = $this->get_paystack_transaction( $event->data->reference );
Expand All @@ -1422,8 +1445,6 @@ public function process_webhooks() {
exit;
}

http_response_code( 200 );

if ( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ), true ) ) {
exit;
}
Expand Down