This commit is contained in:
2025-09-09 11:06:36 +05:00
parent 4e1f286eb5
commit 0b63d9098e
3 changed files with 125 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
<?php
use App\Events\EventType;
use App\Models\Payment\OnlinePaymentHistory;
use App\Models\System\Roles\Permission;
use App\Models\System\Verification;
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
@@ -9,6 +10,7 @@ use GuzzleHttp\Psr7\Request as GuzzleRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Stevebauman\Location\Facades\Location;
@@ -392,3 +394,88 @@ function emptyClass(...$arguments): object
}
};
}
/**
* Check online payment
*
* @param string $orderId
* @param int|string $username
* @param string $password
*
* @return mixed
*/
function checkOnlinePayment(string $orderId, int|string $username, string $password): mixed
{
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
'language' => 'ru',
'orderId' => $orderId,
'userName' => $username,
'password' => $password,
]);
return $response;
}
/**
* Sync with bank system
*
* @param string $online_payment_order_uuid
* @param string $bank_unique_code
* @param string $online_payment_terminal_id
* @param string $user_deposit_account
* @param string $online_payment_auth_ref_num
* @param string $online_payment_tmt_amount
* @param string $pay_purpose
*
* @return mixed
*/
function syncWithBankSystem(
$online_payment_order_uuid,
$bank_unique_code,
$online_payment_terminal_id,
$user_deposit_account,
$online_payment_auth_ref_num,
$online_payment_tmt_amount,
$pay_purpose
): mixed
{
$ecomId = $online_payment_order_uuid;
$agentId = $bank_unique_code;
$eposId = $online_payment_terminal_id;
$account = $user_deposit_account;
$rrn = $online_payment_auth_ref_num;
$amount = $online_payment_tmt_amount;
$payPurpose = $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",
"rrn": "%s",
"amount": "%s",
"payPurpose": "%s"
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose),
CURLOPT_HTTPHEADER => [
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}