This commit is contained in:
2025-09-09 11:14:24 +05:00
parent 5cb2f9027c
commit 40565033b6
2 changed files with 75 additions and 38 deletions

View File

@@ -4,6 +4,7 @@ use App\Events\EventType;
use App\Models\Payment\OnlinePaymentHistory;
use App\Models\System\Roles\Permission;
use App\Models\System\Verification;
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request as GuzzleRequest;
@@ -401,7 +402,7 @@ function emptyClass(...$arguments): object
* @param string $orderId
* @param int|string $username
* @param string $password
*
*
* @return mixed
*/
function checkOnlinePayment(string $orderId, int|string $username, string $password): mixed
@@ -426,19 +427,18 @@ function checkOnlinePayment(string $orderId, int|string $username, string $passw
* @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,
$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
{
): mixed {
$ecomId = $online_payment_order_uuid;
$agentId = $bank_unique_code;
$eposId = $online_payment_terminal_id;
@@ -479,3 +479,43 @@ function syncWithBankSystem(
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'}
*/
function getSberCredentials(SberPaymentOrderItem $item): array
{
/** @var \App\Models\Payment\OnlinePaymentHistory|null $onlinePaymentResource */
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
if (! $onlinePaymentResource) {
return ['error' => 'Online payment resource tapylmady', 'type' => 'danger'];
}
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
->find(id: $onlinePaymentResource->online_paymantable_id);
if (! $relatedResource) {
return ['error' => 'Bu resource tapylmady', 'type' => 'danger'];
}
if (! $relatedResource->branch) {
return ['error' => 'Şahamça bilen birikdirilmedik', 'type' => 'danger'];
}
$username = $relatedResource->branch->billing_sber_username;
$password = $relatedResource->branch->billing_sber_password;
if (empty($username) || empty($password)) {
return ['error' => 'Ulanyjy ady bilen açar sözi gabat gelmedi', 'type' => 'modal'];
}
return [
'username' => $username,
'password' => $password,
'onlinePaymentResource' => $onlinePaymentResource,
];
}