first(); $result = getSberCredentials($orderItem); if (isset($result['error'])) { $this->handleError($result); } /** @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']); 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: $orderItem->tmt_payment_amount, pay_purpose: $sberPaymentOrder->created_at->translatedFormat('F').' '.$sberPaymentOrder->created_at->format('Y') )); return Action::modal('modal-response', [ 'title' => 'HALKBANK API', 'html' => CheckOnlinePayment::resultHTML($response), ]); } /** * Get the fields available on the action. * * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function fields(NovaRequest $request) { return []; } /** * Handle error * * @param array $result */ private function handleError(array $result): mixed { if ($result['type'] === 'modal') { return Action::modal('modal-response', [ 'title' => 'HALKBANK API', 'body' => $result['error'], ]); } return ActionResponse::danger($result['error']); } }