public function process()
 {
     $body = Tools::file_get_contents('php://input');
     $data = trim($body);
     $result = OpenPayU_Order::consumeNotification($data);
     $response = $result->getResponse();
     SimplePayuLogger::addLog('notification', __FUNCTION__, print_r($result, true), $response->order->orderId, 'Incoming notification: ');
     if (isset($response->order->orderId)) {
         $payu = new PayU();
         $payu->payu_order_id = $response->order->orderId;
         $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
         $id_order = (int) $order_payment['id_order'];
         // if order not validated yet
         if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
             $id_order = $this->createOrder($order_payment, $payu, $response);
         }
         if (!empty($id_order)) {
             $payu->id_order = $id_order;
             $payu->updateOrderData($response);
         }
         if ($this->checkIfPaymentIdIsPresent($response) && $response->order->status == PayU::ORDER_V2_COMPLETED) {
             $this->addPaymentIdToOrder($response, $payu, $id_order);
         }
         //the response should be status 200
         header("HTTP/1.1 200 OK");
         exit;
     }
 }
Example #2
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;
 }
Example #3
0
 public function initContent()
 {
     $payu = new PayU();
     $id_cart = Tools::getValue('id_cart');
     $id_payu_session = $this->context->cookie->__get('payu_order_id');
     if (Tools::getValue('error')) {
         Tools::redirect('order.php?error=' . Tools::getValue('error'), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
     }
     $payu->id_cart = $id_cart;
     $payu->payu_order_id = $id_payu_session;
     $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
     $id_order = (int) $order_payment['id_order'];
     $payu->id_cart = (int) $order_payment['id_cart'];
     // if order not validated yet
     $cart_id = $payu->id_cart;
     if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
         $cart = new Cart($payu->id_cart);
         $cart_id = $cart->id;
         $payu->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $payu->displayName, 'PayU cart ID: ' . $cart_id . ', sessionId: ' . $payu->payu_order_id, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null);
         $payu->id_order = $payu->current_order = $payu->{'currentOrder'};
         $payu->updateOrderPaymentStatusBySessionId(PayU::PAYMENT_STATUS_INIT);
     }
     $id_order = $payu->getOrderIdBySessionId($id_payu_session);
     if (!empty($id_order)) {
         $payu->id_order = $id_order;
         $payu->updateOrderData();
     }
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart_id, __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
 }
Example #4
0
 * 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;
            }
        }
    }
}
ob_end_flush();
exit;
Example #5
0
 * http://openpayu.com
 * http://twitter.com/openpayu
 *
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../../../init.php';
include dirname(__FILE__) . '/../../../header.php';
$payu = new PayU();
$id_cart = Tools::getValue('id_cart');
global $cookie;
$id_payu_session = $cookie->__get('payu_order_id');
if (Tools::getValue('error')) {
    Tools::redirect('order.php?error=' . Tools::getValue('error'), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
}
$payu->id_cart = $id_cart;
$payu->payu_order_id = $id_payu_session;
$order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
$id_order = (int) $order_payment['id_order'];
/* if order not validated yet */
if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
    $cart = new Cart($payu->id_cart);
    $payu->validateOrder($cart->id, Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), 'PayU cart ID: ' . $cart->id . ', sessionId: ' . $payu->payu_order_id, null, null, false, $cart->secure_key);
    $payu->id_order = $payu->current_order = $payu->currentOrder;
    $payu->updateOrderPaymentStatusBySessionId(PayU::PAYMENT_STATUS_INIT);
}
$id_order = $payu->getOrderIdBySessionId($id_payu_session);
if (!empty($id_order)) {
    $payu->id_order = $id_order;
    $payu->updateOrderData();
}
Tools::redirect('history.php', __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');