private function validatePayment($transactionId, $paymentResult) { $cart = $this->context->cart; $customer = new Customer($cart->id_customer); if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active || !Validate::isLoadedObject($customer)) { Tools::redirect($this->checkoutUrl); } $currency = $this->context->currency; $orderTotal = (double) $cart->getOrderTotal(true, Cart::BOTH); $responseCheckout = SkrillPaymentCore::getResponseArray($paymentResult); $transactionLog = $this->setTransactionLog($transactionId, $currency, $orderTotal, $responseCheckout); VersionTracker::sendVersionTracker($this->module->getVersionData()); $this->saveTransactionLog($transactionLog, $responseCheckout); $isFraud = $this->isFraud($orderTotal, $responseCheckout); $isAuthorized = $this->isAuthorized(); if ($isFraud or !$isAuthorized) { $this->processFraudPayment($responseCheckout); } $this->processSuccessPayment($cart, $customer, $currency, $orderTotal, $responseCheckout, $transactionLog); }
public function hookdisplayAdminOrder() { $orderId = Tools::getValue('id_order'); $sql = "SELECT * FROM skrill_order_ref WHERE id_order ='" . $orderId . "'"; $row = Db::getInstance()->getRow($sql); if ($row) { if (Tools::isSubmit('skrillUpdateOrder') && $row['order_status'] != $this->refundedStatus) { $fieldParams = $this->getSkrillCredentials(); $fieldParams['type'] = 'mb_trn_id'; $fieldParams['id'] = $row['ref_id']; $paymentResult = ''; $isPaymentAccepted = SkrillPaymentCore::isPaymentAccepted($fieldParams, $paymentResult); if ($isPaymentAccepted) { $responseUpdateOrder = SkrillPaymentCore::getResponseArray($paymentResult); $this->updateTransLogStatus($row['ref_id'], $responseUpdateOrder['status']); $sql = "SELECT * FROM skrill_order_ref WHERE id_order ='" . $orderId . "'"; $row = Db::getInstance()->getRow($sql); } } $paymentInfo = array(); $paymentInfo['name'] = $this->getFrontendPaymentLocale($row['payment_method']); $isSkrill = strpos($paymentInfo['name'], 'Skrill'); if ($isSkrill === false) { $paymentInfo['name'] = 'Skrill ' . $paymentInfo['name']; } $trnStatus = SkrillPaymentCore::getTrnStatus($row['order_status']); $paymentInfo['status'] = $this->getTrnStatusLocale($trnStatus); $paymentInfo['method'] = $this->getFrontendPaymentLocale('SKRILL_FRONTEND_PM_' . $row['payment_code']); $paymentInfo['currency'] = $row['currency']; $additionalInformation = $this->getAdditionalInformation($row['add_information']); $langId = Context::getContext()->language->id; $orderOriginId = $this->getCountryIdByIso($additionalInformation['SKRILL_BACKEND_ORDER_ORIGIN']); $paymentInfo['order_origin'] = Country::getNameById($langId, $orderOriginId); $getCountryIso2 = SkrillPaymentCore::getCountryIso2($additionalInformation['SKRILL_BACKEND_ORDER_COUNTRY']); $orderCountryId = $this->getCountryIdByIso($getCountryIso2); $paymentInfo['order_country'] = Country::getNameById($langId, $orderCountryId); $buttonUpdateOrder = $row['order_status'] == $this->refundedStatus ? false : true; $this->context->smarty->assign(array('orderId' => $orderId, 'paymentInfo' => $paymentInfo, 'buttonUpdateOrder' => $buttonUpdateOrder)); return $this->display(__FILE__, 'views/templates/hook/displayAdminOrder.tpl'); } return ''; }