public function main()
 {
     $fields = array();
     $this->load->model('checkout/order');
     $this->loadLanguage('default_skrill/default_skrill');
     $cancel_url = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2');
     if (is_file(DIR_RESOURCE . $this->config->get('config_logo'))) {
         $logo = HTTPS_DIR_RESOURCE . $this->config->get('config_logo');
     } else {
         $logo = $this->config->get('config_logo');
     }
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $products = '';
     foreach ($this->cart->getProducts() as $product) {
         $products .= $product['quantity'] . ' x ' . $product['name'] . ', ';
     }
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $skrill_url = 'https://pay.skrill.com';
     //$skrill_url = 'https://sandbox.dev.skrillws.net/pay';
     $fields = array('rid' => '53571612', 'ext_ref_id' => 'abantecart', 'pay_to_email' => $this->config->get('default_skrill_email'), 'recipient_description' => $this->config->get('store_name'), 'transaction_id' => $this->session->data['order_id'] . '_' . UNIQUE_ID, 'return_url' => $this->html->getSecureURL('checkout/success'), 'cancel_url' => $cancel_url, 'status_url' => $this->html->getSecureURL('extension/default_skrill/callback'), 'language' => $this->session->data['language'], 'logo_url' => $logo, 'pay_from_email' => $order_info['email'], 'firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'address' => $order_info['payment_address_1'], 'address2' => $order_info['payment_address_2'], 'phone_number' => $order_info['telephone'], 'postal_code' => substr($order_info['payment_postcode'], 0, 9), 'city' => $order_info['payment_city'], 'state' => $order_info['payment_zone'], 'country' => $order_info['payment_iso_code_3'], 'amount' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE), 'currency' => $order_info['currency'], 'detail1_text' => $products, 'merchant_fields' => 'order_id', 'order_id' => $encryption->encrypt($this->session->data['order_id']));
     $form = new AForm();
     $form->setForm(array('form_name' => 'checkout'));
     $data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'checkout', 'action' => $skrill_url));
     foreach ($fields as $key => $value) {
         $data['form'][$key] = $form->getFieldHtml(array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     $data['form']['back'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back));
     $data['form']['submit'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_confirm')));
     $this->view->batchAssign($data);
     $this->processTemplate('responses/default_skrill.tpl');
 }
 public function main()
 {
     $template_data['button_confirm'] = $this->language->get('button_confirm');
     $template_data['button_back'] = $this->language->get('button_back');
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $template_data['mid'] = $this->config->get('default_paymate_username');
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $template_data['return'] = $this->html->getSecureURL('extension/paymate/callback', '&oid=' . base64_encode($encryption->encrypt($order_info['order_id'])) . '&conf=' . base64_encode($encryption->encrypt($order_info['payment_firstname'] . $order_info['payment_lastname'])));
     if ($this->config->get('default_paymate_include_order')) {
         $template_data['ref'] = html_entity_decode($this->config->get('store_name'), ENT_QUOTES, 'UTF-8') . " (#" . $order_info['order_id'] . ")";
     } else {
         $template_data['ref'] = html_entity_decode($this->config->get('store_name'), ENT_QUOTES, 'UTF-8');
     }
     $currency = array('AUD', 'NZD', 'USD', 'EUR', 'GBP');
     if (in_array(strtoupper($order_info['currency']), $currency)) {
         $template_data['currency'] = $order_info['currency'];
         $template_data['amt'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE);
     } else {
         for ($findcur = 0; $findcur < sizeof($currency); $findcur++) {
             if ($this->currency->getValue($currency[$findcur])) {
                 $template_data['currency'] = $currency[$findcur];
                 $template_data['amt'] = $this->currency->format($order_info['total'], $currency[$findcur], '', FALSE);
                 break;
             } elseif ($findcur == sizeof($currency) - 1) {
                 $template_data['currency'] = 'AUD';
                 $template_data['amt'] = $order_info['total'];
             }
         }
     }
     $template_data['pmt_contact_firstname'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
     $template_data['pmt_contact_surname'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
     $template_data['pmt_contact_phone'] = $order_info['telephone'];
     $template_data['pmt_sender_email'] = $order_info['email'];
     $template_data['regindi_address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
     $template_data['regindi_address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
     $template_data['regindi_sub'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
     $template_data['regindi_state'] = html_entity_decode($order_info['payment_zone'], ENT_QUOTES, 'UTF-8');
     $template_data['regindi_pcode'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
     $template_data['pmt_country'] = $order_info['iso_code_2'];
     $template_data['action'] = 'https://www.paymate.com/PayMate/ExpressPayment';
     $template_data['back'] = $this->html->getSecureURL('checkout/payment');
     $this->view->batchAssign($template_data);
     $this->processTemplate('responses/default_paymate.tpl');
 }
 public function main()
 {
     $this->load->model('checkout/order');
     $this->loadLanguage('default_moneybookers/default_moneybookers');
     $form = new AForm();
     $form->setForm(array('form_name' => 'checkout'));
     $data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'checkout', 'action' => 'https://www.moneybookers.com/app/payment.pl?rid=10111486'));
     $data['form']['pay_to_email'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'pay_to_email', 'value' => $this->config->get('default_moneybookers_email')));
     $data['form']['recipient_description'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'recipient_description', 'value' => $this->config->get('store_name')));
     $data['form']['transaction_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'transaction_id', 'value' => $this->session->data['order_id']));
     $data['form']['return_url'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'return_url', 'value' => $this->html->getSecureURL('checkout/success')));
     $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2');
     $data['form']['cancel_url'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'cancel_url', 'value' => $back));
     $data['form']['status_url'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'status_url', 'value' => $this->html->getSecureURL('extension/moneybookers/callback')));
     $data['form']['language'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'language', 'value' => $this->session->data['language']));
     if (is_file(DIR_RESOURCE . $this->config->get('config_logo'))) {
         $logo = HTTP_DIR_RESOURCE . $this->config->get('config_logo');
     } else {
         $logo = $this->config->get('config_logo');
     }
     $data['form']['logo_url'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'logo_url', 'value' => $logo));
     /* * */
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $data['form']['pay_from_email'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'pay_from_email', 'value' => $order_info['email']));
     $data['form']['firstname'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'firstname', 'value' => $order_info['payment_firstname']));
     $data['form']['lastname'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'lastname', 'value' => $order_info['payment_lastname']));
     $data['form']['address'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'address', 'value' => $order_info['payment_address_1']));
     $data['form']['address2'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'address2', 'value' => $order_info['payment_address_2']));
     $data['form']['phone_number'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'phone_number', 'value' => $order_info['telephone']));
     $data['form']['postal_code'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'postal_code', 'value' => $order_info['payment_postcode']));
     $data['form']['city'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'city', 'value' => $order_info['payment_city']));
     $data['form']['state'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'state', 'value' => $order_info['payment_zone']));
     $data['form']['country'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'country', 'value' => $order_info['payment_iso_code_3']));
     $data['form']['amount'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'amount', 'value' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE)));
     $data['form']['currency'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'currency', 'value' => $order_info['currency']));
     $products = '';
     foreach ($this->cart->getProducts() as $product) {
         $products .= $product['quantity'] . ' x ' . $product['name'] . ', ';
     }
     $data['form']['detail1_text'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'detail1_text', 'value' => $products));
     $data['form']['merchant_fields'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'merchant_fields', 'value' => 'order_id'));
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $data['form']['order_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'order_id', 'value' => $encryption->encrypt($this->session->data['order_id'])));
     $data['form']['back'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back));
     $data['form']['submit'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_confirm')));
     $this->view->batchAssign($data);
     $this->processTemplate('responses/default_moneybookers.tpl');
 }
 public function main()
 {
     $this->data['button_confirm'] = $this->language->get('button_confirm');
     $this->data['button_back'] = $this->language->get('button_back');
     if (!$this->config->get('default_pp_standart_test')) {
         $this->data['action'] = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         $this->data['action'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $this->data['business'] = $this->config->get('default_pp_standart_email');
     $this->data['item_name'] = html_entity_decode($this->config->get('store_name'), ENT_QUOTES, 'UTF-8');
     $this->data['currency_code'] = $order_info['currency'];
     $this->data['amount'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE);
     $this->data['first_name'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
     $this->data['last_name'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
     $this->data['address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
     $this->data['address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
     $this->data['city'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
     $this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
     $this->data['country'] = $order_info['payment_iso_code_2'];
     $this->data['notify_url'] = $this->html->getURL('extension/default_pp_standart/callback');
     $this->data['email'] = $order_info['email'];
     $this->data['invoice'] = $this->session->data['order_id'] . ' - ' . html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8') . ' ' . html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
     $this->data['lc'] = $this->session->data['language'];
     if (has_value($this->config->get('default_pp_standart_custom_logo'))) {
         if (strpos($this->config->get('default_pp_standart_custom_logo'), 'http') === 0) {
             $this->data['logoimg'] = $this->config->get('default_pp_standart_custom_logo');
         } else {
             $this->data['logoimg'] = HTTPS_SERVER . 'resources/' . $this->config->get('default_pp_standart_custom_logo');
         }
     }
     if (has_value($this->config->get('default_pp_standart_cartbordercolor'))) {
         $this->data['cartbordercolor'] = $this->config->get('default_pp_standart_cartbordercolor');
     }
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $this->data['products'] = array();
     $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);
         }
         $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $this->currency->format($product['price'], $order_info['currency'], $order_info['value'], FALSE), 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight']);
     }
     $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', 'balance'))) {
             $total['value'] = $total['value'] < 0 ? $total['value'] * -1 : $total['value'];
             $this->data['discount_amount_cart'] += $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE);
         } else {
             $this->data['products'][] = array('name' => $total['title'], 'model' => '', 'price' => $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE), 'quantity' => 1, 'option' => array(), 'weight' => 0);
         }
     }
     if (!$this->config->get('default_pp_standart_transaction')) {
         $this->data['paymentaction'] = 'authorization';
     } else {
         $this->data['paymentaction'] = 'sale';
     }
     $this->data['return'] = $this->html->getSecureURL('checkout/success');
     if ($this->request->get['rt'] != 'checkout/guest_step_3') {
         $this->data['cancel_return'] = $this->html->getSecureURL('checkout/payment');
     } else {
         $this->data['cancel_return'] = $this->html->getSecureURL('checkout/guest_step_2');
     }
     $this->data['custom'] = $encryption->encrypt($this->session->data['order_id']);
     if ($this->request->get['rt'] != 'checkout/guest_step_3') {
         $this->data['back'] = $this->html->getSecureURL('checkout/payment');
     } else {
         $this->data['back'] = $this->html->getSecureURL('checkout/guest_step_2');
     }
     $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2');
     $this->data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back));
     $this->data['button_confirm'] = HtmlElementFactory::create(array('type' => 'submit', 'name' => $this->language->get('button_confirm'), 'style' => 'button'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/default_pp_standart.tpl');
 }
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE LOWER(loginname)  = LOWER('" . $this->db->escape($loginname) . "')\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->customer_id = $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         //load customer saved cart and merge with session cart before login
         $cart = $this->getCustomerCart();
         $this->mergeCustomerCart($cart);
         //save merged cart
         $this->saveCustomerCart();
         $this->loginname = $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 = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         //set cookie for unauthenticated user (expire in 1 year)
         $encryption = new AEncryption($this->config->get('encryption_key'));
         $cutomer_data = $encryption->encrypt(serialize(array('first_name' => $this->firstname, 'customer_id' => $this->customer_id, 'script_name' => $this->request->server['SCRIPT_NAME'])));
         setcookie('customer', $cutomer_data, time() + 60 * 60 * 24 * 365, '/', $this->request->server['HTTP_HOST']);
         return true;
     } else {
         return false;
     }
 }
 public function main()
 {
     $template_data['button_confirm'] = $this->language->get('button_confirm');
     $template_data['button_back'] = $this->language->get('button_back');
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $template_data['action'] = 'https://www.secpay.com/java-bin/ValCard';
     $template_data['merchant'] = $this->config->get('default_paypoint_merchant');
     $template_data['trans_id'] = $this->session->data['order_id'];
     $template_data['amount'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE);
     $template_data['bill_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
     $template_data['bill_addr_1'] = $order_info['payment_address_1'];
     $template_data['bill_addr_2'] = $order_info['payment_address_2'];
     $template_data['bill_city'] = $order_info['payment_city'];
     $template_data['bill_state'] = $order_info['payment_zone'];
     $template_data['bill_post_code'] = $order_info['payment_postcode'];
     $template_data['bill_country'] = $order_info['payment_country'];
     $template_data['bill_tel'] = $order_info['telephone'];
     $template_data['bill_email'] = $order_info['email'];
     if ($this->cart->hasShipping()) {
         $template_data['ship_name'] = $order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname'];
         $template_data['ship_addr_1'] = $order_info['shipping_address_1'];
         $template_data['ship_addr_2'] = $order_info['shipping_address_2'];
         $template_data['ship_city'] = $order_info['shipping_city'];
         $template_data['ship_state'] = $order_info['shipping_zone'];
         $template_data['ship_post_code'] = $order_info['shipping_postcode'];
         $template_data['ship_country'] = $order_info['shipping_country'];
     } else {
         $template_data['ship_name'] = '';
         $template_data['ship_addr_1'] = '';
         $template_data['ship_addr_2'] = '';
         $template_data['ship_city'] = '';
         $template_data['ship_state'] = '';
         $template_data['ship_post_code'] = '';
         $template_data['ship_country'] = '';
     }
     $template_data['currency'] = $this->currency->getCode();
     $template_data['callback'] = $this->html->getSecureURL('extension/paypoint/callback');
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $template_data['order_id'] = $encryption->encrypt($this->session->data['order_id']);
     switch ($this->config->get('default_paypoint_test')) {
         case 'production':
             $status = 'live';
             break;
         case 'successful':
         default:
             $status = 'true';
             break;
         case 'fail':
             $status = 'false';
             break;
     }
     $template_data['options'] = 'test_status=' . $status . ',dups=false,cb_flds=order_id';
     if ($this->request->get['rt'] != 'checkout/guest_step_3') {
         $template_data['back'] = $this->html->getSecureURL('checkout/payment');
     } else {
         $template_data['back'] = $this->html->getSecureURL('checkout/guest_step_2');
     }
     $this->view->batchAssign($template_data);
     $this->processTemplate('responses/default_paypoint.tpl');
 }
 public function send()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //validate input
     $post = $this->request->post;
     if (empty($post['cc_number'])) {
         $json['error'] = $this->language->get('error_incorrect_number');
     }
     if (empty($post['cc_owner'])) {
         $json['error'] = $this->language->get('error_incorrect_name');
     }
     if (empty($post['cc_expire_date_month']) || empty($post['cc_expire_date_year'])) {
         $json['error'] = $this->language->get('error_incorrect_expiration');
     }
     if (strlen($post['cc_cvv2']) != 3 && strlen($post['cc_cvv2']) != 4) {
         $json['error'] = $this->language->get('error_incorrect_cvv');
     }
     if (isset($json['error'])) {
         $this->load->library('json');
         $this->response->setOutput(AJson::encode($json));
         return null;
     }
     $this->loadModel('checkout/order');
     $this->loadModel('extension/default_realex');
     $this->loadLanguage('default_realex/default_realex');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     // currency code
     $currency = $this->currency->getCode();
     // order amount without decimal delimiter
     $amount = round($this->currency->convert($this->cart->getFinalTotal(), $this->config->get('config_currency'), $currency), 2) * 100;
     $cardnumber = preg_replace('/[^0-9]/', '', $post['cc_number']);
     $cvv2 = preg_replace('/[^0-9]/', '', $post['cc_cvv2']);
     // Card owner name
     $cardname = html_entity_decode($post['cc_owner'], ENT_QUOTES, 'UTF-8');
     $cardtype = $post['cc_type'];
     // card expire date mmyy
     $expdate = $post['cc_expire_date_month'] . substr($post['cc_expire_date_year'], 2, 2);
     $cardissue = $post['cc_issue'];
     $order_ref = $order_id . 'AB' . strftime("%Y%m%d%H%M%S") . mt_rand(1, 999);
     // Mechant id values are provided by Realex Payments, if you have not already received them please contact releax
     $conf_cc_list = unserialize($this->config->get('default_realex_creditcard_selection'));
     $account = $conf_cc_list[$cardtype]['subaccount'];
     if (empty($account) || $accounts[$cardtype]['default']) {
         //use default account by setting it to empty
         $account = '';
     }
     ADebug::checkpoint('Realex Payment: Order ID ' . $order_id);
     //do we have 3d on?
     $v3d = array();
     $pd = array('account' => $account, 'amount' => $amount, 'currency' => $currency, 'order_id' => $order_id, 'order_ref' => $order_ref, 'cc_number' => $cardnumber, 'cc_expire' => $expdate, 'cc_owner' => $cardname, 'cc_type' => $cardtype, 'cc_cvv2' => $cvv2, 'cc_issue' => $cardissue);
     if ($this->config->get('default_realex_3d')) {
         if ($cc_type == 'visa' || $cc_type == 'mc' || $cc_type == 'amex') {
             $verify_3ds = $this->model_extension_default_realex->check3DEnrollment($account, $amount, $currency, $order_ref, $post);
             ADebug::variable('Verify 3DS result: ', $verify_3ds);
             if (isset($verify_3ds->result) && $verify_3ds->result == '00') {
                 $encryption = new AEncryption($this->config->get('encryption_key'));
                 $enc_data = $encryption->encrypt(serialize($pd));
                 $json = array();
                 $json['ACSURL'] = (string) $verify_3ds->url;
                 $json['MD'] = $enc_data;
                 $json['PaReq'] = (string) $verify_3ds->pareq;
                 $json['TermUrl'] = $this->html->getSecureURL('extension/default_realex/callback');
                 $this->load->library('json');
                 $this->response->setOutput(AJson::encode($json));
                 return null;
             }
             //Cardholder Not Enrolled. Shift in liability. ECI = 6
             if (isset($verify_3ds->result) && $verify_3ds->result == '110' && isset($verify_3ds->enrolled) && $verify_3ds->enrolled == 'N') {
                 $v3d['eci_ref'] = 1;
                 if ($cardtype == 'mc') {
                     $v3d['eci'] = 1;
                 } else {
                     $v3d['eci'] = 6;
                 }
             }
             // Cannot Verify Enrollment. No shift in liability. ECI = 7
             if (isset($verify_3ds->result) && $verify_3ds->result == '110' && isset($verify_3ds->enrolled) && $verify_3ds->enrolled == 'U') {
                 if ($this->config->get('default_realex_liability_shift') != 1) {
                     $json['error'] = $this->language->get('error_3d_enroll');
                     $this->load->library('json');
                     $this->response->setOutput(AJson::encode($json));
                     return null;
                 } else {
                     $v3d['eci_ref'] = 2;
                     if ($cardtype == 'mc') {
                         $v3d['eci'] = 0;
                     } else {
                         $v3d['eci'] = 7;
                     }
                 }
             }
             // Invalid response from Enrollment Server. No shift in liability. ECI = 7
             if (isset($verify_3ds->result) && $verify_3ds->result >= 500 && $verify_3ds->result < 600) {
                 if ($this->config->get('realex_remote_liability') != 1) {
                     $json['error'] = (string) $verify_3ds->message;
                     $this->load->library('json');
                     $this->response->setOutput(AJson::encode($json));
                     return null;
                 } else {
                     $v3d['eci_ref'] = 3;
                     if ($cardtype == 'mc') {
                         $v3d['eci'] = 0;
                     } else {
                         $v3d['eci'] = 7;
                     }
                 }
             }
         }
     }
     $p_result = $this->model_extension_default_realex->processPayment($pd, $v3d);
     ADebug::variable('Processing payment result: ', $p_result);
     if ($p_result->result != '00') {
         // transaction failed
         $json['error'] = (string) $p_result->message . ' (' . (int) $p_result->result . ')';
     } else {
         $json['success'] = $this->html->getSecureURL('checkout/success');
     }
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($json));
 }