コード例 #1
0
 /**
  * construct value array method, converts the data gathered by the base class code to something acceptable to the gateway
  * @access public
  */
 function construct_value_array()
 {
     //$collected_gateway_data
     $paypal_vars = array();
     // Store settings to be sent to paypal
     $data = array();
     $data['USER'] = get_option('paypal_pro_username');
     $data['PWD'] = get_option('paypal_pro_password');
     $data['SIGNATURE'] = get_option('paypal_pro_signature');
     $data['VERSION'] = "52.0";
     $data['METHOD'] = "DoDirectPayment";
     $data['PAYMENTACTION'] = "Sale";
     $data['RETURNFMFDETAILS'] = "1";
     // optional - return fraud management filter data
     $data['CURRENCYCODE'] = $this->get_paypal_currency_code();
     // Basic Cart Data
     $data['INVNUM'] = $this->cart_data['session_id'];
     $data['NOTIFYURL'] = add_query_arg('gateway', 'wpsc_merchant_paypal_pro', $this->cart_data['notification_url']);
     $data['IPADDRESS'] = $_SERVER["REMOTE_ADDR"];
     if ($this->cart_data['billing_address']['country'] == 'UK') {
         $this->cart_data['billing_address']['country'] = 'GB';
     }
     // Billing Data
     $data['FIRSTNAME'] = $this->cart_data['billing_address']['first_name'];
     $data['LASTNAME'] = $this->cart_data['billing_address']['last_name'];
     $data['EMAIL'] = $this->cart_data['email_address'];
     $data['STREET'] = $this->cart_data['billing_address']['address'];
     $data['CITY'] = $this->cart_data['billing_address']['city'];
     $data['STATE'] = $this->cart_data['billing_address']['state'];
     $data['COUNTRYCODE'] = $this->cart_data['billing_address']['country'];
     $data['ZIP'] = $this->cart_data['billing_address']['post_code'];
     // Shipping Data
     $data['SHIPTONAME'] = $this->cart_data['shipping_address']['first_name'] . " " . $this->cart_data['shipping_address']['last_name'];
     $data['SHIPTOSTREET'] = $this->cart_data['shipping_address']['address'];
     $data['SHIPTOCITY'] = $this->cart_data['shipping_address']['city'];
     // Check the state for internal numeric ID and trap it
     if (is_numeric($this->cart_data['shipping_address']['state'])) {
         $this->cart_data['shipping_address']['state'] = wpsc_get_state_by_id($this->cart_data['shipping_address']['state'], 'code');
     }
     if ($this->cart_data['shipping_address']['country'] == 'UK') {
         $this->cart_data['shipping_address']['country'] = 'GB';
     }
     $data['SHIPTOSTATE'] = $this->cart_data['shipping_address']['state'];
     $data['SHIPTOCOUNTRY'] = $this->cart_data['shipping_address']['country'];
     $data['SHIPTOZIP'] = $this->cart_data['shipping_address']['post_code'];
     // Credit Card Data
     $data['CREDITCARDTYPE'] = $_POST['cctype'];
     $data['ACCT'] = str_replace(array(' ', '-'), '', $_POST['card_number']);
     $data['EXPDATE'] = $_POST['expiry']['month'] . $_POST['expiry']['year'];
     $data['CVV2'] = $_POST['card_code'];
     // Ordered Items
     // Cart Item Data
     $i = $item_total = 0;
     $tax_total = wpsc_tax_isincluded() ? 0 : $this->cart_data['cart_tax'];
     $shipping_total = $this->convert($this->cart_data['base_shipping']);
     foreach ($this->cart_items as $cart_row) {
         $data['L_NAME' . $i] = apply_filters('the_title', $cart_row['name']);
         $data['L_AMT' . $i] = $this->convert($cart_row['price']);
         $data['L_NUMBER' . $i] = $i;
         $data['L_QTY' . $i] = $cart_row['quantity'];
         $shipping_total += $this->convert($cart_row['shipping']);
         $item_total += $this->convert($cart_row['price']) * $cart_row['quantity'];
         $i++;
     }
     if ($this->cart_data['has_discounts']) {
         $discount_value = $this->convert($this->cart_data['cart_discount_value']);
         $coupon = new wpsc_coupons($this->cart_data['cart_discount_data']);
         // free shipping
         if ($coupon->is_percentage()) {
             $shipping_total = 0;
             $discount_value = 0;
         } elseif ($discount_value >= $item_total) {
             $discount_value = $item_total - 0.01;
             $shipping_total -= 0.01;
         }
         $data["L_NAME{$i}"] = _x('Coupon / Discount', 'PayPal Pro Item Name for Discounts', 'wp-e-commerce');
         $data["L_AMT{$i}"] = -$discount_value;
         $data["L_NUMBER{$i}"] = $i;
         $data["L_QTY{$i}"] = 1;
         $item_total -= $discount_value;
     }
     // Cart totals
     $data['ITEMAMT'] = $this->format_price($item_total);
     $data['SHIPPINGAMT'] = $this->format_price($shipping_total);
     $data['TAXAMT'] = $this->convert($tax_total);
     $data['AMT'] = $data['ITEMAMT'] + $data['SHIPPINGAMT'] + $data['TAXAMT'];
     $data = apply_filters('wpsc_paypal_pro_gateway_data_array', $data, $this->cart_items);
     $data['BUTTONSOURCE'] = 'WPeC_Cart_WPP';
     $this->collected_gateway_data = $data;
 }
