From 5a4759a1371e6eec9d85498d10b65cd97bfa2126 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Tue, 9 Sep 2025 16:31:30 +0500 Subject: [PATCH] wip --- app/Helpers/helpers.php | 50 +++++++++++------------- app/Nova/Actions/Sber/SyncWithSystem.php | 5 +-- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index ef5ed04..d690acf 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -447,37 +447,31 @@ function syncWithBankSystem( $amount = $online_payment_tmt_amount; $payPurpose = $pay_purpose; - $curl = curl_init(); + $client = new Client(); + $headers = [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz' + ]; + $body = '{ + "ecomId": "'.$ecomId.'", + "agentId": "'.$agentId.'", + "eposId": "'.$eposId.'", + "account": "'.$account.'", + "rnn": "'.$rrn.'", + "amount": "'.$amount.'", + "payPurpose": "'.$payPurpose.'" + }'; + $request = new GuzzleRequest('POST', 'http://10.3.158.102:8888/api/paytrn/new', $headers, $body); - curl_setopt_array($curl, [ - CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "ecomId": "'.$ecomId.'", - "agentId": "'.$agentId.'", - "eposId": "'.$eposId.'", - "account": "'.$account.'", - "rrn": "'.$rrn.'", - "amount": "'.$amount.'", - "payPurpose": "'.$payPurpose.'" - }', - CURLOPT_HTTPHEADER => [ - 'Authorization: Basic YWRtaW46UUFad3N4MTIz', - 'Content-Type: application/json' - ], - ]); + try { + $res = $client->sendAsync($request)->wait(); - $response = curl_exec($curl); + return $res->getBody(); + } catch (Exception $e) { + Log::error($e); - curl_close($curl); - - return $response; + return null; + } } /** diff --git a/app/Nova/Actions/Sber/SyncWithSystem.php b/app/Nova/Actions/Sber/SyncWithSystem.php index 1b5283c..f02dbfa 100644 --- a/app/Nova/Actions/Sber/SyncWithSystem.php +++ b/app/Nova/Actions/Sber/SyncWithSystem.php @@ -67,10 +67,7 @@ class SyncWithSystem extends Action info(['response' => $systemRawResponse]); - return Action::modal('modal-response', [ - 'html' => $systemRawResponse, - 'title' => 'SYSTEM API', - ]); + return Action::success('Sync with system success'); // $systemResponse = json_decode($systemRawResponse);