/**
  * ExpressCheckout Shortcut Callback
  *
  * @return int
  */
 public function callback_shortcut_process()
 {
     if (!isset($_GET['payment_gateway'])) {
         return;
     }
     $payment_gateway = $_GET['payment_gateway'];
     global $wpsc_cart;
     //	Create a new PurchaseLog Object
     $purchase_log = new WPSC_Purchase_Log();
     // Create a Sessionid
     $sessionid = mt_rand(100, 999) . time();
     wpsc_update_customer_meta('checkout_session_id', $sessionid);
     $purchase_log->set(array('user_ID' => get_current_user_id(), 'date' => time(), 'plugin_version' => WPSC_VERSION, 'statusno' => '0', 'sessionid' => $sessionid));
     if (wpsc_is_tax_included()) {
         $tax = $wpsc_cart->calculate_total_tax();
         $tax_percentage = $wpsc_cart->tax_percentage;
     } else {
         $tax = 0;
         $tax_percentage = 0;
     }
     $purchase_log->set(array('wpec_taxes_total' => $tax, 'wpec_taxes_rate' => $tax_percentage));
     // Save the purchase_log object to generate it's id
     $purchase_log->save();
     $purchase_log_id = $purchase_log->get('id');
     $wpsc_cart->log_id = $purchase_log_id;
     wpsc_update_customer_meta('current_purchase_log_id', $purchase_log_id);
     $purchase_log->set(array('gateway' => $payment_gateway, 'base_shipping' => $wpsc_cart->calculate_base_shipping(), 'totalprice' => $wpsc_cart->calculate_total_price()));
     $purchase_log->save();
     $wpsc_cart->empty_db($purchase_log_id);
     $wpsc_cart->save_to_db($purchase_log_id);
     $wpsc_cart->submit_stock_claims($purchase_log_id);
     // Save an empty Form
     $form = WPSC_Checkout_Form::get();
     $fields = $form->get_fields();
     WPSC_Checkout_Form_Data::save_form($purchase_log, $fields);
     // Return Customer to Review Order Page if there is Shipping
     add_filter('wpsc_paypal_express_checkout_transact_url', array(&$this, 'review_order_url'));
     add_filter('wpsc_paypal_express_checkout_return_url', array(&$this, 'review_order_callback'));
     // Set a Temporary Option for EC Shortcut
     wpsc_update_customer_meta('esc-' . $sessionid, true);
     // Apply Checkout Actions
     do_action('wpsc_submit_checkout', array('purchase_log_id' => $purchase_log_id, 'our_user_id' => get_current_user_id()));
     do_action('wpsc_submit_checkout_gateway', $payment_gateway, $purchase_log);
     return $sessionid;
 }
Exemplo n.º 2
0
 private function get_shipping_method_js_vars()
 {
     global $wpsc_cart;
     $js_var = array('subtotal' => (double) $wpsc_cart->calculate_subtotal(), 'shipping' => array(), 'tax' => wpsc_is_tax_enabled() && !wpsc_is_tax_included() ? (double) wpsc_cart_tax(false) : 0, 'discount' => wpsc_coupon_amount(false) > 0 ? wpsc_coupon_amount(false) : 0);
     foreach ($this->shipping_calculator->sorted_quotes as $module_name => $quotes) {
         foreach ($quotes as $option => $cost) {
             $id = $this->shipping_calculator->ids[$module_name][$option];
             $js_var['shipping'][$id] = $cost;
         }
     }
     $currency = new WPSC_Country(get_option('currency_type'));
     $currency_code = $currency->get_currency_code();
     $isocode = $currency->get_isocode();
     $without_fractions = in_array($currency_code, WPSC_Payment_Gateways::currencies_without_fractions());
     $decimals = $without_fractions ? 0 : 2;
     $decimals = apply_filters('wpsc_modify_decimals', $decimals, $isocode);
     $decimal_separator = apply_filters('wpsc_format_currency_decimal_separator', wpsc_get_option('decimal_separator'), $isocode);
     $thousands_separator = apply_filters('wpsc_format_currency_thousands_separator', wpsc_get_option('thousands_separator'), $isocode);
     $symbol = apply_filters('wpsc_format_currency_currency_symbol', $currency->get_currency_symbol());
     $sign_location = get_option('currency_sign_location');
     $js_var['formatter'] = array('currency_code' => $currency_code, 'without_fractions' => $without_fractions, 'decimals' => $decimals, 'decimal_separator' => $decimal_separator, 'thousands_separator' => $thousands_separator, 'symbol' => $symbol, 'sign_location' => $sign_location);
     return $js_var;
 }
Exemplo n.º 3
0
		<tr <?php 
    $this->show_tax_style();
    ?>
 class="wpsc-cart-aggregate wpsc-cart-tax-row">
			<th scope="row" colspan="<?php 
    echo count($this->columns) - 1;
    ?>
">
				<?php 
    esc_html_e('Tax:', 'wpsc');
    ?>
<br />
			</th>
			<td>
<?php 
    if (wpsc_is_tax_included()) {
        ?>
				<span class="wpsc-tax-included"><?php 
        echo _x('(included)', 'tax is included in product prices', 'wpsc');
        ?>
</span>
<?php 
    } else {
        echo esc_html(wpsc_format_currency($this->get_tax()));
    }
    ?>
			</td>
		</tr>
<?php 
}
?>