コード例 #2
0
ファイル: cart.class.php プロジェクト: dreamteam111/dreamteam
 /**
  * update_shipping method, updates the shipping
  * @access public
  */
 function update_shipping($method, $option)
 {
     global $wpdb, $wpsc_shipping_modules;
     if (!empty($method)) {
         $this->selected_shipping_method = $method;
     }
     if (!empty($option)) {
         $this->selected_shipping_option = $option;
     }
     $this->get_shipping_quotes();
     // reapply coupon in case it's free shipping
     if ($this->coupons_name) {
         $coupon = new wpsc_coupons($this->coupons_name);
         if ($coupon->is_free_shipping()) {
             $this->apply_coupons($coupon->calculate_discount(), $this->coupons_name);
         }
     }
 }
コード例 #3
0
ファイル: ajax.functions.php プロジェクト: alx/SBek-Arak
/**
	* coupons price, used through ajax and in normal page loading.
	* No parameters, returns nothing
*/
function wpsc_coupon_price($currCoupon = '')
{
    global $wpdb, $wpsc_cart, $wpsc_coupons;
    if (isset($_POST['coupon_num']) && $_POST['coupon_num'] != '') {
        $coupon = $wpdb->escape($_POST['coupon_num']);
        $_SESSION['coupon_numbers'] = $coupon;
        $wpsc_coupons = new wpsc_coupons($coupon);
        if ($wpsc_coupons->validate_coupon()) {
            $discountAmount = $wpsc_coupons->calculate_discount();
            $wpsc_cart->apply_coupons($discountAmount, $coupon);
            $wpsc_coupons->errormsg = false;
        } else {
            $wpsc_coupons->errormsg = true;
            $wpsc_cart->coupons_amount = 0;
            $wpsc_cart->coupons_name = '';
        }
    } else {
        if ($_POST['coupon_num'] == '' && $currCoupon == '') {
            $wpsc_cart->coupons_amount = 0;
            $wpsc_cart->coupons_name = '';
        } else {
            if ($currCoupon != '') {
                $coupon = $wpdb->escape($currCoupon);
                $_SESSION['coupon_numbers'] = $coupon;
                $wpsc_coupons = new wpsc_coupons($coupon);
                if ($wpsc_coupons->validate_coupon()) {
                    $discountAmount = $wpsc_coupons->calculate_discount();
                    $wpsc_cart->apply_coupons($discountAmount, $coupon);
                    $wpsc_coupons->errormsg = false;
                }
            }
        }
    }
}
コード例 #4
0
 function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL)
 {
     global $wpdb;
     $nvpstr = '';
     $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
     $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
     $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
     $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
     $data = array();
     if (!isset($this->cart_data['shipping_address']['first_name']) && !isset($this->cart_data['shipping_address']['last_name'])) {
         $this->cart_data['shipping_address']['first_name'] = $this->cart_data['billing_address']['first_name'];
         $this->cart_data['shipping_address']['last_name'] = $this->cart_data['billing_address']['last_name'];
     }
     if ($this->cart_data['shipping_address']['country'] == 'UK') {
         $this->cart_data['shipping_address']['country'] = 'GB';
     }
     $data += array('PAYMENTREQUEST_0_SHIPTONAME' => $this->cart_data['shipping_address']['first_name'] . ' ' . $this->cart_data['shipping_address']['last_name'], 'PAYMENTREQUEST_0_SHIPTOSTREET' => $this->cart_data['shipping_address']['address'], 'PAYMENTREQUEST_0_SHIPTOCITY' => $this->cart_data['shipping_address']['city'], 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => $this->cart_data['shipping_address']['country'], 'PAYMENTREQUEST_0_SHIPTOZIP' => $this->cart_data['shipping_address']['post_code']);
     if (!empty($this->cart_data['shipping_address']['state'])) {
         $data += array('PAYMENTREQUEST_0_SHIPTOSTATE' => $this->cart_data['shipping_address']['state']);
     }
     $i = 0;
     $item_total = 0;
     $tax_total = 0;
     $shipping_total = 0;
     $is_free_shipping = false;
     if ($this->cart_data['has_discounts'] && (double) $this->cart_data['cart_discount_value'] > 0) {
         $coupon = new wpsc_coupons($this->cart_data['cart_discount_coupon']);
         $is_free_shipping = $coupon->is_free_shipping();
     }
     foreach ($this->cart_items as $cart_item) {
         $data["L_PAYMENTREQUEST_0_NAME{$i}"] = urlencode(apply_filters('the_title', $cart_item['name']));
         $data["L_PAYMENTREQUEST_0_AMT{$i}"] = $this->convert($cart_item['price']);
         $data["L_PAYMENTREQUEST_0_NUMBER{$i}"] = $i;
         $data["L_PAYMENTREQUEST_0_QTY{$i}"] = $cart_item['quantity'];
         $item_total += $this->convert($cart_item['price']) * $cart_item['quantity'];
         $shipping_total += $cart_item['shipping'];
         $i++;
     }
     //if we have a discount then include a negative amount with that discount
     // in php 0.00 = true so we will change that here
     if ($this->cart_data['cart_discount_value'] == 0.0) {
         $this->cart_data['cart_discount_value'] = 0;
     }
     $discount_value = $this->convert($this->cart_data['cart_discount_value']);
     if ($this->cart_data['cart_discount_value'] && !$is_free_shipping) {
         // if item total < discount amount, leave at least 0.01 unit in item total, then subtract
         // 0.01 from shipping as well
         if (!$is_free_shipping && $discount_value >= $item_total) {
             $discount_value = $item_total - 0.01;
             $shipping_total -= 0.01;
         }
         $item_total -= $discount_value;
         $data["L_PAYMENTREQUEST_0_NAME{$i}"] = "Discount / Coupon";
         $data["L_PAYMENTREQUEST_0_AMT{$i}"] = -$discount_value;
         $data["L_PAYMENTREQUEST_0_NUMBER{$i}"] = $i;
         $data["L_PAYMENTREQUEST_0_QTY{$i}"] = 1;
     }
     $data["PAYMENTREQUEST_0_ITEMAMT"] = $this->format_price($item_total);
     if ($discount_value && $is_free_shipping) {
         $data["PAYMENTREQUEST_0_SHIPPINGAMT"] = 0;
     } else {
         $data["PAYMENTREQUEST_0_SHIPPINGAMT"] = $this->convert($this->cart_data['base_shipping'] + $shipping_total);
     }
     $total = $data["PAYMENTREQUEST_0_ITEMAMT"] + $data["PAYMENTREQUEST_0_SHIPPINGAMT"];
     if (!wpsc_tax_isincluded()) {
         $data["PAYMENTREQUEST_0_TAXAMT"] = $this->convert($this->cart_data['cart_tax']);
         $total += $data["PAYMENTREQUEST_0_TAXAMT"];
     }
     // adjust total amount in case we had to round up after converting currency
     // or discount calculation
     if ($total != $paymentAmount) {
         $paymentAmount = $total;
     }
     $data["PAYMENTREQUEST_0_AMT"] = $paymentAmount;
     if (count($data) >= 4) {
         $temp_data = array();
         foreach ($data as $key => $value) {
             $temp_data[] = $key . "=" . $value;
         }
         $nvpstr = $nvpstr . "&" . implode("&", $temp_data);
     }
     wpsc_update_customer_meta('paypal_express_currency_code_type', $currencyCodeType);
     wpsc_update_customer_meta('paypal_express_payment_type', $paymentType);
     $resArray = paypal_hash_call("SetExpressCheckout", $nvpstr);
     $ack = strtoupper($resArray["ACK"]);
     if ($ack == "SUCCESS") {
         $token = urldecode($resArray["TOKEN"]);
         wpsc_update_customer_meta('paypal_express_token', $token);
     }
     return $resArray;
 }
