$models * @return mixed */ public function handle(ActionFields $fields, Collection $models) { if ($models->count() > 1) { return ActionResponse::danger('Diňä bir resursa barlap bolýar'); } $onlinePaymentResource = $models->first(); $relatedResource = (new $onlinePaymentResource->online_paymantable_type)->find(id: $onlinePaymentResource->online_paymantable_id); if (! $relatedResource) { return ActionResponse::danger('Bu resource tapylmady'); } $relatedResource->load('branch'); $username = ''; $password = ''; if ($onlinePaymentResource->api_client == 'billing_visa_master_username') { $username = $relatedResource->branch->billing_visa_master_username; $password = $relatedResource->branch->billing_visa_master_password; } if ($onlinePaymentResource->api_client == 'billing_username') { $username = $relatedResource->branch->billing_username; $password = $relatedResource->branch->billing_password; } if ($onlinePaymentResource->api_client == 'billing_sber_username') { $username = $relatedResource->branch->billing_sber_username; $password = $relatedResource->branch->billing_sber_password; } if ($username == '') { return Action::modal('modal-response', [ 'title' => 'HALKBANK API', 'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi', ]); } $response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [ 'language' => 'ru', 'orderId' => $onlinePaymentResource->orderId, 'userName' => $username, 'password' => $password, ]); return Action::modal('modal-response', [ 'title' => 'HALKBANK API', 'html' => self::resultHTML($response), ]); } /** * Get the fields available on the action. * * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function fields(NovaRequest $request) { return []; } /** * Result html * * @param $response */ public static function resultHTML(Response $response): string { $errorMessage = $response->offsetExists('actionCodeDescription') ? $response['actionCodeDescription'] : ''; $keyValueListHTML = json_encode($response->json(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); return Blade::render(<<HALKBANK-dan gelen netije:
$errorMessage
HTML); } }