public function initContent() { if ($id_cart = Tools::getValue('id_cart')) { $myCart = new Cart($id_cart); if (!Validate::isLoadedObject($myCart)) { $myCart = $this->context->cart; } } else { $myCart = $this->context->cart; } $total_to_pay = $myCart->getOrderTotal(true, Cart::BOTH); $currency_rub = new Currency(Currency::getIdByIsoCode('RUB')); if ($myCart->id_currency != $currency_rub->id) { $currency = new Currency($myCart->id_currency); $total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate; } $total_to_pay = number_format($total_to_pay, 2, '.', ''); if ($postvalidate = Configuration::get('robokassa_postvalidate')) { $order_number = $myCart->id; } else { if (!($order_number = Order::getOrderByCartId($myCart->id))) { $this->module->validateOrder((int) $myCart->id, Configuration::get('PL_OS_WAITPAYMENT'), $myCart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $myCart->secure_key); $order_number = $this->module->currentOrder; } } $customer = new Customer($myCart->id_customer); $signature = md5(Configuration::get('robokassa_login') . ':' . $total_to_pay . ':' . $order_number . ':' . Configuration::get('robokassa_password1')); $this->context->smarty->assign(array('robokassa_login' => Configuration::get('robokassa_login'), 'robokassa_demo' => Configuration::get('robokassa_demo'), 'signature' => strtoupper($signature), 'email' => $customer->email, 'postvalidate' => $postvalidate, 'order_number' => $order_number, 'total_to_pay' => $total_to_pay, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/')); return $this->setTemplate('redirect.tpl'); }
public function initContent() { parent::initContent(); $ordernumber = Tools::getValue('InvId'); $this->context->smarty->assign('ordernumber', $ordernumber); if (Configuration::get('robokassa_postvalidate')) { if (!$ordernumber) { robokassa::validateAnsver($this->module->l('Cart number is not set')); } $cart = new Cart((int) $ordernumber); if (!Validate::isLoadedObject($cart)) { robokassa::validateAnsver($this->module->l('Cart does not exist')); } if (!($ordernumber = Order::getOrderByCartId($cart->id))) { $this->setTemplate('waitingPayment.tpl'); } } if (!$ordernumber) { robokassa::validateAnsver($this->module->l('Order number is not set')); } $order = new Order((int) $ordernumber); if (!Validate::isLoadedObject($order)) { robokassa::validateAnsver($this->module->l('Order does not exist')); } $customer = new Customer((int) $order->id_customer); if ($customer->id != $this->context->cookie->id_customer) { robokassa::validateAnsver($this->module->l('You are not logged in')); } if ($order->hasBeenPaid()) { Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $order->id_cart . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $order->id); } else { $this->setTemplate('waitingPayment.tpl'); } }
public function preProcess() { parent::preProcess(); $this->id_cart = (int) Tools::getValue('id_cart', 0); /* check if the cart has been made by a Guest customer, for redirect link */ if (Cart::isGuestCartByCartId($this->id_cart)) { $redirectLink = 'guest-tracking.php'; } else { $redirectLink = 'history.php'; } $this->id_module = (int) Tools::getValue('id_module', 0); $this->id_order = Order::getOrderByCartId((int) $this->id_cart); $this->secure_key = Tools::getValue('key', false); if (!$this->id_order or !$this->id_module or !$this->secure_key or empty($this->secure_key)) { Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '?slowvalidation' : '')); } $order = new Order((int) $this->id_order); if (!Validate::isLoadedObject($order) or $order->id_customer != self::$cookie->id_customer or $this->secure_key != $order->secure_key) { Tools::redirect($redirectLink); } $module = Module::getInstanceById((int) $this->id_module); if ($order->payment != $module->displayName) { Tools::redirect($redirectLink); } }
/** * Initialize order confirmation controller * @see FrontController::init() */ public function init() { parent::init(); $this->id_cart = (int) Tools::getValue('id_cart', 0); $is_guest = false; /* check if the cart has been made by a Guest customer, for redirect link */ if (Cart::isGuestCartByCartId($this->id_cart)) { $is_guest = true; $redirectLink = 'index.php?controller=guest-tracking'; } else { $redirectLink = 'index.php?controller=history'; } $this->id_module = (int) Tools::getValue('id_module', 0); $this->id_order = Order::getOrderByCartId((int) $this->id_cart); $this->secure_key = Tools::getValue('key', false); $order = new Order((int) $this->id_order); if ($is_guest) { $customer = new Customer((int) $order->id_customer); $redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email); } if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) { Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : '')); } $this->reference = $order->reference; if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) { Tools::redirect($redirectLink); } $module = Module::getInstanceById((int) $this->id_module); if ($order->payment != $module->displayName) { Tools::redirect($redirectLink); } }
public function updateStatus(&$resp) { $this->log_on = Configuration::get('YA_P2P_LOGGING_ON'); if ($resp->status == 'success') { $cart = $this->context->cart; if ($cart->id > 0) { if ($cart->orderExists()) { $ord = new Order((int) Order::getOrderByCartId($cart->id)); $id_order = $ord->id; } else { $ord = $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName . " Банковская карта", null, array(), null, false, $cart->secure_key); $id_order = $this->module->currentOrder; } if ($ord) { $history = new OrderHistory(); $history->id_order = $id_order; $history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), $id_order); $history->addWithemail(true); } } if ($this->log_on) { $this->module->logSave('payment_card: #' . $this->module->currentOrder . ' ' . $this->module->l('Order success')); } Tools::redirect($this->context->link->getPageLink('order-confirmation') . '&id_cart=' . $this->context->cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $this->context->cart->secure_key); } }
public function initContent() { $this->display_column_left = false; $this->display_column_right = false; parent::initContent(); global $smarty; if (isset($_GET['order_id'])) { $cart = Cart::getCartByOrderId($_GET['order_id']); if ($cart == null) { die; } } else { global $cart; } $address = new Address((int) $cart->id_address_invoice); $customer = new Customer((int) $cart->id_customer); $amount = $cart->getOrderTotal(true, Cart::BOTH); $przelewy24 = new Przelewy24(); $currencies = $przelewy24->getCurrency(intval($cart->id_currency)); $currency = $currencies[0]; if (isset($currency['decimals']) && $currency['decimals'] == '0') { if (Configuration::get('PS_PRICE_ROUND_MODE') != null) { switch (Configuration::get('PS_PRICE_ROUND_MODE')) { case 0: $amount = ceil($amount); break; case 1: $amount = floor($amount); break; case 2: $amount = round($amount); break; } } } $amount = number_format($amount, 2, '.', '') * 100; $s_sid = md5(time()); Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'przelewy24_amount` ' . '(`s_sid`,`i_id_order`,`i_amount`) ' . 'VALUES("' . $s_sid . '",' . $cart->id . ',' . $amount . ')'); $s_lang = new Country((int) $address->id_country); $order = Order::getOrderByCartId($cart->id); if ($order == null) { $s_descr = ''; $validationRequired = true; } else { $s_descr = 'Zamówienie: ' . $order; $validationRequired = false; } $url = 'secure.przelewy24.pl'; if (Configuration::get('P24_TEST_MODE') == 1) { if (Configuration::get('P24_TEST_MODE_TRANSACTION') == 1) { $url = 'sandbox.przelewy24.pl'; } else { $url = 'sandbox.przelewy24.pl'; $s_descr = 'TEST_ERR102'; } } $smarty->assign(array('productsNumber' => $cart->nbProducts(), 'ps_version' => _PS_VERSION_, 'p24_url' => $url, 'p24_session_id' => $cart->id . '|' . $s_sid, 'p24_id_sprzedawcy' => Configuration::get('P24_ID_SPRZEDAWCY'), 'p24_kwota' => $amount, 'p24_opis' => $s_descr, 'p24_klient' => $customer->firstname . ' ' . $customer->lastname, 'p24_adres' => $address->address1 . " " . $address->address2, 'p24_kod' => $address->postcode, 'p24_miasto' => $address->city, 'p24_language' => strtolower($s_lang->iso_code), 'p24_kraj' => $s_lang->iso_code, 'p24_email' => $customer->email, 'p24_metoda' => Tools::getValue('payment_method'), 'p24_return_url_ok' => $this->context->link->getModuleLink('przelewy24', 'paymentSuccessful'), 'p24_return_url_error' => $this->context->link->getModuleLink('przelewy24', 'paymentFailed'), 'p24_validationRequired' => $validationRequired)); $this->setTemplate('paymentConfirmation.tpl'); }
public function validateOrderPay($id_cart, $id_order_state, $amount_paid, $extraCosts, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) { $statusPending = Configuration::get('PAYNL_WAIT'); $statusPaid = Configuration::get('PAYNL_SUCCESS'); // Als er nog geen order van dit cartid is, de order valideren. $orderId = Order::getOrderByCartId($id_cart); if ($orderId == false) { if ($id_order_state == $statusPaid) { if ($extraCosts != 0) { $id_order_state_tmp = $statusPending; } else { $id_order_state_tmp = $statusPaid; } } else { $id_order_state_tmp = $id_order_state; } $result = parent::validateOrder($id_cart, $id_order_state_tmp, $amount_paid, $payment_method, $message, $extra_vars, $currency_special, $dont_touch_amount, $secure_key, $shop); $orderId = $this->currentOrder; if ($extraCosts == 0 && $id_order_state_tmp == $statusPaid) { //Als er geen extra kosten zijn, en de order staat op betaald zijn we klaar return $result; } } if ($orderId && $id_order_state == $statusPaid) { $order = new Order($orderId); $shippingCost = $order->total_shipping; $newShippingCosts = $shippingCost + $extraCosts; $extraCostsExcl = round($extraCosts / (1 + 21 / 100), 2); if ($extraCosts != 0) { //als de order extra kosten heeft, moeten deze worden toegevoegd. $order->total_shipping = $newShippingCosts; $order->total_shipping_tax_excl = $order->total_shipping_tax_excl + $extraCostsExcl; $order->total_shipping_tax_incl = $newShippingCosts; $order->total_paid_tax_excl = $order->total_paid_tax_excl + $extraCostsExcl; $order->total_paid_tax_incl = $order->total_paid_real = $order->total_paid = $order->total_paid + $extraCosts; } $result = $order->addOrderPayment($amount_paid, $payment_method, $extra_vars['transaction_id']); if (number_format($order->total_paid_tax_incl, 2) !== number_format($amount_paid, 2)) { $id_order_state = Configuration::get('PS_OS_ERROR'); } //paymentid ophalen $orderPayment = OrderPayment::getByOrderId($order->id); $history = new OrderHistory(); $history->id_order = (int) $order->id; $history->changeIdOrderState((int) $id_order_state, $order, $orderPayment); $res = Db::getInstance()->getRow(' SELECT `invoice_number`, `invoice_date`, `delivery_number`, `delivery_date` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_order` = ' . (int) $order->id); $order->invoice_date = $res['invoice_date']; $order->invoice_number = $res['invoice_number']; $order->delivery_date = $res['delivery_date']; $order->delivery_number = $res['delivery_number']; $order->update(); $history->addWithemail(); } return $result; }
public function initContent() { parent::initContent(); $log_on = Configuration::get('YA_ORG_LOGGING_ON'); if (Tools::getValue('label')) { $data = explode('_', Tools::getValue('label')); } else { $data = explode('_', Tools::getValue('customerNumber')); } if (!empty($data) && isset($data[1])) { $ordernumber = $data['1']; $this->context->smarty->assign('ordernumber', $ordernumber); $this->context->smarty->assign('time', date('Y-m-d H:i:s ')); if (!$ordernumber) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified')); } $this->setTemplate('error.tpl'); } else { $cart = new Cart((int) $ordernumber); $qty = $cart->nbProducts(); $this->context->smarty->assign('nbProducts', $qty); if (!Validate::isLoadedObject($cart) || $qty < 1) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Shopping cart does not exist')); } $this->setTemplate('error.tpl'); } else { $ordernumber = (int) $cart->id; if (!$ordernumber) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Order number is not specified')); } $this->setTemplate('error.tpl'); } else { $order = new Order((int) Order::getOrderByCartId($cart->id)); $customer = new Customer((int) $order->id_customer); if ($order->hasBeenPaid()) { if ($log_on) { $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order paid')); } Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $order->id_cart . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $order->id); } else { if ($log_on) { $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order wait payment')); } $this->setTemplate('waitingPayment.tpl'); } } } } } else { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified')); } $this->setTemplate('error.tpl'); } }
public function renderView() { if (!($cart = $this->loadObject(true))) { return; } $customer = new Customer($cart->id_customer); $this->context->cart = $cart; $this->context->customer = $customer; $products = $cart->getProducts(); $customized_datas = Product::getAllCustomizedDatas((int) $cart->id); Product::addCustomizationPrice($products, $customized_datas); $summary = $cart->getSummaryDetails(); $currency = new Currency($cart->id_currency); /* Display order information */ $id_order = (int) Order::getOrderByCartId($cart->id); $order = new Order($id_order); if ($order->getTaxCalculationMethod() == PS_TAX_EXC) { $total_products = $summary['total_products']; $total_discounts = $summary['total_discounts_tax_exc']; $total_wrapping = $summary['total_wrapping_tax_exc']; $total_price = $summary['total_price_without_tax']; $total_shipping = $summary['total_shipping_tax_exc']; } else { $total_products = $summary['total_products_wt']; $total_discounts = $summary['total_discounts']; $total_wrapping = $summary['total_wrapping']; $total_price = $summary['total_price']; $total_shipping = $summary['total_shipping']; } foreach ($products as $k => &$product) { if ($order->getTaxCalculationMethod() == PS_TAX_EXC) { $product['product_price'] = $product['price']; $product['product_total'] = $product['total']; } else { $product['product_price'] = $product['price_wt']; $product['product_total'] = $product['total_wt']; } $image = array(); if (isset($product['id_product_attribute']) && (int) $product['id_product_attribute']) { $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['id_product_attribute']); } if (!isset($image['id_image'])) { $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['id_product'] . ' AND cover = 1'); } $product_obj = new Product($product['id_product']); $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int) $order->id_shop); $image_product = new Image($image['id_image']); $product['image'] = isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $image_product->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--'; } $this->tpl_view_vars = array('products' => $products, 'discounts' => $cart->getCartRules(), 'order' => $order, 'cart' => $cart, 'currency' => $currency, 'customer' => $customer, 'customer_stats' => $customer->getStats(), 'total_products' => $total_products, 'total_discounts' => $total_discounts, 'total_wrapping' => $total_wrapping, 'total_price' => $total_price, 'total_shipping' => $total_shipping, 'customized_datas' => $customized_datas); return parent::renderView(); }
public function initContent() { parent::initContent(); if (Tools::getIsset('collection_id') && Tools::getValue('collection_id') != 'null') { // payment variables $payment_statuses = array(); $payment_ids = array(); $payment_types = array(); $payment_method_ids = array(); $card_holder_names = array(); $four_digits_arr = array(); $statement_descriptors = array(); $status_details = array(); $transaction_amounts = 0; $collection_ids = split(',', Tools::getValue('collection_id')); foreach ($collection_ids as $collection_id) { $mercadopago = $this->module; $mercadopago_sdk = $mercadopago->mercadopago; $result = $mercadopago_sdk->getPayment($collection_id); $payment_info = $result['response']['collection']; $id_cart = $payment_info['external_reference']; $cart = new Cart($id_cart); $payment_statuses[] = $payment_info['status']; $payment_ids[] = $payment_info['id']; $payment_types[] = $payment_info['payment_type']; $payment_method_ids[] = $payment_info['payment_method_id']; $transaction_amounts += $payment_info['transaction_amount']; if ($payment_info['payment_type'] == 'credit_card') { $card_holder_names[] = $payment_info['cardholder']['name']; $four_digits_arr[] = '**** **** **** ' . $payment_info['last_four_digits']; $statement_descriptors[] = $payment_info['statement_descriptor']; $status_details[] = $payment_info['status_detail']; } } if (Validate::isLoadedObject($cart)) { $order_id = Order::getOrderByCartId($cart->id); $order = new Order($order_id); $uri = __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $order->id_cart . '&id_module=' . $mercadopago->id . '&id_order=' . $order->id . '&key=' . $order->secure_key; $uri .= '&payment_status=' . $payment_statuses[0]; $uri .= '&payment_id=' . join(" / ", $payment_ids); $uri .= '&payment_type=' . join(" / ", $payment_types); $uri .= '&payment_method_id=' . join(" / ", $payment_method_ids); $uri .= '&amount=' . $transaction_amounts; if ($payment_info['payment_type'] == 'credit_card') { $uri .= '&card_holder_name=' . join(" / ", $card_holder_names); $uri .= '&four_digits=' . join(" / ", $four_digits_arr); $uri .= '&statement_descriptor=' . $statement_descriptors[0]; $uri .= '&status_detail=' . $status_details[0]; } Tools::redirectLink($uri); } } else { error_log('External reference is not set. Order placement has failed.'); } }
/** * @see FrontController::postProcess() */ public function postProcess() { // Log requests from Privat API side in Debug mode. if (Configuration::get('PRIVAT24_DEBUG_MODE')) { $logger = new FileLogger(); $logger->setFilename(_PS_ROOT_DIR_ . '/log/' . $this->module->name . '_' . date('Ymd_His') . '_response.log'); $logger->logError($_POST); } $payment = array(); parse_str(Tools::getValue('payment'), $payment); $hash = sha1(md5(Tools::getValue('payment') . $this->module->merchant_password)); if ($payment && $hash === Tools::getValue('signature')) { if ($payment['state'] == 'ok') { $state = Configuration::get('PRIVAT24_WAITINGPAYMENT_OS'); $cart_id = (int) $payment['order']; $order = new Order(Order::getOrderByCartId($cart_id)); if (!Validate::isLoadedObject($order)) { PrestaShopLogger::addLog('Privat24: cannot get order by cart id ' . $cart_id, 3); die; } if ($order->getCurrentState() != $state) { PrestaShopLogger::addLog(sprintf('Privat24: order id %s current state %s !== expected state %s', $order->id, $order->getCurrentState(), $state), 3); die; } // Check paid currency and paid amount. $id_currency = Currency::getIdByIsoCode($payment['ccy']); if (!$id_currency) { PrestaShopLogger::addLog(sprintf('Privat24: order id %s cannot get currency id by iso code: %s', $order->id, $payment['ccy']), 3); die; } if ($order->id_currency != $id_currency) { PrestaShopLogger::addLog(sprintf('Privat 24: order id %s, order currency id %s does not match with %s', $order->id, $order->id_currency, $id_currency), 3); die; } if ((double) $order->total_paid != (double) $payment['amt']) { PrestaShopLogger::addLog(sprintf('Privat 24: order id %s order total paid %s does not match %s', $order->id, $order->total_paid, $payment['amt']), 3); die; } $order_history = new OrderHistory(); $order_history->id_order = $order->id; $order_history->changeIdOrderState(_PS_OS_PAYMENT_, $order->id); $order_history->addWithemail(); $this->setPaymentTransaction($order, $payment); $this->module->paymentNotify($order, $payment); PrestaShopLogger::addLog(sprintf('Privat24 payment accepted: order id: %s, amount: %s, ref: %s', $order->id, $payment['amt'], $payment['ref']), 1); } else { PrestaShopLogger::addLog(sprintf('Privat24 payment failed: state: %s, order: %s, ref: %s', $payment['state'], $payment['order'], $payment['ref']), 3, null, null, null, true); } } else { PrestaShopLogger::addLog('Privat24: Payment callback bad signature.', 3, null, null, null, true); } die; }
public function initContent() { parent::initContent(); // Init smarty content and set template to display $order = new Order(Order::getOrderByCartId(Tools::getValue('id_cart'))); if ($order->id_customer == Tools::getValue('id_customer')) { $this->context->smarty->assign(array('order' => $order, 'state' => new OrderState($order->current_state, $this->context->language->id))); $this->setTemplate('confirmation.tpl'); } else { $this->setTemplate('error.tpl'); } }
/** * Preparing hidden form with payment data before sending it to Dotpay */ public function initContent() { parent::initContent(); $this->display_column_left = false; $this->display_header = false; $this->display_footer = false; $cartId = 0; if (Tools::getValue('order_id') == false) { $cartId = $this->context->cart->id; $exAmount = $this->api->getExtrachargeAmount(true); if ($exAmount > 0 && !$this->isExVPinCart()) { $productId = $this->config->getDotpayExchVPid(); if ($productId != 0) { $product = new Product($productId, true); $product->price = $exAmount; $product->save(); $product->flushPriceCache(); $this->context->cart->updateQty(1, $product->id); $this->context->cart->update(); $this->context->cart->getPackageList(true); } } $discAmount = $this->api->getDiscountAmount(); if ($discAmount > 0) { $discount = new CartRule($this->config->getDotpayDiscountId()); $discount->reduction_amount = $this->api->getDiscountAmount(); $discount->reduction_currency = $this->context->cart->id_currency; $discount->reduction_tax = 1; $discount->update(); $this->context->cart->addCartRule($discount->id); $this->context->cart->update(); $this->context->cart->getPackageList(true); } $result = $this->module->validateOrder($this->context->cart->id, (int) $this->config->getDotpayNewStatusId(), $this->getDotAmount(), $this->module->displayName, NULL, array(), NULL, false, $this->customer->secure_key); } else { $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id')); $this->initPersonalData(); $cartId = $this->context->cart->id; } $this->api->onPrepareAction(Tools::getValue('dotpay_type'), array('order' => Order::getOrderByCartId($cartId), 'customer' => $this->context->customer->id)); $sa = new DotpaySellerApi($this->config->getDotpaySellerApiUrl()); if ($this->config->isDotpayDispInstruction() && $this->config->isApiConfigOk() && $this->api->isChannelInGroup(Tools::getValue('channel'), array(DotpayApi::cashGroup, DotpayApi::transfersGroup)) && $sa->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion())) { $this->context->cookie->dotpay_channel = Tools::getValue('channel'); Tools::redirect($this->context->link->getModuleLink($this->module->name, 'confirm', array('order_id' => Order::getOrderByCartId($cartId)))); die; } $this->context->smarty->assign(array('hiddenForm' => $this->api->getHiddenForm())); $cookie = new Cookie('lastOrder'); $cookie->orderId = Order::getOrderByCartId($cartId); $cookie->write(); $this->setTemplate("preparing.tpl"); }
public function postProcess() { $cartId = Tools::getValue('id_cart', false); if (!$cartId) { Tools::redirect('index.php?controller=order-confirmation'); } $cart = new Cart((int) $cartId); if (!$cart->orderExists()) { $this->module->validateOrder($cart->id, Configuration::get('PS_OS_CANCELED'), $cart->getOrderTotal(), $this->module->displayName, 'Order cancelled by Aplazame cancel_url', null, null, false, Tools::getValue('key', false)); } $orderId = Order::getOrderByCartId($cart->id); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $orderId . '&key=' . $cart->secure_key); }
function getCartOrder() { global $cart; $id_order = Order::getOrderByCartId((int) $cart->id); if (!$id_order) { return false; } $cartOrder = new Order((int) $id_order); if (!Validate::isLoadedObject($cartOrder)) { return false; } return $cartOrder; }
public function initContent() { global $smarty, $cart; $this->display_column_left = false; $this->display_column_right = false; parent::initContent(); if (!empty($_POST)) { $b_is_SSL = function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec') && function_exists('curl_close'); $p24_session_id = $_POST["p24_session_id"]; $p24_order_id = $_POST["p24_order_id"]; $p24_id_sprzedawcy = Configuration::get('P24_ID_SPRZEDAWCY'); //TWÓJ ID_SPRZEDAWCY; $sa_sid = explode('|', $_POST["p24_session_id"]); $sa_sid = preg_replace('/[^a-z0-9]/i', '', $sa_sid[1]); $o_order = Db::getInstance()->getRow('SELECT `i_id_order`,`i_amount` FROM `' . _DB_PREFIX_ . 'przelewy24_amount` WHERE `s_sid`="' . $sa_sid . '"'); $p24_kwota = (int) $o_order['i_amount']; // WYNIK POBRANY Z TWOJEJ BAZY (w groszach) $i_id_order = $o_order['i_id_order']; $WYNIK = false; $url = 'secure.przelewy24.pl'; if (Configuration::get('P24_TEST_MODE') == 1) { $url = 'sandbox.przelewy24.pl'; } if ($b_is_SSL) { $WYNIK = p24_weryfikujSSL($p24_id_sprzedawcy, $p24_session_id, $p24_order_id, $p24_kwota, $url); } else { $WYNIK = p24_weryfikujNoSSL($p24_id_sprzedawcy, $p24_session_id, $p24_order_id, $p24_kwota, $url); } $o_przelewy24 = new Przelewy24(); $opis = "przelewy24.pl"; $cart = new Cart($i_id_order); $secure_key = $cart->secure_key; if ($WYNIK[0] == 'TRUE') { $order_id = Order::getOrderByCartId(intval($i_id_order)); $order = new Order($order_id); $history = new OrderHistory(); $history->id_order = intval($order_id); $order_state = Configuration::get('P24_ORDER_STATE_2'); $history->changeIdOrderState($order_state, intval($order_id)); $history->addWithemail(true); $payments = $order->getOrderPaymentCollection(); if (count($payments) > 0) { $payments[0]->transaction_id = $p24_order_id; $payments[0]->update(); } } $smarty->assign('p24_status', 'success'); } $this->setTemplate('paymentSuccessful.tpl'); }
/** * Assign template vars related to page content. * * @see FrontController::initContent() */ public function initContent() { if (Configuration::isCatalogMode()) { Tools::redirect('index.php'); } parent::initContent(); $order = new Order(Order::getOrderByCartId((int) $this->id_cart)); $presentedOrder = $this->order_presenter->present($order); $register_form = $this->makeCustomerForm()->setGuestAllowed(false)->fillWith(Tools::getAllValues()); $this->context->smarty->assign(array('HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order), 'order' => $presentedOrder, 'register_form' => $register_form)); if ($this->context->customer->is_guest) { /* If guest we clear the cookie for security reason */ $this->context->customer->mylogout(); } $this->setTemplate('checkout/order-confirmation'); }
public function initContent() { parent::initContent(); // Get class instance $su = new Sofortueberweisung(); // Get cartId from $_GET $id_cart = (int) Tools::getValue('cartid'); if ($id_cart <= 0) { // Display information how to set the cartid $this->setTemplate('tpl-frontend-success-error.tpl'); } else { // Get orderId from cartId $id_order = Order::getOrderByCartId($id_cart); $order = new Order($id_order); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $id_cart . '&id_module=' . $su->id . '&id_order=' . $order->id . '&key=' . $order->secure_key); } }
/** * Initialize order confirmation controller * @see FrontController::init() */ public function init() { parent::init(); if (isset($this->context->cookie->{'url_confirmation'})) { unset($this->context->cookie->{'url_confirmation'}); } $this->id_cart = (int) Tools::getValue('id_cart', 0); $is_guest = false; /* check if the cart has been made by a Guest customer, for redirect link */ if (Cart::isGuestCartByCartId($this->id_cart)) { $is_guest = true; $redirectLink = 'index.php?controller=guest-tracking'; } else { $redirectLink = 'index.php?controller=history'; } $this->id_module = (int) Tools::getValue('id_module', 0); $this->id_order = Order::getOrderByCartId((int) $this->id_cart); $this->secure_key = Tools::getValue('key', false); $order = new Order((int) $this->id_order); if ($is_guest) { $customer = new Customer((int) $order->id_customer); $redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email); } if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) { Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : '')); } $this->reference = $order->reference; if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) { Tools::redirect($redirectLink); } $module = Module::getInstanceById((int) $this->id_module); if (isset($order->payment) && isset($module->displayName) && $order->payment != $module->displayName && !in_array($order->payment, $this->get_mediosp())) { Tools::redirect($redirectLink); } $url_banco2 = Tools::getValue('bankdest2', 0); $url_dec_64 = base64_decode(strtr($url_banco2, '-_,', '+/=')); if ($url_banco2 != false) { $this->url_banco = $url_dec_64; Tools::redirect($this->url_banco); } $URL_PAYMENT_RECEIPT_HTML = Tools::getValue('URL_PAYMENT_RECEIPT_HTML', 0); $url_iframe = base64_decode(strtr($URL_PAYMENT_RECEIPT_HTML, '-_,', '+/=')); if ($URL_PAYMENT_RECEIPT_HTML != false) { $this->url_iframe = $url_iframe; } }
public function postProcess() { $auth = $this->getHeaderAuthorization(); if (!$auth || $auth !== Configuration::get('APLAZAME_SECRET_KEY')) { $this->apiResponse(array('error' => 'Authorization not valid')); } $checkoutToken = Tools::getValue('checkout_token', false); if (!$checkoutToken) { $this->apiResponse(array('error' => 'missing checkout_token')); } $orderId = Order::getOrderByCartId($checkoutToken); $order = new Order($orderId); if (!Validate::isLoadedObject($order)) { $this->apiResponse(array('error' => 'mid not found')); } if ($order->module !== $this->module->name) { $this->apiResponse(array('error' => 'mid is not from an Aplazame order')); } $this->apiResponse($this->getCustomerHistory($order->id_customer, $this->limit_orders)); }
public function postProcess() { if (Tools::isSubmit('cart_id') == false || Tools::isSubmit('secure_key') == false) { return false; } $cart_id = Tools::getValue('cart_id'); $secure_key = Tools::getValue('secure_key'); $cart = new Cart((int) $cart_id); $customer = new Customer((int) $cart->id_customer); /** * Since it's an example we are validating the order right here, * You should not do it this way in your own module. */ $payment_status = Configuration::get('PS_OS_PAYMENT'); // Default value for a payment that succeed. $message = null; // You can add a comment directly into the order so the merchant will see it in the BO. /** * Converting cart into a valid order */ $module_name = $this->module->displayName; $currency_id = (int) Context::getContext()->currency->id; $this->module->validateOrder($cart_id, $payment_status, $cart->getOrderTotal(), $module_name, $message, array(), $currency_id, false, $secure_key); /** * If the order has been validated we try to retrieve it */ $order_id = Order::getOrderByCartId((int) $cart->id); if ($order_id && $secure_key == $customer->secure_key) { /** * The order has been placed so we redirect the customer on the confirmation page. */ $module_id = $this->module->id; Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart_id . '&id_module=' . $module_id . '&id_order=' . $order_id . '&key=' . $secure_key); } else { /** * An error occured and is shown on a new page. */ $this->errors[] = $this->module->l('An error occured. Please contact the merchant to have more informations'); return $this->setTemplate('error.tpl'); } }
/** * * @see FrontController::postProcess() */ public function postProcess() { // Disconnect User from cart HipayClass::unsetCart(); // block 3s because sleep(3); // récupération des informations en GET ou POST venant de la page de paiement $cart_id = Tools::getValue('orderId'); $transac = Tools::getValue('reference'); $context = Context::getContext(); // -------------------------------------------------------------------------- // vérification si les informations ne sont pas = à FALSE if (!$cart_id) { // récupération du dernier panier via son compte client $sql = 'SELECT `id_cart` FROM `' . _DB_PREFIX_ . 'cart` WHERE `id_customer` = ' . $context->customer->id . ' ORDER BY date_upd DESC'; $result = Db::getInstance()->getRow($sql); $cart_id = isset($result['id_cart']) ? $result['id_cart'] : false; if ($cart_id) { $objCart = new Cart((int) $cart_id); } } else { // load cart $objCart = new Cart((int) $cart_id); } // load order for id_order $order_id = Order::getOrderByCartId($cart_id); if ($order_id && !empty($order_id) && $order_id > 0) { // load transaction by id_order $sql = 'SELECT DISTINCT(op.transaction_id) FROM `' . _DB_PREFIX_ . 'order_payment` op INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON o.reference = op.order_reference WHERE o.id_order = ' . $order_id; $result = Db::getInstance()->getRow($sql); } $transaction = isset($result['transaction_id']) ? $result['transaction_id'] : 0; $context->smarty->assign(array('id_order' => $order_id, 'total' => $objCart->getOrderTotal(true), 'transaction' => $transaction, 'currency' => $context->currency->iso_code, 'email' => $context->customer->email)); $this->setTemplate('payment_accept.tpl'); }
public function postProcess() { if (Tools::isSubmit('cart_id') == false || Tools::isSubmit('secure_key') == false) { return false; } $cart_id = Tools::getValue('cart_id'); $secure_key = Tools::getValue('secure_key'); $cart = new Cart((int) $cart_id); $customer = new Customer((int) $cart->id_customer); $payment_status = Configuration::get('PS_OS_PAYMENT'); // Default value for a payment that succeed. $message = null; // You can add a comment directly into the order so the merchant will see it in the BO. $module_name = $this->module->displayName; $currency_id = (int) Context::getContext()->currency->id; $order_id = Order::getOrderByCartId((int) $cart->id); if ($order_id && $secure_key == $customer->secure_key) { $module_id = $this->module->id; Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart_id . '&id_module=' . $module_id . '&id_order=' . $order_id . '&key=' . $secure_key); } else { if ($order_id) { $this->errors[] = $this->module->l('An error occured but don\'t worry. Your order has been placed before. Please contact the merchant to have more informations or visit "My Account" to see your order history'); } elseif ($cart_id) { //We will try a last client side validation $result = $this->module->callToRest('POST', Aplazame::API_CHECKOUT_PATH . '/' . $cart_id . '/authorize', null, false); $result['response'] = json_decode($result['response'], true); if ($result['code'] == '200') { if ($this->module->validateController(Tools::getValue('cart_id'))) { $order_id = Order::getOrderByCartId((int) $cart->id); $module_id = $this->module->id; Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart_id . '&id_module=' . $module_id . '&id_order=' . $order_id . '&key=' . $secure_key); } } else { $this->errors[] = $this->module->l('An error occured. Your order has not been confirmed by Aplazame. Please contact the merchant to have more information.'); } } else { $this->errors[] = $this->module->l('An error occured. Please contact the merchant to have more information.'); } return $this->setTemplate('error.tpl'); } }
private function displayOrderConfirmation($id_cart) { if (!(int) ${${"GLOBALS"}["ymudqmgr"]}) { return; } ${${"GLOBALS"}["tiampu"]} = Order::getOrderByCartId(${${"GLOBALS"}["ymudqmgr"]}); ${${"GLOBALS"}["lyxqutk"]} = array(); ${${"GLOBALS"}["xhejvzyl"]} = new Order(${${"GLOBALS"}["tiampu"]}); ${${"GLOBALS"}["lliireede"]} = new Currency($order->id_currency); if (Validate::isLoadedObject(${${"GLOBALS"}["xhejvzyl"]})) { $qxulguwfzl = "params"; $gyzgdhsxvn = "currency"; ${$qxulguwfzl}["total_to_pay"] = $order->getOrdersTotalPaid(); ${${"GLOBALS"}["lyxqutk"]}["currency"] = $currency->sign; ${"GLOBALS"}["jowultw"] = "params"; ${${"GLOBALS"}["lyxqutk"]}["objOrder"] = ${${"GLOBALS"}["xhejvzyl"]}; ${${"GLOBALS"}["jowultw"]}["currencyObj"] = ${$gyzgdhsxvn}; return Hook::exec("displayOrderConfirmation", ${${"GLOBALS"}["lyxqutk"]}); } return; }
public function postProcess() { $auth = $this->getHeaderAuthorization(); if (!$auth || $auth != Configuration::get('APLAZAME_SECRET_KEY', null)) { $this->apiResponse(array('error' => 'Authorization not valid')); } if (Tools::getValue('checkout_token', false) == false) { $this->apiResponse(array('error' => 'mid not found as parameter checkout_token')); } if ($id_order = Order::getOrderByCartId(Tools::getValue('checkout_token'))) { $Order = new Order($id_order); if ($Order->module == $this->module->name) { $Customer = new Customer($Order->id_customer); $this->apiResponse($this->module->getCustomerHistory($Customer, $this->limit_orders)); } else { $this->apiResponse(array('error' => 'mid is not from an Aplazame order')); } } else { $this->apiResponse(array('error' => 'no order exists with this mid')); } }
public function postProcess() { $cart = $this->context->cart; if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) { Tools::redirect('index.php?controller=order&step=1'); } $authorized = false; foreach (Module::getPaymentModules() as $module) { if ($module['name'] == 'invipaypaygate') { $authorized = true; break; } } if (!$authorized) { die($this->module->l('This payment method is not available.', 'validation')); } $validationErrors = $this->helper->validateCart($cart); if (count($validationErrors) > 0) { Tools::redirect('index.php?controller=order'); } $virtual_product_id = $this->helper->addPaymentMethodCostVirtualItemToCart($cart); $customer = new Customer($cart->id_customer); $total = (double) $cart->getOrderTotal(true, Cart::BOTH); // Saves order to database $config = $this->helper->loadConfiguration(); $title = $config['PAYMENT_METHOD_TITLE']; if ($this->module->validateOrder($cart->id, Configuration::get(InvipaypaygateHelper::ORDER_STATUS_PAYMENT_STARTED), $total, $title, NULL, NULL, $cart->id_currency, false, $customer->secure_key)) { $this->helper->removePaymentMethodCostVirtualItem($virtual_product_id); try { $order = new Order(Order::getOrderByCartId($cart->id)); $redirectUrl = $this->helper->startPaymentRequest($cart, $order); Tools::redirect($redirectUrl); } catch (Exception $ex) { Tools::redirect($this->context->link->getModuleLink('invipaypaygate', 'error') . '?msg=' . base64_encode($ex->getMessage())); return; } } else { Tools::redirect('index.php?controller=order'); } }
/** * @return string */ protected function _executeWebhook() { $order_id = Tools::getValue('customer_order'); if (empty($order_id)) { return 'NO ID'; } $status = Tools::getValue('status'); if (empty($status) || $status != 4) { return 'NO STATUS'; } $amount = Tools::getValue('amount'); if (empty($amount)) { return 'NO AMOUNT'; } $order = Order::getOrderByCartId($order_id); if ($order) { $this->module->setOrderStatus($order, 12); } else { return 'NO ORDER'; } return 'OK'; }
public function initContent() { parent::initContent(); $currency = new Currency((int) $this->context->cart->id_currency); $paylater = new Paylater(); $id_module = $paylater->id; if (Tools::getValue('c')) { $cart = new Cart((int) Tools::getValue('c')); $order_id = Order::getOrderByCartId((int) $cart->id); $order = new Order($order_id); $cart_products = $cart->getProducts(); $items = array(); foreach ($cart_products as $p) { $items[] = array('id' => $p['id_product'], 'name' => $p['name'], 'sku' => $p['reference'], 'category' => $p['category'], 'price' => $p['price'], 'quantity' => $p['quantity']); } $analitics = Configuration::get('PAYLATER_ANALYTICS'); $this->context->smarty->assign(array('total' => $order->total_paid, 'currency' => $currency, 'currency_iso' => $currency->iso_code, 'id_module' => $id_module, 'id_cart' => $cart, 'order_id' => $order_id, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'shipping' => $order->total_shipping_tax_excl, 'total_w_tax' => $order->total_paid_tax_excl, 'tax' => $order->total_paid_tax_incl - $order->total_paid_tax_excl, 'items' => $items, 'analitics' => $analitics)); return $this->setTemplate('confirmation.tpl'); } else { return $this->setTemplate('error.tpl'); } }
public function postProcess() { $cart = new Cart(Tools::getValue('id_cart')); if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) { Tools::redirect('index.php?controller=order&step=1'); } // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process $authorized = false; foreach (Module::getPaymentModules() as $module) { if ($module['name'] == 'weixinpay') { $authorized = true; break; } } if (!$authorized) { die($this->module->l('This payment method is not available.', 'validation')); } $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) { Tools::redirect('index.php?controller=order&step=1'); } $id_order = Order::getOrderByCartId($cart->id); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $id_order . '&key=' . $customer->secure_key); }
$this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($id_order))); } echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl'); } } $id_cart = Tools::getValue('id_cart'); $id_module = Tools::getValue('id_module'); $id_order = Tools::getValue('id_order'); $key = Tools::getValue('key'); if ($id_module && $id_order && $id_cart && $key) { if (version_compare(_PS_VERSION_, '1.5', '<')) { $integral_evolution_submit = new PayPalIntegralEvolutionSubmit(); $integral_evolution_submit->run(); } } elseif ($id_cart) { // Redirection $values = array('id_cart' => (int) $id_cart, 'id_module' => (int) Module::getInstanceByName('paypal')->id, 'id_order' => (int) Order::getOrderByCartId((int) $id_cart)); if (version_compare(_PS_VERSION_, '1.5', '<')) { $customer = new Customer(Context::getContext()->cookie->id_customer); $values['key'] = $customer->secure_key; $url = _MODULE_DIR_ . '/paypal/integral_evolution/submit.php'; Tools::redirectLink($url . '?' . http_build_query($values, '', '&')); } else { $values['key'] = Context::getContext()->customer->secure_key; $link = Context::getContext()->link->getModuleLink('paypal', 'submit', $values); Tools::redirect($link); } } else { Tools::redirectLink(__PS_BASE_URI__); } exit(0);