when i test CCNOW payment method the payment is successful but the item is still in the shopping cart.
this what i get on my log file:
2014-03-27 8:11:26 - PHP Notice: Undefined index: x_invoice_num in /home/aseelmal/public_html/catalog/controller/payment/ccnow.php on line 119
2014-03-27 8:11:26 - PHP Notice: Undefined index: x_fp_hash in /home/aseelmal/public_html/catalog/controller/payment/ccnow.php on line 125
2014-03-27 8:11:26 - PHP Notice: Undefined index: x_timestamp in /home/aseelmal/public_html/catalog/controller/payment/ccnow.php on line 126
thanks in advance
Code: Select all
<?php
class ControllerPaymentCcnow extends Controller {
protected function index() {
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$this->data['action'] = 'https://www.ccnow.com/cgi-local/transact.cgi';
$totalissimo = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
$sequence = rand(1, 1000);
$fp_arg_list = 'x_login^x_fp_arg_list^x_fp_sequence^x_amount^x_currency_code';
//fingerprint
$fingerprint = md5($this->config->get('ccnow_account') . '^' . $fp_arg_list . '^' . $sequence . '^' . $totalissimo . '^' . $order_info['currency_code'] . '^' . $this->config->get('ccnow_activate'));
$this->data['x_login'] = $this->config->get('ccnow_account');
$this->data['x_method'] = $this->config->get('ccnow_method');
$this->data['x_version'] = '1.0';
$this->data['x_fp_sequence'] = $sequence;
$this->data['x_fp_arg_list'] = $fp_arg_list;
$this->data['x_fp_hash'] = $fingerprint;
$this->data['x_amount'] = $totalissimo;
$this->data['x_currency_code'] = $order_info['currency_code'];
$this->data['x_invoice_num'] = $this->session->data['order_id'];
$this->data['x_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
$this->data['x_company'] = $order_info['payment_company'];
$this->data['x_address'] = $order_info['payment_address_1'];
$this->data['x_address2'] = $order_info['payment_address_2'];
$this->data['x_city'] = $order_info['payment_city'];
$this->data['x_instructions'] = $order_info['comment'];
if ($order_info['payment_iso_code_2'] == 'US' || $order_info['payment_iso_code_2'] == 'CA') {
$this->data['x_state'] = $order_info['payment_zone'];
} else {
$this->data['x_state'] = 'XX';
}
$this->data['x_zip'] = $order_info['payment_postcode'];
$this->data['x_country'] = $order_info['payment_country'];
$this->data['x_email'] = $order_info['email'];
$this->data['x_phone'] = $order_info['telephone'];
if ($this->cart->hasShipping()) {
$this->data['x_ship_to_name'] = $order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname'];
$this->data['x_ship_to_address'] = $order_info['shipping_address_1'];
$this->data['x_ship_to_address2'] = $order_info['shipping_address_2'];
$this->data['x_ship_to_city'] = $order_info['shipping_city'];
$this->data['x_ship_to_state'] = $order_info['shipping_zone'];
$this->data['x_ship_to_zip'] = $order_info['shipping_postcode'];
$this->data['x_ship_to_country'] = $order_info['shipping_country'];
$this->data['x_ship_to_company'] = $order_info['shipping_company'];
$this->data['x_ship_to_phone'] = $order_info['telephone'];
} else {
$this->data['x_ship_to_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
$this->data['x_ship_to_address'] = $order_info['payment_address_1'];
$this->data['x_ship_to_address'] = $order_info['payment_address_2'];
$this->data['x_ship_to_city'] = $order_info['payment_city'];
$this->data['x_ship_to_state'] = $order_info['payment_zone'];
$this->data['x_ship_to_zip'] = $order_info['payment_postcode'];
$this->data['x_ship_to_country'] = $order_info['payment_country'];
$this->data['x_ship_to_company'] = $order_info['payment_company'];
$this->data['x_ship_to_phone'] = $order_info['telephone'];
}
$this->data['products'] = array();
$products = $this->cart->getProducts();
$key = 1;
foreach ($products as $product) {
$this->data['products'][] = array(
'x_product_sku_' . $key => $product['product_id'],
'x_product_title_' . $key => $product['name'],
'x_product_unitprice_' . $key => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value'], false),
'x_product_quantity_' . $key => $product['quantity'],
'x_product_url_' . $key => $order_info['store_url'] . 'index.php?route=product/product&product_id=' . $product['product_id']
);
$key++;
}
$order_shipping = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "order_total` WHERE `order_id` = " . $this->session->data['order_id'] . " AND `code` = 'shipping';");
$this->data['x_shipping_amount'] = $this->currency->format($order_shipping->row['value'], $order_info['currency_code'], $order_info['currency_value'], false);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/ccnow.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/ccnow.tpl';
} else {
$this->template = 'default/template/payment/ccnow.tpl';
}
$this->render();
}
public function callback() {
if($_REQUEST['x_storeid'] == 'test') {
echo 'ok';
// send email to system admin regarding activation key, using plain PHP
$to = $this->config->get('config_email');
$subject = 'Activation code from CCNow';
$message = '12 digit activation code: ' . $_REQUEST['x_orderid'];
$headers = 'From: no-reply@' . $_SERVER['HTTP_HOST'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
echo 'ok';
$this->load->model('checkout/order');
$vars = $this->request->post;
$order_info = $this->model_checkout_order->getOrder($vars['x_invoice_num']);
$hash_key = $this->config->get('ccnow_hash');
$order_number = $vars['x_orderid'];
//security checks
$key = $vars['x_fp_hash'];
$check = md5($vars['x_orderid'] . '^' . $vars['x_status'] . '^' . $vars['x_timestamp'] . '^' . $hash_key);
if ($key == $check) {
if ($this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) == $this->request->post['x_amount']) {
$this->model_checkout_order->confirm($vars['x_invoice_num'], $this->config->get('ccnow_order_status_id'), '', true);
} else {
$this->model_checkout_order->confirm($vars['x_invoice_num'], $this->config->get('config_order_status_id'), '', true);
}
echo 'ok';
echo '<html>' . "\n";
echo '<head>' . "\n";
echo ' <meta http-equiv="Refresh" content="0; url=' . $this->url->link('checkout/success') . '">' . "\n";
echo '</head>'. "\n";
echo '<body>' . "\n";
echo ' <p>Please follow <a href="' . $this->url->link('checkout/success') . '">link</a>!</p>' . "\n";
echo '</body>' . "\n";
echo '</html>' . "\n";
exit();
} else {
echo 'The response from CCNow.com can\'t be parsed. Please contact the site administrator.';
}
}
}
?>