diff --git a/app/Http/Controllers/OnlinePaymentController.php b/app/Http/Controllers/OnlinePaymentController.php index 94218e4..917070c 100644 --- a/app/Http/Controllers/OnlinePaymentController.php +++ b/app/Http/Controllers/OnlinePaymentController.php @@ -34,17 +34,17 @@ class OnlinePaymentController extends Controller /** @var \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem */ $resource = $data['resource']; - if ($data['success'] && $paymentHistory && is_array($paymentHistory->api_response)) { - info(OnlinePaymentRepo::syncWithBilling( - uuid: $paymentHistory->orderId, - bank_code: $bank->unique_code, - terminal_id: $paymentHistory->api_response['terminalId'], - account_number: $resource->parent->sender_datas[0]['deposit_account'], - rrn: $paymentHistory->api_response['authRefNum'], - amount: $resource->tmt_payment_amount, - pay_purpose: $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y'), - )); - } + // if ($data['success'] && $paymentHistory && is_array($paymentHistory->api_response)) { + // info(OnlinePaymentRepo::syncWithBilling( + // uuid: $paymentHistory->orderId, + // bank_code: $bank->unique_code, + // terminal_id: $paymentHistory->api_response['terminalId'], + // account_number: $resource->parent->sender_datas[0]['deposit_account'], + // rrn: $paymentHistory->api_response['authRefNum'], + // amount: $resource->tmt_payment_amount, + // pay_purpose: $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y'), + // )); + // } return view(OnlinePaymentRepo::statusView(), $data); } diff --git a/app/Repos/Payment/Billing/HandlesBillingSyncing.php b/app/Repos/Payment/Billing/HandlesBillingSyncing.php index 632d918..303b066 100644 --- a/app/Repos/Payment/Billing/HandlesBillingSyncing.php +++ b/app/Repos/Payment/Billing/HandlesBillingSyncing.php @@ -2,6 +2,9 @@ namespace App\Repos\Payment\Billing; +use GuzzleHttp\Client; +use GuzzleHttp\Psr7\Request; + trait HandlesBillingSyncing { /** @@ -16,16 +19,15 @@ trait HandlesBillingSyncing string $amount, string $pay_purpose, ) { - return sprintf( - '{ - "ecomId" : "%s", - "agentId" : "%s", - "eposId" : "%s", - "account" : "%s", - "rnn" : "%s", - "amount" : %s, - "payPurpose" : "%s" - }', + $body = sprintf('{ + "ecomId": "%s", + "agentId": "%s", + "eposId": "%s", + "account": "%s", + "rnn": "%s", + "amount": "%s", + "payPurpose": "%s" + }', $uuid, $bank_code, $terminal_id, @@ -34,45 +36,33 @@ trait HandlesBillingSyncing $amount, $pay_purpose, ); - $curl = curl_init(); - 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 => sprintf( - '{ - "ecomId" : "%s", - "agentId" : "%s", - "eposId" : "%s", - "account" : "%s", - "rnn" : "%s", - "amount" : %s, - "payPurpose" : "%s" - }', - $uuid, - $bank_code, - $terminal_id, - $account_number, - $rrn, - $amount, - $pay_purpose, - ), - CURLOPT_HTTPHEADER => [ - 'Authorization: Basic YWRtaW46UUFad3N4MTIz', - 'Content-Type: application/json', + $request = new Request( + method: 'POST', + uri: 'http://10.3.158.102:8888/api/paytrn/new', + headers: [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz', ], - ]); + body: $body + ); - $response = curl_exec($curl); + $client = new Client; + $response = $client->sendAsync($request)->wait(); - curl_close($curl); + // curl --location --request POST 'http://10.3.158.102:8888/api/paytrn/new' \ + // --header 'Authorization: Basic YWRtaW46UUFad3N4MTIz' \ + // --header 'Content-Type: application/json' \ + // --data-raw '{ + // "ecomId" : "0c406ee2-097d-42f7-86c8-18127bd87e10", + // "agentId" : "1307", + // "eposId" : "30400225", + // "account" : "4324234234", + // "rnn" : "002959773584", + // "amount" : 0.1, + // "payPurpose" : "Mart 2025" + // }' - return $response; + return $response->getBody(); } } diff --git a/resources/views/orders/loan/mobile/card-history.blade.php b/resources/views/orders/loan/mobile/card-history.blade.php index c6075dc..e3ac035 100644 --- a/resources/views/orders/loan/mobile/card-history.blade.php +++ b/resources/views/orders/loan/mobile/card-history.blade.php @@ -79,7 +79,7 @@ '{{ $card_month }}/{{ substr($card_year, 2) }}', 'card-history-details', )" - >{{ $resource->card_number }} + >{{ trim(chunk_split($resource->card_number, 4, ' ')) }}
{{ $resource->card_name }}
{{ $card_month }}/{{ $card_year }}