コード例 #1
0
 public function postProcess()
 {
     $sid = Configuration::get('CHECKOUT_SID');
     $secret_word = Configuration::get('CHECKOUT_SECRET');
     $credit_card_processed = $_REQUEST['credit_card_processed'];
     $order_number = $_REQUEST['order_number'];
     $cart_id = $_REQUEST['merchant_order_id'];
     $cart = new Cart($cart_id);
     $checkout = new checkout();
     if (Configuration::get('CHECKOUT_CURRENCY') > 0) {
         $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
         $currency_from = Currency::getCurrency($cart->id_currency);
         $currency_to = Currency::getCurrency(Configuration::get('CHECKOUT_CURRENCY'));
         $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2);
         $total = number_format(Tools::ps_round($amount *= $currency_to['conversion_rate'], 2), 2, '.', '');
     } else {
         $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
     }
     //Check the hash
     if ($_REQUEST['demo'] == 'Y') {
         $order_number = 1;
     }
     $compare_string = $secret_word . $sid . $order_number . $total;
     $compare_hash1 = strtoupper(md5($compare_string));
     $compare_hash2 = $_REQUEST['key'];
     if ($compare_hash1 == $compare_hash2) {
         $customer = new Customer($cart->id_customer);
         $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
         $checkout->validateOrder($cart_id, _PS_OS_PAYMENT_, $total, $checkout->displayName, '', array(), NULL, false, $customer->secure_key);
         $order = new Order($checkout->currentOrder);
         Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $checkout->currentOrder);
     } else {
         echo 'Hash Mismatch! Please contact the seller directly for assistance.</br>';
         echo 'Total: ' . $total . '</br>';
         echo '2CO Total: ' . $_REQUEST['total'];
     }
 }
コード例 #2
0
if ($cart->id_currency != 2) {
    $total = Tools::convertPrice($total, $cart->id_currency, false);
}
$total = round($total);
$total = number_format($total, 2, '.', '');
//Check the hash
if ($_REQUEST['demo'] == 'Y') {
    $order_number = 1;
}
$compare_string = $secret_word . $sid . $order_number . $total;
$compare_hash1 = strtoupper(md5($compare_string));
$compare_hash2 = $_REQUEST['key'];
if ($compare_hash1 == $compare_hash2) {
    //hash passed, get the cart total for this order
    $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
    $customer = new Customer($cart->id_customer);
    $message = '2Checkout Order Number: ' . $order_number;
    /* Create Necessary variables for order placement */
    $currency = new Currency(intval(isset($_REQUEST['currency_payement']) ? $_REQUEST['currency_payement'] : $cookie->id_currency));
    $checkout = new checkout();
    $checkout->validateOrder($cart_id, _PS_OS_PAYMENT_, $total, $checkout->displayName, $message, array(), NULL, false, $secure_key);
    $order = new Order($checkout->currentOrder);
    /*  Once complete, redirect to order-confirmation.php */
    $url = __PS_BASE_URI__ . "order-confirmation.php?id_cart={$cart_id}&id_module={$checkout->id}&id_order={$checkout->currentOrder}";
    Tools::redirectLink(__PS_BASE_URI__ . "order-confirmation.php?key=" . $customer->secure_key . "&id_cart=" . $cart_id . "&id_module=" . $checkout->id . "&id_order=" . $checkout->currentOrder);
    //echo __PS_BASE_URI__."order-confirmation.php?key=".$customer->secure_key."&id_cart=".$cart_id."&id_module=".$checkout->id."&id_order=".$checkout->currentOrder;
    //echo '<script type="text/javascript">location.replace("'.$url.'")</script>';
} else {
    $smarty->display('failure.tpl');
    include dirname(__FILE__) . '/../../footer.php';
}