From 5b5264a85ac517d150cedc5f8ab9ed4e002930b6 Mon Sep 17 00:00:00 2001 From: tnateghi Date: Sat, 21 Dec 2024 23:13:49 +0330 Subject: [PATCH] fix zibal gateway 500 response (#292) --- src/Drivers/Zibal/Zibal.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Drivers/Zibal/Zibal.php b/src/Drivers/Zibal/Zibal.php index 1247e20..530bc14 100644 --- a/src/Drivers/Zibal/Zibal.php +++ b/src/Drivers/Zibal/Zibal.php @@ -138,22 +138,25 @@ public function verify() : ReceiptInterface $curl = curl_init(); + $postData = json_encode([ + "merchant" => $this->settings->merchantId, + "trackId" => $transactionId, + ]); + curl_setopt_array($curl, array( CURLOPT_URL => $this->settings->apiVerificationUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, + CURLOPT_TIMEOUT => 30, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS =>'{ - "merchant": "'.$this->settings->merchantId.'", - "trackId": "'.$transactionId.'", - }', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json' - ), + CURLOPT_POSTFIELDS => $postData, + CURLOPT_HTTPHEADER => [ + 'Content-Type: application/json', + 'Content-Length: ' . strlen($postData), + ], )); $response = curl_exec($curl);