コード例 #5
0
ファイル: cart.class.php プロジェクト: pankajsinghjarial/SYLC
 /**
  * update_shipping method, updates the shipping
  * @access public
  */
 function update_shipping($method, $option)
 {
     global $wpdb, $wpsc_shipping_modules;
     $this->selected_shipping_method = $method;
     $this->shipping_quotes = $wpsc_shipping_modules[$method]->getQuote();
     $this->selected_shipping_option = $option;
     foreach ($this->cart_items as $key => $cart_item) {
         $this->cart_items[$key]->calculate_shipping();
     }
     $this->clear_cache();
     $this->get_shipping_option();
     // reapply coupon in case it's free shipping
     if ($this->coupons_name) {
         $coupon = new wpsc_coupons($this->coupons_name);
         if ($coupon->is_free_shipping()) {
             $this->apply_coupons($coupon->calculate_discount(), $this->coupons_name);
         }
     }
 }
コード例 #6
0
/**
 * coupons price, used through ajax and in normal page loading.
 * No parameters, returns nothing
 */
function wpsc_coupon_price($currCoupon = '')
{
    global $wpsc_cart, $wpsc_coupons;
    if (isset($_POST['coupon_num']) && $_POST['coupon_num'] != '') {
        $coupon = esc_sql($_POST['coupon_num']);
        wpsc_update_customer_meta('coupon', $coupon);
        $wpsc_coupons = new wpsc_coupons($coupon);
        if ($wpsc_coupons->validate_coupon()) {
            $discountAmount = $wpsc_coupons->calculate_discount();
            $wpsc_cart->apply_coupons($discountAmount, $coupon);
            $wpsc_coupons->errormsg = false;
        } else {
            $wpsc_coupons->errormsg = true;
            $wpsc_cart->coupons_amount = 0;
            $wpsc_cart->coupons_name = '';
            wpsc_delete_customer_meta('coupon');
        }
    } else {
        if ((!isset($_POST['coupon_num']) || $_POST['coupon_num'] == '') && $currCoupon == '') {
            $wpsc_cart->coupons_amount = 0;
            $wpsc_cart->coupons_name = '';
        } else {
            if ($currCoupon != '') {
                $coupon = esc_sql($currCoupon);
                wpsc_update_customer_meta('coupon', $coupon);
                $wpsc_coupons = new wpsc_coupons($coupon);
                if ($wpsc_coupons->validate_coupon()) {
                    $discountAmount = $wpsc_coupons->calculate_discount();
                    $wpsc_cart->apply_coupons($discountAmount, $coupon);
                    $wpsc_coupons->errormsg = false;
                }
            }
        }
    }
}
コード例 #7
0
 /**
  * @description: wpec_taxes_calculate_total - takes into account all tax logic
  *                   settings and returns the calculated total tax.
  *                   Expects wpsc_cart to be set.
  *
  * @param: void
  * @return: array containing total tax and rate if applicable
  * */
 function wpec_taxes_calculate_total()
 {
     //get the cart - NOTE: billing country is selected_country and shipping country is delivery_country
     global $wpsc_cart;
     //initialize return variable
     $returnable = array('total' => 0, 'rate' => 0);
     //check if tax is enabled
     if ($this->wpec_taxes->wpec_taxes_get_enabled()) {
         //run tax logic and calculate tax
         if ($this->wpec_taxes_run_logic()) {
             //get selected country code
             $wpec_selected_country = $this->wpec_taxes_retrieve_selected_country();
             //set tax region
             $region = $this->wpec_taxes_retrieve_region();
             //get the rate for the country and region if set
             $tax_rate = $this->wpec_taxes->wpec_taxes_get_rate($wpec_selected_country, $region);
             //start the total_tax off at 0
             $total_tax = 0;
             foreach ($wpsc_cart->cart_items as $cart_item) {
                 //if the tax is inclusive calculate vat
                 if ($this->wpec_taxes_isincluded()) {
                     //run wpec_taxes_calculate_included_tax
                     $taxes = $this->wpec_taxes_calculate_included_tax($cart_item);
                     $total_tax += $taxes['tax'];
                 } else {
                     //run wpec_taxes_calculate_excluded_tax
                     $taxes = $this->wpec_taxes_calculate_excluded_tax($cart_item, $tax_rate);
                     $total_tax += $taxes['tax'];
                 }
                 // if
             }
             // foreach
             $free_shipping = false;
             $coupon_num = wpsc_get_customer_meta('coupon');
             if ($coupon_num) {
                 $coupons = new wpsc_coupons($coupon_num);
                 $free_shipping = $coupons->is_free_shipping();
             }
             // minus coupon tax if we are using coupons, but make sure the coupon is not a free shipping coupon
             /* Iterative note: In a future implementation, we'll allow for coupons to either apply to taxes, or not */
             /* The default logic to date has been that they do, which is generally improper, and there's a logic bug here as well */
             /* @link: https://github.com/wp-e-commerce/WP-e-Commerce/issues/170 */
             if ($wpsc_cart->coupons_amount > 0 && !$free_shipping) {
                 if ($this->wpec_taxes_isincluded()) {
                     $coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate'], false);
                 } else {
                     $coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate']);
                 }
                 /* Only subtract if coupons apply to tax.  Likely in 4.0 */
                 /* $total_tax -= $coupon_tax; */
             }
             //add shipping tax if set
             if ($tax_rate['shipping'] && !$free_shipping) {
                 if ($this->wpec_taxes_isincluded()) {
                     $total_tax += $this->wpec_taxes_calculate_tax($wpsc_cart->calculate_total_shipping(), $tax_rate['rate'], false);
                 } else {
                     $total_tax += $this->wpec_taxes_calculate_tax($wpsc_cart->calculate_total_shipping(), $tax_rate['rate']);
                 }
             }
             // if
             $returnable = array('total' => $total_tax);
             if (!$this->wpec_taxes_isincluded() && isset($tax_rate['rate'])) {
                 $returnable['rate'] = $tax_rate['rate'];
             }
             // if
         }
         // if
     }
     //if
     return $returnable;
 }
