예제 #1
0
function submit_order($values)
{
    if (!(isset($values['user_id']) && isset($values['token']))) {
        throw new Exception('user_id and token required');
    }
    if (FALSE === VerifyToken($values['token'], $values['user_id'], NULL)) {
        throw new Exception('Your session has expired.  Please log in again.');
    }
    //set up all data to be passed to add_order()
    $userInfo = get_users(array('id' => $values['user_id']));
    $email = isset($values['email']) ? $values['email'] : $userInfo['email'];
    $dbh = new PDOConnection();
    $order = get_cart_information($dbh, $values);
    //TODO : customer_id
    $billing_addresses = get_addresses(array('user_id' => $values['user_id'], 'customer_id' => -1, 'type' => ADDRESS_TYPE_BILL));
    $order['billing_address_id'] = isset($billing_addresses[0]['address_id']) ? $billing_addresses[0]['address_id'] : $order['shipping_address_id'];
    $orderInfo = add_order($order);
    order_confirmation_email(array_merge($orderInfo, array('email' => $email)));
    //delete cart
    delete_cart_by_user_id($dbh, $values['user_id']);
    return $orderInfo;
}
예제 #2
0
function draw()
{
    global $_CONF, $_TABLES, $LANG_ECOM;
    $display = "";
    $cart = get_cart_information();
    $sales_tax = $_SESSION['orderAmount'] - ($cart['total'] + $_SESSION['shipping_price']);
    $T = new Template($_CONF['path'] . 'plugins/ecommerce/templates/payment_processor');
    $T->set_file(array('cybersource_receipt' => 'cybersource_receipt.thtml', 'cybersource_receipt_cart_row' => 'cybersource_receipt_cart_row.thtml'));
    $T->set_var('order_number', $_SESSION['orderNumber']);
    $T->set_var('b_first_name', $_SESSION['billTo_firstName']);
    $T->set_var('b_last_name', $_SESSION['billTo_lastName']);
    $T->set_var('b_address_line_1', $_SESSION['billTo_street1']);
    $T->set_var('b_city', $_SESSION['billTo_city']);
    $T->set_var('b_state', $_SESSION['billTo_state']);
    $T->set_var('b_zip', $_SESSION['billTo_postalCode']);
    $T->set_var('b_country', strtoupper($_SESSION['billTo_country']));
    $T->set_var('s_full_name', $_SESSION['full_name']);
    $T->set_var('s_address_line_1', $_SESSION['address_line1']);
    $T->set_var('s_address_line_2', $_SESSION['address_line2']);
    $T->set_var('s_city', $_SESSION['city']);
    $T->set_var('s_state', $_SESSION['state']);
    $T->set_var('s_zip', $_SESSION['zip']);
    $T->set_var('s_country', strtoupper($_SESSION['country']));
    $T->set_var('msg_193', $LANG_ECOM[193]);
    $T->set_var('msg_194', $LANG_ECOM[194]);
    $T->set_var('msg_195', $LANG_ECOM[195]);
    #######
    foreach ($cart['items'] as $item) {
        $total = $item['price'] * $item['quantity'];
        $T->set_var('name', $item['name']);
        $T->set_var('price', number_format($item['price'], 2));
        $T->set_var('quantity', $item['quantity']);
        $T->set_var('item_total', number_format($total, 2));
        $T->parse('cybersource_receipt_cart_row', 'cybersource_receipt_cart_row');
    }
    $T->set_var('sub_total', number_format($cart['total'], 2));
    $T->set_var('shipping_details', $_SESSION['shipping_description']);
    $T->set_var('shipping_total', number_format($_SESSION['shipping_price'], 2));
    $T->set_var('sales_tax', number_format($sales_tax, 2));
    $T->set_var('grand_total', number_format($_SESSION['orderAmount'], 2));
    $T->set_var('b_email_address', $_SESSION['billTo_email']);
    //If Credit Card
    if ($_SESSION['card_accountNumber'] != "") {
        $T->set_var('credit_card', true);
        $T->set_var('card_number', $_SESSION['card_accountNumber']);
        $T->set_var('card_exp_month', $_SESSION['card_expirationMonth']);
        $T->set_var('card_exp_year', $_SESSION['card_expirationYear']);
    } else {
        $T->set_var('credit_card', false);
        //Fill in check fields as needed
    }
    $T->set_var('msg_38', $LANG_ECOM[38]);
    $T->set_var('msg_163', $LANG_ECOM[163]);
    $T->set_var('msg_180', $LANG_ECOM[180]);
    $T->set_var('msg_183', $LANG_ECOM[183]);
    $T->set_var('msg_184', $LANG_ECOM[184]);
    $T->set_var('msg_196', $LANG_ECOM[196]);
    $T->set_var('msg_197', $LANG_ECOM[197]);
    $T->parse('output', 'cybersource_receipt');
    echo $T->finish($T->get_var('output'));
    ####
    //Send email
    $res = DB_query("SELECT email, email_from FROM {$_TABLES['ecom_config']}");
    $row = DB_fetchArray($res);
    $headers = 'MIME-Version: 1.0' . "\r\n";
    //REquired for HTML
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . $row['email_from'] . "\r\n";
    //send receipt to user
    mail($_SESSION['billTo_email'], "Order Number: " . $_SESSION['orderNumber'] . "", $display, $headers);
    //send duplicate receipt to address specified
    mail($row['email'], "Order Number: " . $_SESSION['orderNumber'] . "", $display, $headers);
    //Add transactions to database
    if ($_SESSION['uid'] == 0) {
        $uid = 1;
    } else {
        $uid = $_SESSION['uid'];
    }
    add_transactions($cart['items'], $_SESSION['orderNumber'], $uid, $_SESSION['shipping_price'], $sales_tax);
}
예제 #3
0
$paymentType = urlencode($_SESSION['paymentType']);
$currCodeType = urlencode($_SESSION['currCodeType']);
$payerID = urlencode($_SESSION['payer_id']);
$serverName = urlencode($_SERVER['SERVER_NAME']);
$nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $paymentAmount . '&CURRENCYCODE=' . $currCodeType . '&IPADDRESS=' . $serverName;
//Make the call
$resArray = hash_call("DoExpressCheckoutPayment", $nvpstr);
$ack = strtoupper($resArray["ACK"]);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $resArray;
    $location = "error.php";
    echo "<script>window.location='" . $location . "'</script>";
}
include '../shared_functions.php';
require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php";
$cart = get_cart_information();
$sales_tax = $paymentAmount - ($cart['total'] + $_SESSION['shipping_price']);
$T = new Template($_CONF['path'] . 'plugins/ecommerce/templates/payment_processor');
$T->set_file(array('paypal_receipt' => 'paypal_receipt.thtml', 'paypal_cart_row' => 'paypal_cart_content_row.thtml'));
//get email addres
$email_res = DB_query("SELECT email FROM {$_TABLES['users']} WHERE uid = {$_SESSION['uid']}");
$user_email = DB_fetchArray($email_res);
$T->set_var('order_number', $resArray['TRANSACTIONID']);
$T->set_var('s_full_name', $_SESSION['full_name']);
$T->set_var('s_address_line_1', $_SESSION['address_line1']);
$T->set_var('s_address_line_2', $_SESSION['address_line2']);
$T->set_var('s_city', $_SESSION['city']);
$T->set_var('s_state', $_SESSION['state']);
$T->set_var('s_zip', $_SESSION['zip']);
$T->set_var('s_country', strtoupper($_SESSION['country']));
#######