Exemplo n.º 1
0
 public function process()
 {
     if (Tools::getIsset('DOCUMENT')) {
         $data = Tools::getValue('DOCUMENT');
         $result = OpenPayU_Order::consumeMessage($data, false);
         if ($result->getMessage() == 'ShippingCostRetrieveRequest') {
             $id_payu_session = $result->getSessionId();
             $iso_country_code = $result->getCountryCode();
             $payu = new PayU();
             $order_payment = $payu->getOrderPaymentBySessionId($id_payu_session);
             $id_cart = $order_payment['id_cart'];
             if (!empty($id_cart)) {
                 $payu->id_cart = $id_cart;
                 $payu->payu_order_id = $id_payu_session;
                 $payu->id_request = $result->getReqId();
                 $xml = $payu->shippingCostRetrieveRequest($iso_country_code);
                 if (!empty($xml)) {
                     header('Content-Type:text/xml');
                     echo $xml;
                 }
             }
         }
     }
     exit;
 }
Exemplo n.º 2
0
 public function retrieveOrder($document)
 {
     $result = \OpenPayU_Order::consumeMessage($document);
     if ($result->getMessage() == 'OrderNotifyRequest') {
         $result = \OpenPayU_Order::retrieve($result->getSessionId());
         return $result->getResponse();
     }
     return null;
 }
Exemplo n.º 3
0
 public function shipping()
 {
     $this->loadLibConfig();
     if ($this->request->post['DOCUMENT']) {
         $xml = htmlspecialchars_decode($this->request->post['DOCUMENT']);
         $result = OpenPayU_Order::consumeMessage($xml);
         $countrycode = $result->getCountryCode();
         $reqId = $result->getReqId();
         $sessionId = $result->getSessionId();
         $order_id = $this->model_payment_payu->getOrderIdBySessionId(substr($sessionId, 0, 32));
         $this->load->model('localisation/country');
         $country_list = $this->model_localisation_country->getCountries();
         $country_id = 0;
         foreach ($country_list as $country) {
             if ($country['iso_code_2'] == $countrycode) {
                 $country_id = $country['country_id'];
             }
         }
         $this->load->model('checkout/order');
         $order_info = $this->model_checkout_order->getOrder($order_id);
         $shippingCostList = array();
         $this->tax->setShippingAddress($country_id, 0);
         $this->tax->setPaymentAddress($country_id, 0);
         $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
         foreach ($this->getShippings($order_id, $country_id) as $onemethod) {
             $shipmethod = array('Type' => $onemethod['title'], 'CountryCode' => $countrycode, 'Price' => array('Gross' => str_ireplace('.', '', $this->currency->format($this->tax->calculate($onemethod['cost'], $onemethod['tax_class_id']), $order_info['currency_code'], false, false)), 'Net' => str_ireplace('.', '', $this->currency->format($onemethod['cost'], $order_info['currency_code'], false, false)), 'Tax' => str_ireplace('.', '', $this->currency->format($this->tax->calculate($onemethod['cost'], $onemethod['tax_class_id']) - $onemethod['cost'], $order_info['currency_code'], false, false)), 'CurrencyCode' => $order_info['currency_code']));
             if (false) {
                 $shipmethod[]['State'] = $order_info['shipping_zone'];
                 $shipmethod[]['City'] = $order_info['shipping_city'];
             }
             $shippingCostList[]['ShippingCost'] = $shipmethod;
         }
         $shippingCost = array('CountryCode' => $countrycode, 'ShipToOtherCountry' => 'true', 'ShippingCostList' => $shippingCostList);
         $xml = OpenPayU::buildShippingCostRetrieveResponse($shippingCost, $reqId, $countrycode);
         if (!$result->getSuccess()) {
             $this->logger->write($result->getError() . ' [request: ' . serialize($result->getRequest()) . ', response: ' . serialize(OpenPayU::parseOpenPayUDocument($xml)) . ']');
         }
         header("Content-type: text/xml");
         echo $xml;
     }
 }
Exemplo n.º 4
0
 *
 * @copyright  Copyright (c) 2013 PayU
 * @license    http://opensource.org/licenses/LGPL-3.0  Open Software License (LGPL 3.0)
 *
 * http://www.payu.com
 * http://openpayu.com
 * http://twitter.com/openpayu
 *
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../../../init.php';
include dirname(__FILE__) . '/../../../header.php';
ob_clean();
if (Tools::getIsset('DOCUMENT')) {
    $data = Tools::getValue('DOCUMENT');
    $result = OpenPayU_Order::consumeMessage($data, false);
    if ($result->getMessage() == 'ShippingCostRetrieveRequest') {
        $id_payu_session = $result->getSessionId();
        $iso_country_code = $result->getCountryCode();
        $payu = new PayU();
        $order_payment = $payu->getOrderPaymentBySessionId($id_payu_session);
        $id_cart = $order_payment['id_cart'];
        if (!empty($id_cart)) {
            $payu->id_cart = $id_cart;
            $payu->payu_order_id = $id_payu_session;
            $payu->id_request = $result->getReqId();
            $xml = $payu->shippingCostRetrieveRequest($iso_country_code);
            if (!empty($xml)) {
                header('Content-Type:text/xml');
                echo $xml;
            }