orderId)->first(); // Find related resource $resource = VisaMasterPaymentOrderItem::where('online_payment_history_id', $paymentHistory->id)->first(); // If resource could not be found or does not exist, then inform it via logs if (! $resource) { static::logResourceNotFound($request, $paymentHistory); return static::resourceNotFound(); } $bank_branch = $resource->parent->branch; $response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [ 'language' => 'ru', 'orderId' => $request->orderId, 'userName' => $bank_branch->billing_visa_master_username, 'password' => $bank_branch->billing_visa_master_password, ]); $payment_status = $response['ErrorCode'] == '0'; if ($payment_status) { $resource->update([ 'payer_name' => $response['cardholderName'], 'payer_card' => $response['Pan'], 'paid' => true, ]); $paymentHistory->update([ 'paymentStatus' => OnlinePaymentRepo::PAID, ]); return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource); } $resource->update([ 'payer_name' => $response['cardholderName'] ?? '-', 'payer_card' => $response['Pan'] ?? '-', ]); $paymentHistory->update([ 'paymentStatus' => OnlinePaymentRepo::FAILED, ]); return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource); } }