Exemplo n.º 1
0
 function addRequestLog($io, $tl_type, $tl_header, $tl_body)
 {
     if (modApiFunc('Settings', 'getParamValue', 'TIMELINE', $io) === 'NO') {
         return;
     }
     if (is_array($tl_body)) {
         $tl_body = prepareArrayDisplay($tl_body);
     }
     modApiFunc('Timeline', 'addLog', $tl_type, $tl_header, $tl_body);
 }
 /**
  * Otputs the view.
  *
  * @todo $request->setView  ( '' ) - define the view name
  */
 function output()
 {
     global $application;
     $ViewClassName = modApiFunc("Checkout", "getCurrentPaymentModuleSettingsViewName");
     $ViewClassName = 'get' . $ViewClassName;
     $this->_Current_Payment_Module = array("MODULE_NAME" => 'none_at_all');
     $application->registerAttributes($this->_Current_Payment_Module);
     //        $value = modApiFunc('TmplFiller', 'fill', "checkout/payment_module_settings/","container.tpl.html",array());
     return prepareArrayDisplay($this);
     //$value;
 }
 function __addRequestToTimeline($service_name, $from, $to, $rate, $request, $responce)
 {
     $tl_type = getMsg('CC', 'TL_TYPE');
     $tl_header = str_replace(array('{SERVICE}', '{FROM}', '{TO}'), array($service_name, $from, $to), getMsg('CC', 'TL_HEADER_REQUEST'));
     if ($rate != false) {
         $tl_header .= str_replace(array('{RATE}', '{FROM}', '{TO}'), array($rate, $from, $to), getMsg('CC', 'TL_HEADER_RESPONSE_OK'));
     } else {
         $tl_header .= getMsg('CC', 'TL_HEADER_RESPONSE_FIALED');
     }
     $tl_body = prepareArrayDisplay($request, getMsg('CC', 'TL_REQUEST'));
     $tl_body .= prepareArrayDisplay($responce, getMsg('CC', 'TL_RESPONSE'));
     modApiFunc('Timeline', 'addLog', $tl_type, $tl_header, $tl_body);
 }
 /**
  * Processes data on updating the order status, come from the payment gateway.
  * The flag &$bStop is set by the payment module. If it is true on return,
  * then Checkout module stops the data process, come from the payment gateway.
  */
 function processData($data, $order_id)
 {
     global $application;
     $obj =& $application->getInstance('MessageResources', "payment-module-paypal-messages", "AdminZone");
     //the first step of data processing from the Payment Gateway
     //the payment status update.
     //the next step.
     //do not call the Payment Gateway .
     $DBPaymentStatus = array();
     $status = $data["_GET"]["status"];
     //=========================== logging request ========================
     $msgObj = $application->getInstance("MessageResources", "payment-module-paypal-messages", "AdminZone");
     $title = $msgObj->getMessage("MODULE_PAYMENT_TIMELINE_HEADER_PROCESS_DATA");
     $title = str_replace('{ORDER_ID}', $order_id, $title);
     $this->addRequestLog("LOG_PM_INPUT", "Payment Module Logs", $title, prepareArrayDisplay($data));
     //=========================== logging request ========================
     switch ($status) {
         case "notify":
             $EventType = "BackgroundEvent";
             $result = modApiFunc("Checkout", "addOrderHistory", $order_id, $this->OrderHistoryMessageTag . "\n" . $this->getmicrotime() . "\n" . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_EVENT_DESCRIPTION') . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_MESSAGE_AZ_004') . $data["_POST"]["payment_status"] . "\n " . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_MESSAGE_AZ_005') . " \n " . print_r($data["_POST"], true));
             //next 2 steps : processing IPN "notify"
             $result = $this->processIPNnotify($data["_POST"], $order_id);
             break;
         case "return":
             $EventType = "ConfirmationSuccess";
             $result = modApiFunc("Checkout", "addOrderHistory", $order_id, $this->OrderHistoryMessageTag . "\n" . $this->getmicrotime() . "\n" . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_EVENT_DESCRIPTION') . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_MESSAGE_AZ_006'));
             break;
         case "cancel":
             $EventType = "ConfirmationFailure";
             $result = modApiFunc("Checkout", "UpdatePaymentStatusInDB", $order_id, 3, $this->OrderHistoryMessageTag . $this->getmicrotime() . "\n" . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_EVENT_DESCRIPTION') . $obj->getMessage('MODULE_PAYMENT_PAYPAL_PAYPAL_IPN_LOG_MESSAGE_AZ_007'));
             break;
         default:
             //: Report Error: e.g. write to order history
             $result = array("payment_status" => array());
             break;
     }
     return array("EventType" => $EventType, "statusChanged" => $result);
 }
