*/ public static function checkCardOrderPayment(Request $request): array { // Find order from history $paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first(); // Find related resource $resource = (new $paymentHistory->online_paymantable_type)->find(id: $paymentHistory->online_paymantable_id); // If resource could not be found or does not exist, then inform it via logs if (! $resource) { static::logResourceNotFound($request, $paymentHistory); return static::resourceNotFound(); } $resource->load('branch'); $bank_branch = $resource->branch; $response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [ 'language' => 'ru', 'orderId' => $request->orderId, 'userName' => $bank_branch->billing_username, 'password' => $bank_branch->billing_password, ]); $payment_status = $response['ErrorCode'] == '0'; $returnURL = $resource->panelUrl('index'); if ($payment_status) { $resource->update([ 'paid' => true, ]); $paymentHistory->update([ 'paymentStatus' => OnlinePaymentRepo::PAID, ]); return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response); } $paymentHistory->update([ 'paymentStatus' => OnlinePaymentRepo::FAILED, ]); return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response); } }