コード例 #8
0
 /**
  * construct value array method, converts the data gathered by the base class code to something acceptable to the gateway
  * @access private
  * @param boolean $aggregate Whether to aggregate the cart data or not. Defaults to false.
  * @return array $paypal_vars The paypal vars
  */
 function _construct_value_array($aggregate = false)
 {
     global $wpdb, $wpsc_cart;
     $paypal_vars = array();
     $add_tax = !wpsc_tax_isincluded();
     $buy_now = defined('WPSC_PAYPAL_BUY_NOW') && WPSC_PAYPAL_BUY_NOW;
     $return_url = add_query_arg('sessionid', $this->cart_data['session_id'], $this->cart_data['transaction_results_url']);
     if ($buy_now) {
         $return_url = add_query_arg('wpsc_buy_now_return', 1, $return_url);
     }
     // Store settings to be sent to paypal
     $paypal_vars += array('business' => get_option('paypal_multiple_business'), 'return' => $return_url, 'cancel_return' => $this->cart_data['transaction_results_url'], 'rm' => '2', 'currency_code' => $this->get_paypal_currency_code(), 'lc' => $this->cart_data['store_currency'], 'no_note' => '1', 'charset' => 'utf-8');
     // IPN data
     if (get_option('paypal_ipn') == 1) {
         $notify_url = $this->cart_data['notification_url'];
         $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $notify_url);
         $notify_url = apply_filters('wpsc_paypal_standard_notify_url', $notify_url);
         $paypal_vars += array('notify_url' => $notify_url);
     }
     // Customer details
     $paypal_vars += array('email' => $this->cart_data['email_address'], 'first_name' => $this->cart_data['billing_address']['first_name'], 'last_name' => $this->cart_data['billing_address']['last_name'], 'address1' => $this->cart_data['billing_address']['address'], 'city' => $this->cart_data['billing_address']['city'], 'state' => isset($this->cart_data['billing_address']['state']) ? $this->cart_data['billing_address']['state'] : '', 'zip' => $this->cart_data['billing_address']['post_code'], 'country' => isset($this->cart_data['billing_address']['country']) ? $this->cart_data['billing_address']['country'] : '');
     // Shipping
     if ((bool) get_option('paypal_ship') && !$buy_now) {
         $paypal_vars += array('address_override' => get_option('address_override'), 'no_shipping' => '0');
         if ($paypal_vars['country'] == 'UK') {
             $paypal_vars['country'] = 'GB';
         }
     } else {
         $paypal_vars += array('no_shipping' => '1');
     }
     // Order settings to be sent to paypal
     $paypal_vars += array('invoice' => $this->cart_data['session_id']);
     if ($buy_now) {
         $paypal_vars['custom'] = 'buy_now';
     }
     // Two cases:
     // - We're dealing with a subscription
     // - We're dealing with a normal cart
     if ($this->cart_data['is_subscription']) {
         $paypal_vars += array('cmd' => '_xclick-subscriptions');
         $reprocessed_cart_data['shopping_cart'] = array('is_used' => false, 'price' => 0, 'length' => 1, 'unit' => 'd', 'times_to_rebill' => 1);
         $reprocessed_cart_data['subscription'] = array('is_used' => false, 'price' => 0, 'length' => 1, 'unit' => 'D', 'times_to_rebill' => 1);
         foreach ($this->cart_items as $cart_row) {
             if ($cart_row['is_recurring']) {
                 $reprocessed_cart_data['subscription']['is_used'] = true;
                 $reprocessed_cart_data['subscription']['price'] = $this->convert($cart_row['price']);
                 $reprocessed_cart_data['subscription']['length'] = $cart_row['recurring_data']['rebill_interval']['length'];
                 $reprocessed_cart_data['subscription']['unit'] = strtoupper($cart_row['recurring_data']['rebill_interval']['unit']);
                 $reprocessed_cart_data['subscription']['times_to_rebill'] = $cart_row['recurring_data']['times_to_rebill'];
             } else {
                 $item_cost = ($cart_row['price'] + $cart_row['shipping'] + $cart_row['tax']) * $cart_row['quantity'];
                 if ($item_cost > 0) {
                     $reprocessed_cart_data['shopping_cart']['price'] += $item_cost;
                     $reprocessed_cart_data['shopping_cart']['is_used'] = true;
                 }
             }
             $paypal_vars += array('item_name' => apply_filters('the_title', $cart_row['name']), 'src' => '1');
             // This can be false, we don't need to have additional items in the cart/
             if ($reprocessed_cart_data['shopping_cart']['is_used']) {
                 $paypal_vars += array("a1" => $this->convert($reprocessed_cart_data['shopping_cart']['price']), "p1" => $reprocessed_cart_data['shopping_cart']['length'], "t1" => $reprocessed_cart_data['shopping_cart']['unit']);
             }
             // We need at least one subscription product,
             // If this is not true, something is rather wrong.
             if ($reprocessed_cart_data['subscription']['is_used']) {
                 $paypal_vars += array("a3" => $this->convert($reprocessed_cart_data['subscription']['price']), "p3" => $reprocessed_cart_data['subscription']['length'], "t3" => $reprocessed_cart_data['subscription']['unit']);
                 // If the srt value for the number of times to rebill is not greater than 1,
                 // paypal won't accept the transaction.
                 if ($reprocessed_cart_data['subscription']['times_to_rebill'] > 1) {
                     $paypal_vars += array('srt' => $reprocessed_cart_data['subscription']['times_to_rebill']);
                 }
             }
         }
         // end foreach cart item
     } else {
         if ($buy_now) {
             $paypal_vars['cmd'] = '_xclick';
         } else {
             $paypal_vars += array('upload' => '1', 'cmd' => '_ext-enter', 'redirect_cmd' => '_cart');
         }
         $free_shipping = false;
         $coupon = wpsc_get_customer_meta('coupon');
         if ($coupon) {
             $coupon = new wpsc_coupons($coupon);
             $free_shipping = $coupon->is_free_shipping();
         }
         if ($this->cart_data['has_discounts'] && $free_shipping) {
             $handling = 0;
         } else {
             $handling = $this->cart_data['base_shipping'];
         }
         $tax_total = 0;
         if ($add_tax) {
             $tax_total = $this->cart_data['cart_tax'];
         }
         // Set base shipping
         $paypal_vars += array('handling_cart' => $this->convert($handling));
         // Stick the cart item values together here
         $i = 1;
         if (!$buy_now) {
             if (!$aggregate) {
                 foreach ($this->cart_items as $cart_row) {
                     $item_number = get_post_meta($cart_row['product_id'], '_wpsc_sku', true);
                     if (!$item_number) {
                         $item_number = $cart_row['product_id'];
                     }
                     $paypal_vars += array("item_name_{$i}" => apply_filters('the_title', $cart_row['name']), "amount_{$i}" => $this->convert($cart_row['price']), "quantity_{$i}" => $cart_row['quantity'], "item_number_{$i}" => $item_number);
                     if (!$free_shipping) {
                         $paypal_vars += array("shipping_{$i}" => $this->convert($cart_row['shipping'] / $cart_row['quantity']), "shipping2_{$i}" => $this->convert($cart_row['shipping'] / $cart_row['quantity']), "handling_{$i}" => '');
                     }
                     if ($add_tax && !empty($cart_row['tax'])) {
                         $tax_total += $cart_row['tax'];
                     }
                     ++$i;
                 }
                 if ($this->cart_data['has_discounts'] && !$free_shipping) {
                     $paypal_vars['discount_amount_cart'] = $this->convert($this->cart_data['cart_discount_value']);
                     $subtotal = $wpsc_cart->calculate_subtotal();
                     if ($this->cart_data['cart_discount_value'] >= $wpsc_cart->calculate_subtotal()) {
                         $paypal_vars['discount_amount_cart'] = $this->convert($subtotal) - 0.01;
                         if (!empty($paypal_vars['handling_cart'])) {
                             $paypal_vars['handling_cart'] -= 0.01;
                         }
                     }
                 }
             } else {
                 $paypal_vars['item_name_' . $i] = __("Your Shopping Cart", 'wp-e-commerce');
                 $paypal_vars['amount_' . $i] = $this->convert($this->cart_data['total_price']) - $this->convert($this->cart_data['base_shipping']);
                 $paypal_vars['quantity_' . $i] = 1;
                 $paypal_vars['shipping_' . $i] = 0;
                 $paypal_vars['shipping2_' . $i] = 0;
                 $paypal_vars['handling_' . $i] = 0;
             }
             $paypal_vars['tax_cart'] = $aggregate ? 0 : $this->convert($tax_total);
         } else {
             $cart_row = $this->cart_items[0];
             $item_number = get_post_meta($cart_row['product_id'], '_wpsc_sku', true);
             $paypal_vars += array('item_name' => apply_filters('the_title', $cart_row['name']), 'item_number' => $item_number, 'amount' => $this->convert($cart_row['price']), 'quantity' => $cart_row['quantity'], 'handling' => $this->convert($handling));
         }
     }
     $paypal_vars = apply_filters('wpsc_paypal_standard_post_data', $paypal_vars);
     $paypal_vars['bn'] = 'WPeC_Cart_WPS';
     return $paypal_vars;
 }