/** * This method save's all necessary request and response informations in the database * * @param order $order * @param SimpleXmlExtended $request * @param string $orderId * @param SimpleXMLElement $response */ public static function xmlLog($order, $request, $orderId = 'N/A', $response = null) { require_once dirname(__FILE__) . '/../../../languages/' . Session::getLang() . '/modules/payment/' . $order->info['payment_method'] . '.php'; $payment = Loader::getRatepayPayment($order->info['payment_method']); if ($payment->logging) { $transactionId = 'N/A'; $subType = 'N/A'; if ($request->head->{'transaction-id'}) { $transactionId = (string) $request->head->{'transaction-id'}; } if ($request->head->operation->attributes()->subtype) { $subType = (string) $request->head->operation->attributes()->subtype; } $operation = (string) $request->head->operation; $responseXml = 'N/A'; if (!empty($response)) { $responseXml = $response->asXML(); $result = (string) $response->head->processing->result; $resultCode = (string) $response->head->processing->result->attributes()->code; $reasonText = (string) $response->head->processing->reason; if ($response->head->{'transaction-id'}) { $transactionId = (string) $response->head->{'transaction-id'}; } } else { $result = "Service unavaible."; $resultCode = "Service unavaible."; } $sql = "INSERT INTO ratepay_log " . "(" . "order_number, " . "transaction_id, " . "payment_method, " . "payment_type, " . "payment_subtype, " . "result, " . "request, " . "response, " . "result_code, " . "reason" . ") " . "VALUES ('" . tep_db_input($orderId) . "', '" . tep_db_input($transactionId) . "', '" . tep_db_input($payment->title) . "', '" . tep_db_input($operation) . "', '" . tep_db_input($subType) . "', '" . tep_db_input($result) . "','" . tep_db_input($request->asXML()) . "','" . tep_db_input($responseXml) . "','" . tep_db_input($resultCode) . "','" . tep_db_input($reasonText) . "')"; tep_db_query($sql); if ($operation == "PAYMENT_CONFIRM" && $transactionId != 'N/A') { $sql = "UPDATE ratepay_log SET order_number = '" . tep_db_input($orderId) . "' WHERE transaction_id = '" . tep_db_input($transactionId) . "';"; tep_db_query($sql); } } }