public function callback() { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); if (isset($this->request->post['order_id'])) { $order_id = $encryption->decrypt($this->request->post['order_id']); } else { $order_id = 0; } $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info) { $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); switch ($this->request->post['status']) { case '2': $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_id'), '', TRUE); break; case '0': $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_pending_id'), '', TRUE); break; case '-1': $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_canceled_id'), '', TRUE); break; case '-2': $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_failed_id'), '', TRUE); break; case '-3': $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_chargeback_id'), '', TRUE); break; } } }
public function callback() { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); if (isset($this->request->post['order_id'])) { $order_id = $encryption->decrypt($this->request->post['order_id']); } else { return null; } $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if (!$order_info) { return null; } $md5_ok = false; if ($this->config->get('default_skrill_email')) { $ourhash = $this->request->post['merchant_id']; $ourhash .= $this->request->post['transaction_id'] . '_' . UNIQUE_ID; $ourhash .= strtoupper(md5($this->config->get('default_skrill_secret'))); $ourhash .= $this->request->post['mb_amount']; $ourhash .= $this->request->post['mb_currency']; $ourhash .= $this->request->post['status']; $ourmd5hash = strtoupper(md5($ourhash)); $thiermd5sig = $this->request->post['md5sig']; if ($ourmd5hash == $thiermd5sig) { $md5_ok = true; } } $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); if ($md5_ok) { switch ($this->request->post['status']) { case '2': $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_id'), '', TRUE); break; case '0': $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_pending_id'), '', TRUE); break; case '-1': $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_canceled_id'), '', TRUE); break; case '-2': $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_failed_id'), 'Reason code: ' . $this->request->post['failed_reason_code'], TRUE); break; case '-3': $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_chargeback_id'), '', TRUE); break; } } else { //Security HASH verification failed $this->model_checkout_order->addHistory($order_id, $this->config->get('default_skrill_order_status_pending_id'), 'Manual order verification is required! MD5 hash returned (' + $thiermd5sig + ') does not match generated (' + $ourmd5hash + ').'); } return null; }
public function callback() { $this->loadLanguage('default_paymate/default_paymate'); $error = ''; if (isset($this->request->post['responseCode'])) { if ($this->request->post['responseCode'] == 'PA' || $this->request->post['responseCode'] == 'PP') { if (isset($this->request->get['oid']) && isset($this->request->get['conf'])) { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); $order_id = $encryption->decrypt(base64_decode($this->request->get['oid'])); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if (isset($order_info['payment_firstname']) && isset($order_info['payment_lastname']) && strcmp($encryption->decrypt(base64_decode($this->request->get['conf'])), $order_info['payment_firstname'] . $order_info['payment_lastname']) == 0) { $this->model_checkout_order->confirm($order_id, $this->config->get('default_paymate_order_status_id')); } else { $error = $this->language->get('text_unable'); } } else { $error = $this->language->get('text_unable'); } } else { $error = $this->language->get('text_declined'); } } else { $error = $this->language->get('text_unable'); } if ($error != '') { $template_data['heading_title'] = $this->language->get('text_failed'); $template_data['text_message'] = sprintf($this->language->get('text_failed_message'), $error, $this->html->getURL('content/contact')); $template_data['button_continue'] = $this->language->get('button_continue'); $template_data['continue'] = $this->html->getURL('index/home'); $this->view->batchAssign($template_data); $this->processTemplate($this->config->get('config_storefront_template') . 'common/success.tpl'); } else { $this->redirect($this->html->getSecureURL('checkout/success')); } }
private function _get_products_data($order_info) { $that = $this->baseObject; $that->load->library('encryption'); $encryption = new AEncryption($that->config->get('encryption_key')); $this->data['products'] = array(); $this->data['items_total'] = 0.0; $products = $that->cart->getProducts(); foreach ($products as $product) { $option_data = array(); foreach ($product['option'] as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $filename = $encryption->decrypt($option['value']); $value = mb_substr($filename, 0, mb_strrpos($filename, '.')); } $option_data[] = array('name' => $option['name'], 'value' => mb_strlen($value) > 20 ? mb_substr($value, 0, 20) . '..' : $value); } $price = $that->currency->format($product['price'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $price, 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight'], 'weight_type' => $product['weight_type']); $this->data['items_total'] += $price * $product['quantity']; } $this->data['discount_amount_cart'] = 0; $totals = $that->cart->buildTotalDisplay(); foreach ($totals['total_data'] as $total) { if (in_array($total['id'], array('subtotal', 'total'))) { continue; } if (in_array($total['id'], array('promotion', 'coupon'))) { $total['value'] = $total['value'] < 0 ? $total['value'] * -1 : $total['value']; $this->data['discount_amount_cart'] += $total['value']; } else { $price = $that->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0); $this->data['items_total'] += $price; } } if ($this->data['discount_amount_cart'] > 0) { $price = -1 * $that->currency->format($this->data['discount_amount_cart'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][] = array('name' => $that->language->get('text_discount'), 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0); $this->data['items_total'] += $price; } return $this->data['products']; }
private function _get_products_data($order_info) { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); $this->data['products'] = array(); $this->data['items_total'] = 0.0; $products = $this->cart->getProducts(); foreach ($products as $product) { $option_data = array(); foreach ($product['option'] as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $filename = $encryption->decrypt($option['value']); $value = mb_substr($filename, 0, mb_strrpos($filename, '.')); } $option_data[] = array('name' => $option['name'], 'value' => mb_strlen($value) > 20 ? mb_substr($value, 0, 20) . '..' : $value); } $price = $this->currency->format($product['price'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $price, 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight'], 'weight_type' => $product['weight_type']); $this->data['items_total'] += $price * $product['quantity']; } //check for virtual product such as gift certificate $virtual_products = $this->cart->getVirtualProducts(); if ($virtual_products) { foreach ($virtual_products as $k => $virtual) { $this->data['products'][] = array('name' => $virtual['name'] ? $virtual['name'] : 'Virtual Product', 'model' => '', 'price' => $this->currency->format($virtual['amount'], $order_info['currency'], $order_info['value'], false), 'quantity' => $virtual['quantity'] ? $virtual['quantity'] : 1, 'option' => array(), 'weight' => 0); $this->data['items_total'] += ($virtual['quantity'] ? $virtual['quantity'] : 1) * $this->currency->format($virtual['amount'], $order_info['currency'], $order_info['value'], false); } } $this->data['discount_amount_cart'] = 0; $totals = $this->cart->buildTotalDisplay(); foreach ($totals['total_data'] as $total) { if (in_array($total['id'], array('subtotal', 'total'))) { continue; } if (in_array($total['id'], array('promotion', 'coupon'))) { $total['value'] = $total['value'] < 0 ? $total['value'] * -1 : $total['value']; $this->data['discount_amount_cart'] += $total['value']; } else { $price = $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE); if (in_array($total['id'], array('tax'))) { $this->data['tax_total'] += $price; } elseif (in_array($total['id'], array('shipping'))) { $this->data['shipping_total'] += $price; } elseif (in_array($total['id'], array('handling'))) { $this->data['handling_total'] += $price; } else { $this->data['items_total'] += $price; } $this->data['products'][$total['id']] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0); } } $calc_total = $this->data['items_total'] + $this->data['shipping_total'] + $this->data['tax_total'] + $this->data['handling_total']; if ($calc_total - $order_info['order_total'] !== 0.0) { foreach ($totals['total_data'] as $total) { if (in_array($total['id'], array('subtotal', 'total', 'promotion', 'coupon'))) { continue; } $price = $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][$total['id']] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0); } } if ($this->data['discount_amount_cart'] > 0) { $price = -1 * $this->currency->format($this->data['discount_amount_cart'], $order_info['currency'], $order_info['value'], FALSE); $this->data['products'][] = array('name' => $this->language->get('text_discount'), 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0); $this->data['items_total'] += $price; } return $this->data['products']; }
public function callback() { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); if (isset($this->request->post['custom'])) { $order_id = $encryption->decrypt($this->request->post['custom']); } else { $order_id = 0; } $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $suspect = false; $message = ''; if ($order_info) { // check seller email and save message if not equal if ($this->request->post['receiver_email'] != $this->config->get('default_pp_standart_email')) { $this->load->language('default_pp_standart/default_pp_standart'); $message .= $this->language->get('text_suspect'); $params = array('payment_status', 'pending_reason', 'address_zip', 'address_country_code', 'address_name', 'address_country', 'address_city', 'quantity', 'payer_email', 'first_name', 'last_name', 'payment_gross', 'shipping', 'ipn_track_id', 'receiver_email'); foreach ($params as $p) { if (isset($this->request->post[$p])) { $message .= $p . ": " . $this->request->post[$p] . "<br>\n"; } } $msg = new AMessage(); $msg->saveNotice(sprintf($this->language->get('text_suspect_subj'), $order_id), $message); $suspect = true; } $request = 'cmd=_notify-validate'; foreach ($this->request->post as $key => $value) { $request .= '&' . $key . '=' . urlencode(stripslashes(html_entity_decode($value, ENT_QUOTES, 'UTF-8'))); } if (extension_loaded('curl')) { if (!$this->config->get('default_pp_standart_test')) { $ch = curl_init('https://www.paypal.com/cgi-bin/webscr'); } else { $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); } curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); if ($suspect === true) { // set pending status for all suspected orders $this->model_checkout_order->confirm($order_id, 1, $message); } elseif (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') { $this->model_checkout_order->confirm($order_id, $this->config->get('default_pp_standart_order_status_id')); } else { $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); } curl_close($ch); } else { $header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n"; $header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; $header .= 'Content-Length: ' . mb_strlen($request) . "\r\n"; $header .= 'Connection: close' . "\r\n\r\n"; if (!$this->config->get('default_pp_standart_test')) { $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); } else { $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30); } if ($fp) { fputs($fp, $header . $request); while (!feof($fp)) { $response = fgets($fp, 1024); if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') { $this->model_checkout_order->confirm($order_id, $this->config->get('default_pp_standart_order_status_id')); } else { $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); } } fclose($fp); } } $this->model_checkout_order->updatePaymentMethodData($this->session->data['order_id'], $response); } }
/** * @param Registry $registry */ public function __construct($registry) { $this->cache = $registry->get('cache'); $this->config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); $this->dcrypt = $registry->get('dcrypt'); if (isset($this->session->data['customer_id'])) { $customer_query = $this->db->query("SELECT * FROM " . $this->db->table("customers") . " WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND status = '1'"); if ($customer_query->num_rows) { $this->customer_id = $customer_query->row['customer_id']; $this->loginname = $customer_query->row['loginname']; $this->firstname = $customer_query->row['firstname']; $this->lastname = $customer_query->row['lastname']; if ($this->dcrypt->active) { $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']); $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']); $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']); } else { $this->email = $customer_query->row['email']; $this->telephone = $customer_query->row['telephone']; $this->fax = $customer_query->row['fax']; } $this->newsletter = (int) $customer_query->row['newsletter']; $this->customer_group_id = $customer_query->row['customer_group_id']; $this->address_id = $customer_query->row['address_id']; } else { $this->logout(); } } elseif (isset($this->request->cookie['customer'])) { //we have unauthenticated customer $encryption = new AEncryption($this->config->get('encryption_key')); $this->unauth_customer = unserialize($encryption->decrypt($this->request->cookie['customer'])); //customer is not from the same store (under the same domain) if ($this->unauth_customer['script_name'] != $this->request->server['SCRIPT_NAME']) { //clean up $this->unauth_customer = array(); setcookie("customer", "", time() - 3600); } //no need to merge with session as it shoud be always in sync $this->session->data['cart'] = array(); $this->session->data['cart'] = $this->getCustomerCart(); } }
public function callback() { $this->loadLanguage('default_paypoint/default_paypoint'); $template_data['title'] = sprintf($this->language->get('heading_title'), $this->config->get('store_name')); if (!isset($this->request->server['HTTPS']) || $this->request->server['HTTPS'] != 'on') { $template_data['base'] = HTTP_SERVER; } else { $template_data['base'] = HTTPS_SERVER; } $template_data['charset'] = 'utf-8'; $template_data['language'] = $this->language->get('code'); $template_data['direction'] = $this->language->get('direction'); $template_data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('store_name')); $template_data['text_response'] = $this->language->get('text_response'); $template_data['text_success'] = $this->language->get('text_success'); $template_data['text_success_wait'] = sprintf($this->language->get('text_success_wait'), $this->html->getSecureURL('checkout/success')); $template_data['text_failure'] = $this->language->get('text_failure'); $template_data['text_failure_wait'] = sprintf($this->language->get('text_failure_wait'), $this->html->getSecureURL('checkout/cart')); if (isset($this->request->get['valid']) && $this->request->get['valid'] == 'true') { $this->load->library('encryption'); $encryption = new AEncryption($this->config->get('encryption_key')); $order_id = $encryption->decrypt($this->request->get['order_id']); $this->load->model('checkout/order'); $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); $message = ''; if (isset($this->request->get['code'])) { $message .= 'code: ' . $this->request->get['code'] . "\n"; } if (isset($this->request->get['auth_code'])) { $message .= 'auth_code: ' . $this->request->get['auth_code'] . "\n"; } if (isset($this->request->get['ip'])) { $message .= 'ip: ' . $this->request->get['ip'] . "\n"; } if (isset($this->request->get['cv2avs'])) { $message .= 'cv2avs: ' . $this->request->get['cv2avs'] . "\n"; } if (isset($this->request->get['trans_id'])) { $message .= 'trans_id: ' . $this->request->get['trans_id'] . "\n"; } if (isset($this->request->get['valid'])) { $message .= 'valid: ' . $this->request->get['valid'] . "\n"; } $this->model_checkout_order->update($order_id, $this->config->get('default_paypoint_order_status_id'), $message, FALSE); $template_data['continue'] = $this->html->getSecureURL('checkout/success'); $this->view->batchAssign($template_data); $this->view->setTemplate('responses/extension/paypoint_success.tpl'); } else { $template_data['continue'] = $this->html->getSecureURL('checkout/cart'); $this->view->batchAssign($template_data); $this->view->setTemplate('responses/extension/paypoint_failure.tpl'); } $this->processTemplate(); }
/** * @param Registry $registry */ public function __construct($registry) { $this->cache = $registry->get('cache'); $this->config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); $this->dcrypt = $registry->get('dcrypt'); $this->load = $registry->get('load'); if (isset($this->session->data['customer_id'])) { $customer_query = $this->db->query("SELECT c.*, cg.* FROM " . $this->db->table("customers") . " c\n\t\t\t\t\tLEFT JOIN " . $this->db->table("customer_groups") . " cg on c.customer_group_id = cg.customer_group_id\n\t\t\t\t\tWHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' \n\t\t\t\t\tAND status = '1'"); if ($customer_query->num_rows) { $this->customer_id = $customer_query->row['customer_id']; $this->loginname = $customer_query->row['loginname']; $this->firstname = $customer_query->row['firstname']; $this->lastname = $customer_query->row['lastname']; if ($this->dcrypt->active) { $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']); $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']); $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']); } else { $this->email = $customer_query->row['email']; $this->telephone = $customer_query->row['telephone']; $this->fax = $customer_query->row['fax']; } $this->newsletter = (int) $customer_query->row['newsletter']; $this->customer_group_id = $customer_query->row['customer_group_id']; $this->customer_group_name = $customer_query->row['name']; $this->customer_tax_exempt = $customer_query->row['tax_exempt']; $this->address_id = $customer_query->row['address_id']; } else { $this->logout(); } } elseif (isset($this->request->cookie['customer'])) { //we have unauthenticated customer $encryption = new AEncryption($this->config->get('encryption_key')); $this->unauth_customer = unserialize($encryption->decrypt($this->request->cookie['customer'])); //customer is not valid or not from the same store (under the same domain) if ($this->unauth_customer['script_name'] != $this->request->server['SCRIPT_NAME'] || !$this->isValidEnabledCustomer()) { //clean up $this->unauth_customer = array(); //expire unauth cookie unset($_COOKIE['customer']); setcookie('customer', '', time() - 3600, dirname($this->request->server['PHP_SELF'])); } //check if unauthenticated customer cart content was found and merge with session $saved_cart = $this->getCustomerCart(); if (!empty($saved_cart) && count($saved_cart)) { $this->mergeCustomerCart($saved_cart); } } //Update online customers' activity $ip = ''; if (isset($this->request->server['REMOTE_ADDR'])) { $ip = $this->request->server['REMOTE_ADDR']; } $url = ''; if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) { $url = 'http://' . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI']; } $referer = ''; if (isset($this->request->server['HTTP_REFERER'])) { $referer = $this->request->server['HTTP_REFERER']; } $customer_id = ''; if ($this->isLogged()) { $customer_id = $this->getId(); } else { if ($this->isUnauthCustomer()) { $customer_id = $this->isUnauthCustomer(); } } $this->load->model('tool/online_now'); $registry->get('model_tool_online_now')->setOnline($ip, $customer_id, $url, $referer); //EOF Custmer Construct }
/** * @param Registry $registry */ public function __construct($registry) { $this->cache = $registry->get('cache'); $this->config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); $this->dcrypt = $registry->get('dcrypt'); if (isset($this->session->data['customer_id'])) { $customer_query = $this->db->query("SELECT * FROM " . $this->db->table("customers") . " WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND status = '1'"); if ($customer_query->num_rows) { $this->customer_id = $customer_query->row['customer_id']; $this->loginname = $customer_query->row['loginname']; $this->firstname = $customer_query->row['firstname']; $this->lastname = $customer_query->row['lastname']; if ($this->dcrypt->active) { $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']); $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']); $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']); } else { $this->email = $customer_query->row['email']; $this->telephone = $customer_query->row['telephone']; $this->fax = $customer_query->row['fax']; } $this->newsletter = (int) $customer_query->row['newsletter']; $this->customer_group_id = $customer_query->row['customer_group_id']; $this->address_id = $customer_query->row['address_id']; } else { $this->logout(); } } elseif (isset($this->request->cookie['customer'])) { //we have unauthenticated customer $encryption = new AEncryption($this->config->get('encryption_key')); $this->unauth_customer = unserialize($encryption->decrypt($this->request->cookie['customer'])); //customer is not valid or not from the same store (under the same domain) if ($this->unauth_customer['script_name'] != $this->request->server['SCRIPT_NAME'] || !$this->isValidEnabledCustomer()) { //clean up $this->unauth_customer = array(); //expire unauth cookie unset($_COOKIE['customer']); setcookie('customer', '', time() - 3600, dirname($this->request->server['PHP_SELF'])); } //check if unauthenticated customer cart content was found and merge with session $saved_cart = $this->getCustomerCart(); if (!empty($saved_cart) && count($saved_cart)) { $this->mergeCustomerCart($saved_cart); } } }