Exemplo n.º 5
0
function prepareArrayDisplay($array, $title = 'Title', $first_cycle = true, $func = null, $max_level = 8)
{
    if ($max_level == 0) {
        return '';
    }
    $js = "<script>";
    $js .= " function prepareArrayDisplay_toggleBlock_{FUNC}(block_id) ";
    $js .= "{ var el = document.getElementById('list_'+block_id); ";
    $js .= "  if (el)";
    $js .= "  {";
    $js .= "    if (el.style.display == 'none')";
    $js .= "    {";
    $js .= "        el.style.display = '';";
    $js .= "    }";
    $js .= "    else";
    $js .= "    {";
    $js .= "        el.style.display = 'none';";
    $js .= "    }";
    $js .= "  }";
    $js .= "}";
    $js .= "</script>";
    $html = "<div style='font-family: Verdana; font-size: 8pt; text-align: left; color: black; line-height: 16px;'>";
    $tpl_array = "{TYPE} <A onclick=\"prepareArrayDisplay_toggleBlock_{FUNC}('{ID}',1)\" href='javascript: void(0);' style='text-decoration: none; font-weight: bold; font-family: Impact; color: green;'>&gt;&gt;&gt;</A><br><div id='list_{ID}' style='padding-left: 30px; display: {DISPLAY};'>{CONTENT}</div>";
    $tpl_key = "{KEY} => ";
    $tpl_value = "{TYPE} {VALUE}<br>";
    if ($func === null) {
        $func = md5(uniqid(rand(), true));
        $js = str_replace('{FUNC}', $func, $js);
    }
    if (is_object($array) or is_array($array) and !empty($array)) {
        if ($first_cycle) {
            $html = $js . $html;
            $html .= "<b>{$title}:</b> " . str_replace(array('{CONTENT}', '{TYPE}', '{ID}', '{DISPLAY}', '{FUNC}'), array(prepareArrayDisplay($array, '', false, $func, $max_level - 1), __formatType($array), md5(uniqid(rand(), true)), 'block', $func), $tpl_array);
            $html .= '<br>';
        } else {
            foreach ($array as $key => $item) {
                if (is_array($item) and !empty($item)) {
                    $html .= str_replace('{KEY}', __formatKey($key), $tpl_key);
                    $html .= str_replace(array('{CONTENT}', '{TYPE}', '{ID}', '{DISPLAY}', '{FUNC}'), array(prepareArrayDisplay($item, '', false, $func, $max_level - 1), __formatType($item), md5(uniqid(rand(), true)), 'none', $func), $tpl_array);
                } else {
                    if (is_object($item)) {
                        $html .= str_replace('{KEY}', __formatKey($key), $tpl_key);
                        if (isempty(get_object_vars($item))) {
                            $html .= str_replace(array('{VALUE}', '{TYPE}'), array(__formatValue(array(), $func), __formatType($item)), $tpl_value);
                        } else {
                            $html .= str_replace(array('{CONTENT}', '{TYPE}', '{ID}', '{DISPLAY}', '{FUNC}'), array(prepareArrayDisplay($item, '', false, $func, $max_level - 1), __formatType($item), md5(uniqid(rand(), true)), 'none', $func), $tpl_array);
                        }
                    } else {
                        $html .= str_replace('{KEY}', __formatKey($key), $tpl_key);
                        $html .= str_replace(array('{VALUE}', '{TYPE}'), array(__formatValue($item, $func), __formatType($item)), $tpl_value);
                    }
                }
            }
        }
        $html .= '</div>';
        return $html;
    } else {
        return "<b>{$title}:</b> " . str_replace(array('{VALUE}', '{TYPE}'), array(__formatValue($array), __formatType($array)), $tpl_value) . '<br>';
    }
}
 function split_cart($order_full_cart, $threshold)
 {
     $this->_reset_msg();
     $this->threshold = $threshold;
     $this->cart = $this->formatCart($order_full_cart);
     $this->_add_msg("Cart untouched:<br />" . prepareArrayDisplay($this->cart));
     // splitting is not needed
     if ($this->cart["total_weight"] <= $threshold) {
         $this->_add_msg("Splitting is not needed.<br />");
         return array(0 => $this->cart);
     }
     $n = 0;
     $this->parcel = array();
     // split large groups - groups, which' weight is larger than the threshold
     $this->_split_large_groups();
     // the better way
     // count minimum parcels number
     // loop groups
     // if there are empty parcels left,
     //     find the heaviest group, try to settle it inside, not splitting it
     // else
     //     find the group with heaviest items, try to settle it, splitting if needed
     //
     // if there are no empty parcels left, make a new parcel
     // and place the group there
     // but a simplified version is used now
     // we do not care about item weights or group weights
     // - just foreach() and go on
     foreach ($this->cart["products"] as $key => $value) {
         if (!$this->_settle_group_into_parcels($key)) {
             if (!$this->_settle_splitted_group_into_parcels($key)) {
                 $this->_add_msg("{$key} wants to be settled as the last new.<br />");
                 $this->_add_parcel($key, $value["qty"], -1);
             }
         }
     }
     $this->_add_msg("<br />Cart leftovers:<br />" . prepareArrayDisplay($this->cart));
     $this->parcel["total_weight"] = $this->parcel_weight;
     $this->parcel["subtotal"] = $this->parcel_subtotal;
     $this->_add_msg("<br />Parcels:<br />" . prepareArrayDisplay($this->parcel));
     $this->parcel["msg"] = $this->msg;
     return $this->parcel;
 }
 /**
  * Prepares and returns necessary data, passed to the payment gateway.
  *
  * @ not all data is defined
  */
 function getConfirmationData($orderId)
 {
     global $application;
     loadCoreFile('aal.class.php');
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setAction("UpdatePaymentStatus");
     $request->setKey("asc_oid", $orderId);
     $self_link = $request->getURL("", true);
     $currency_id = modApiFunc("Localization", "whichCurrencySendOrderToPaymentShippingGatewayIn", $orderId, $this->getUid());
     $currency = modApiFunc("Localization", "getCurrencyCodeById", $currency_id);
     $ocntr = modApiFunc("Location", "getCountryCode", modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_OWNER_COUNTRY));
     $bn_code = "PentasoftCorp_Cart_WPS_" . $ocntr;
     $orderInfo = modApiFunc("Checkout", "getOrderInfo", $orderId, $currency_id);
     $discount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "DiscountsSum", $currency_id));
     $amount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "Subtotal", $currency_id) - $discount);
     $moduleData = $this->getSettings();
     require_once 'libwebtopay/WebToPay.php';
     try {
         $buildRequest = WebToPay::buildRequest(array('projectid' => $moduleData['MODULE_METHOD_ID'], 'sign_password' => $moduleData['MODULE_METHOD_PASS'], 'orderid' => $orderInfo['ID'], 'amount' => intval(number_format($orderInfo['Total'], 2, '', '')), 'currency' => $currency, 'accepturl' => $self_link . "&status=return", 'cancelurl' => $self_link . "&status=cancel", 'callbackurl' => $self_link . "&status=notify", 'payment' => '', 'country' => 'LT', 'logo' => '', 'p_firstname' => $orderInfo['Billing']['attr']['Firstname']['value'], 'p_lastname' => $orderInfo['Billing']['attr']['Lastname']['value'], 'p_email' => $orderInfo['Billing']['attr']['Email']['value'], 'p_street' => $orderInfo['Billing']['attr']['Streetline1']['value'] . ' ' . $orderInfo['Billing']['attr']['Streetline2']['value'], 'p_city' => $orderInfo['Billing']['attr']['City']['value'], 'p_zip' => $orderInfo['Billing']['attr']['Postcode']['value'], 'test' => $moduleData['MODULE_MODE']));
     } catch (WebToPayException $e) {
         echo get_class($e) . ': ' . $e->getMessage();
     }
     $acceptURL = str_replace('&amp;', '&', $buildRequest['accepturl']);
     $cancelURL = str_replace('&amp;', '&', $buildRequest['cancelurl']);
     $callbackURL = str_replace('&amp;', '&', $buildRequest['callbackurl']);
     $confirmationData = array("FormAction" => WebToPay::PAY_URL, "FormMethod" => "POST", "DataFields" => array('projectid' => $buildRequest['projectid'], 'orderid' => $buildRequest['orderid'], 'amount' => $buildRequest['amount'], 'currency' => $buildRequest['currency'], 'lang' => $buildRequest['lang'], 'accepturl' => $buildRequest['accepturl'], 'cancelurl' => $buildRequest['cancelurl'], 'callbackurl' => $buildRequest['callbackurl'], 'payment' => $buildRequest['payment'], 'country' => $buildRequest['country'], 'p_firstname' => $buildRequest['p_firstname'], 'p_lastname' => $buildRequest['p_lastname'], 'p_email' => $buildRequest['p_email'], 'p_street' => $buildRequest['p_street'], 'p_city' => $buildRequest['p_city'], 'p_zip' => $buildRequest['p_zip'], 'test' => $buildRequest['test'], 'version' => $buildRequest['version'], 'sign' => $buildRequest['sign']));
     //=========================== logging request ========================
     $msgObj = $application->getInstance("MessageResources", "payment-module-paypal-messages", "AdminZone");
     $title = $msgObj->getMessage("MODULE_PAYMENT_TIMELINE_HEADER_CONFIRMATION_DATA");
     $title = str_replace('{ORDER_ID}', $orderId, $title);
     $this->addRequestLog("LOG_PM_INPUT", "Payment Module Logs", $title, prepareArrayDisplay($confirmationData));
     //=========================== logging request ========================
     return $confirmationData;
 }
Exemplo n.º 8
0
 function onApplicationStarted()
 {
     global $zone;
     if ($zone == 'AdminZone') {
         if (modApiFunc('Settings', 'getParamValue', 'TIMELINE', 'LOG_BACKEND_ACCESS') === 'NO') {
             return;
         }
         $type = getMsg('TL', 'TL_AZ_ACCESS');
     } else {
         if (modApiFunc('Settings', 'getParamValue', 'TIMELINE', 'LOG_STOREFRONT_ACCESS') === 'NO') {
             return;
         }
         $type = getMsg('TL', 'TL_CZ_ACCESS');
     }
     $header = str_replace(array('{IP}', '{URL}'), array(getVisitorIP(), _ml_htmlentities(str_replace("&", "\t&", getCurrentURL()))), getMsg('TL', 'TL_VISITOR_HEADER'));
     $body = prepareArrayDisplay($_GET, '$_GET');
     $body .= prepareArrayDisplay($_POST, '$_POST');
     $body .= prepareArrayDisplay($_SESSION, '$_SESSION');
     $this->addLog($type, $header, $body);
 }