This commit is contained in:
2025-09-09 11:33:28 +05:00
parent 40565033b6
commit ed65172b07
3 changed files with 52 additions and 29 deletions

View File

@@ -447,44 +447,49 @@ function syncWithBankSystem(
$amount = $online_payment_tmt_amount;
$payPurpose = $pay_purpose;
$curl = curl_init();
return [
'amount' => $amount,
'amount_formatted' => number_format($amount, 2, '.', ''),
];
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',
],
]);
// $curl = curl_init();
$response = curl_exec($curl);
// 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',
// ],
// ]);
curl_close($curl);
// $response = curl_exec($curl);
return $response;
// curl_close($curl);
// return $response;
}
/**
* Get Sber credentials for a given payment item.
*
* @param SberPaymentOrderItem $item
* @return array{username?: string, password?: string, onlinePaymentResource?: OnlinePaymentHistory, error?: string, type?: 'danger'|'modal'}
* @return array{username?: string, password?: string, onlinePaymentResource?: OnlinePaymentHistory, relatedResource?: mixed, error?: string, type?: 'danger'|'modal'}
*/
function getSberCredentials(SberPaymentOrderItem $item): array
{
@@ -502,6 +507,8 @@ function getSberCredentials(SberPaymentOrderItem $item): array
return ['error' => 'Bu resource tapylmady', 'type' => 'danger'];
}
$relatedResource->loadMissing(['branch']);
if (! $relatedResource->branch) {
return ['error' => 'Şahamça bilen birikdirilmedik', 'type' => 'danger'];
}
@@ -517,5 +524,6 @@ function getSberCredentials(SberPaymentOrderItem $item): array
'username' => $username,
'password' => $password,
'onlinePaymentResource' => $onlinePaymentResource,
'relatedResource' => $relatedResource,
];
}

View File

@@ -25,6 +25,10 @@ use Spatie\MediaLibrary\InteractsWithMedia;
* @property int $user_id
* @property string $address
* @property array $sender_datas
* @property ?string $sender_full_name
* @property ?string $sender_passport_serie
* @property ?string $sender_passport_number
* @property ?string $sender_deposit_account
* @property array $payment_reciever
* @property string $documents
* @property string $status

View File

@@ -44,9 +44,20 @@ class SyncWithSystem extends Action
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
$onlinePaymentResource = $result['onlinePaymentResource'];
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $sberPaymentOrder */
$sberPaymentOrder = $result['relatedResource'];
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
// syncWithBankSystem();
info(syncWithBankSystem(
online_payment_order_uuid: $onlinePaymentResource->orderId,
bank_unique_code: $sberPaymentOrder->branch->unique_code,
online_payment_terminal_id: $response['terminalId'],
user_deposit_account: $sberPaymentOrder->sender_deposit_account,
online_payment_auth_ref_num: $response['authRefNum'],
online_payment_tmt_amount: $response['paymentAmountInfo']['depositedAmount'],
pay_purpose: $sberPaymentOrder->created_at->translatedFormat('F').' '.$sberPaymentOrder->created_at->format('Y')
));
return Action::modal('modal-response', [
'title' => 'HALKBANK API',