Example #1
0
 private function callback_login()
 {
     if (empty($_COOKIE[TEST_COOKIE])) {
         $this->message_collection->add(__("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to log in to your account.", 'wp-e-commerce'), 'error');
     }
     $form_args = wpsc_get_login_form_args();
     $validation = wpsc_validate_form($form_args);
     if (is_wp_error($validation)) {
         wpsc_set_validation_errors($validation);
         return;
     }
     $user = wp_signon(array('user_login' => $_POST['username'], 'user_password' => $_POST['password'], 'rememberme' => !empty($_POST['rememberme'])));
     if (is_wp_error($user)) {
         $this->message_collection->add(__('We do not recognize the login information you entered. Please try again.', 'wp-e-commerce'), 'error');
         return;
     }
     $redirect_to = wp_get_referer();
     if (wpsc_get_customer_meta('checkout_after_login')) {
         $redirect_to = wpsc_get_checkout_url();
         wpsc_delete_customer_meta('checkout_after_login');
     }
     if (!$redirect_to || trim(str_replace(home_url(), '', $redirect_to), '/') == trim($_SERVER['REQUEST_URI'], '/')) {
         $redirect_to = wpsc_get_store_url();
     }
     wp_redirect($redirect_to);
     exit;
 }
 public function get_shopping_cart_payment_url()
 {
     $te = get_option('wpsc_get_active_theme_engine', '1.0');
     return '1.0' !== $te ? wpsc_get_checkout_url('shipping-and-billing') : get_option('shopping_cart_url');
 }
 public function get_shopping_cart_payment_url()
 {
     return _wpsc_maybe_activate_theme_engine_v2() ? wpsc_get_checkout_url('shipping-and-billing') : get_option('shopping_cart_url');
 }
 /**
  * Return Customer to Review Order Page if there are Shipping Costs.
  *
  * @param string $url
  * @return string
  */
 public function review_order_url($url)
 {
     if (wpsc_uses_shipping()) {
         $url = wpsc_get_checkout_url('review-order');
     }
     return $url;
 }
function wpsc_theme_engine_v2_activate()
{
    $path = WPSC_FILE_PATH . '/wpsc-components/theme-engine-v2';
    require_once $path . '/core.php';
    _wpsc_te_v2_includes();
    wpsc_register_post_types();
    flush_rewrite_rules(true);
    update_option('transact_url', wpsc_get_checkout_url('results'));
    WPSC_Settings::get_instance();
    do_action('wpsc_theme_engine_v2_activate');
}
 private function init_checkout_wizard()
 {
     $this->wizard = WPSC_Checkout_Wizard::get_instance();
     $this->wizard->steps = array('shipping-and-billing' => __('Details', 'wp-e-commerce'), 'shipping-method' => __('Delivery', 'wp-e-commerce'), 'payment' => __('Place Order', 'wp-e-commerce'), 'results' => __('Complete', 'wp-e-commerce'));
     if (!wpsc_uses_shipping()) {
         unset($this->wizard->steps['shipping-method']);
     }
     if (is_user_logged_in() && (!array_key_exists($this->wizard->active_step, $this->wizard->steps) || in_array($this->wizard->active_step, $this->wizard->disabled))) {
         wp_redirect(wpsc_get_checkout_url($this->wizard->pending_step));
         exit;
     }
 }
function wpsc_transaction_theme()
{
    global $wpdb, $user_ID, $nzshpcrt_gateways, $sessionid, $cart_log_id, $errorcode;
    $errorcode = '';
    $transactid = '';
    $dont_show_transaction_results = false;
    if (isset($_GET['sessionid'])) {
        $sessionid = $_GET['sessionid'];
    }
    if (!isset($_GET['sessionid']) && isset($_GET['ms'])) {
        $sessionid = $_GET['ms'];
    }
    $selected_gateway = wpsc_get_customer_meta('selected_gateway');
    if ($selected_gateway && in_array($selected_gateway, array('paypal_certified', 'wpsc_merchant_paypal_express'))) {
        $sessionid = wpsc_get_customer_meta('paypal_express_sessionid');
    }
    if (isset($_REQUEST['eway']) && '1' == $_REQUEST['eway']) {
        $sessionid = $_GET['result'];
    } elseif (isset($_REQUEST['eway']) && '0' == $_REQUEST['eway']) {
        echo wpsc_get_customer_meta('eway_message');
    } elseif (isset($_REQUEST['payflow']) && '1' == $_REQUEST['payflow']) {
        echo wpsc_get_customer_meta('payflow_message');
        wpsc_delete_customer_meta('payflow_message');
    }
    $dont_show_transaction_results = false;
    if ($selected_gateway) {
        // Replaces the ugly if else for gateways
        switch ($selected_gateway) {
            case 'paypal_certified':
            case 'wpsc_merchant_paypal_express':
                echo wpsc_get_customer_meta('paypal_express_message');
                $reshash = wpsc_get_customer_meta('paypal_express_reshash');
                if (isset($reshash['PAYMENTINFO_0_TRANSACTIONTYPE']) && in_array($reshash['PAYMENTINFO_0_TRANSACTIONTYPE'], array('expresscheckout', 'cart'))) {
                    $dont_show_transaction_results = false;
                } else {
                    $dont_show_transaction_results = true;
                }
                break;
            case 'dps':
                $sessionid = decrypt_dps_response();
                break;
                //paystation was not updating the purchase logs for successful payment - this is ugly as need to have the databse update done in one place by all gatways on a sucsessful transaction hook not some within the gateway and some within here and some not at all??? This is getting a major overhaul but for here and now it just needs to work for the gold cart people!
            //paystation was not updating the purchase logs for successful payment - this is ugly as need to have the databse update done in one place by all gatways on a sucsessful transaction hook not some within the gateway and some within here and some not at all??? This is getting a major overhaul but for here and now it just needs to work for the gold cart people!
            case 'paystation':
                $ec = $_GET['ec'];
                $result = $_GET['em'];
                if ($result == 'Transaction successful' && $ec == 0) {
                    $processed_id = '3';
                }
                if ($result == 'Insufficient Funds' && $ec == 5) {
                    $processed_id = '6';
                }
                if ($processed_id) {
                    wpsc_update_purchase_log_status($sessionid, $processed_id, 'sessionid');
                }
                break;
            case 'wpsc_merchant_paymentexpress':
                // Payment Express sends back there own session id, which is temporarily stored in the Auth field
                // so just swapping that over here
                $query = "SELECT `sessionid` FROM  `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE  `authcode` ='" . $sessionid . "'";
                $result = $wpdb->get_var($query);
                if ($result != null) {
                    // just in case they are using an older version old gold cart (pre 2.9.5)
                    $sessionid = $result;
                    $dont_show_transaction_results = true;
                }
                break;
            case 'eway_hosted':
                $sessionid = decrypt_eway_uk_response();
                break;
                //default filter for other payment gateways to use
            //default filter for other payment gateways to use
            default:
                $sessionid = apply_filters('wpsc_previous_selected_gateway_' . $selected_gateway, $sessionid);
                break;
        }
    }
    if (!$dont_show_transaction_results) {
        if (!empty($sessionid)) {
            $cart_log_id = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid));
            echo transaction_results($sessionid, true);
        } else {
            printf(__('Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wp-e-commerce'), wpsc_get_checkout_url());
        }
    }
}
Example #8
0
/**
 * The 'transact_url' option is still used by other components outside of theme
 * engine (such as payment gateways). To ensure compatibility, we need to point
 * this option to the last step of the checkout process.
 *
 * Action hook: 'pre_option_transact_url'.
 *
 * @access private
 *
 * @since  0.1
 * @param  string $option Value of the 'transact_url' option
 * @return string The new transaction result URL
 */
function _wpsc_te2_filter_option_transact_url($value)
{
    return wpsc_get_checkout_url('results');
}
 /**
  * Add scripts
  */
 public function scripts()
 {
     if (!wpsc_is_cart() && !wpsc_is_checkout()) {
         return;
     }
     wp_enqueue_style('amazon_payments_advanced', WPSC_MERCHANT_V3_SDKS_URL . '/amazon-payments/assets/css/style.css');
     wp_enqueue_script('amazon_payments_advanced_widgets', WPSC_AMAZON_PA_WIDGETS_URL, '', WPSC_VERSION);
     wp_enqueue_script('amazon_payments_advanced', WPSC_MERCHANT_V3_SDKS_URL . '/amazon-payments/assets/js/amazon-checkout.js', array('amazon_payments_advanced_widgets'), '1.0', true);
     $is_pay_page = _wpsc_get_current_controller_name() == 'checkout' || _wpsc_get_current_controller_name() == 'cart';
     $redirect_page = $is_pay_page ? add_query_arg('amazon_payments_advanced', 'true', wpsc_get_checkout_url('shipping-and-billing')) : esc_url_raw(add_query_arg('amazon_payments_advanced', 'true'));
     wp_localize_script('amazon_payments_advanced', 'amazon_payments_advanced_params', apply_filters('wpsc_amazon_payments_advanced_params', array('seller_id' => $this->setting->get('seller_id'), 'reference_id' => $this->reference_id, 'redirect' => $redirect_page, 'pwa_type' => 'PwA', 'pwa_color' => 'Gold', 'pwa_size' => 'small')));
 }
Example #10
0
/**
 * The 'shopping_cart_url' option is still used by other components outside of theme
 * engine (such as payment gateways). To ensure compatibility, we need to point
 * this option to the last step of the checkout process.
 *
 * Action hook: 'pre_option_shopping_cart_url'.
 *
 * @access private
 *
 * @since  0.1
 * @return string The new shopping cart URL
 */
function _wpsc_te2_filter_option_shopping_cart_url()
{
    return wpsc_get_checkout_url('payment');
}
Example #11
0
 public function _callback_update_quantity()
 {
     global $wpsc_cart;
     if (!wp_verify_nonce($_REQUEST['_wp_nonce'], 'wpsc-cart-update')) {
         wp_die(__('Request expired. Please try updating the items in your cart again.', 'wpsc'));
     }
     $changed = 0;
     $has_errors = false;
     extract($_REQUEST, EXTR_SKIP);
     foreach ($wpsc_cart->cart_items as $key => &$item) {
         if (isset($quantity[$key]) && $quantity[$key] != $item->quantity) {
             $product = get_post($item->product_id);
             if (!is_numeric($quantity[$key])) {
                 $message = sprintf(__('Invalid quantity for %s.', 'wpsc'), $product->post_title);
                 $this->message_collection->add($message, 'error');
                 continue;
             }
             if ($quantity[$key] > $item->quantity) {
                 $product = WPSC_Product::get_instance($item->product_id);
                 if (!$product->has_stock) {
                     $message = __("Sorry, all the remaining stock of %s has been claimed. Now you can only checkout with the current number of that item in your cart.", 'wpsc');
                     $this->message_collection->add(sprintf($message, $product->post_title), 'error');
                     $has_errors = true;
                     continue;
                 } elseif ($product->has_limited_stock && $product->stock < $item->quantity) {
                     $message = __('Sorry, but the quantity you just specified is larger than the available stock of %s. Besides the current number of that product in your cart, you can only add %d more.', 'wpsc');
                     $this->message_collection->add(sprintf($message, $product->post_title, $product->stock), 'error');
                     $has_errors = true;
                     continue;
                 }
             }
             $item->quantity = $quantity[$key];
             $item->refresh_item();
             $changed++;
         }
     }
     $wpsc_cart->clear_cache();
     if (!isset($_POST['update_quantity']) && !$has_errors) {
         wp_redirect(wpsc_get_checkout_url());
         exit;
     }
     if ($changed) {
         $message = _n('You just successfully updated the quantity for %d item.', 'You just successfully updated the quantity for %d items.', $changed, 'wpsc');
         $this->message_collection->add(sprintf($message, $changed), 'success');
     }
 }
Example #12
0
function wpsc_get_checkout_steps()
{
    if (_wpsc_get_current_controller_name() != 'checkout') {
        return '';
    }
    $wizard = WPSC_Checkout_Wizard::get_instance();
    $steps = $wizard->steps;
    $output = '<ul class="wpsc-wizard">';
    $step_count = 1;
    foreach ($steps as $step => $title) {
        $classes = array('wpsc-wizard-step wpsc-wizard-step-' . $step);
        if ($wizard->is_active($step)) {
            $classes[] = 'active';
        }
        if ($wizard->is_disabled($step)) {
            $classes[] = 'disabled';
        } elseif ($wizard->is_completed($step)) {
            $classes[] = 'completed';
        } else {
            $classes[] = 'pending';
        }
        $classes[] = 'split-' . count($steps);
        $output .= '<li class="' . implode(' ', $classes) . '">';
        if (!$wizard->is_completed($step)) {
            $output .= '<span>';
        } else {
            $output .= '<a href="' . wpsc_get_checkout_url($step) . '">';
        }
        $output .= '<span class="step">' . $step_count . '.</span> ' . $title;
        if (!$wizard->is_completed($step)) {
            $output .= '</span>';
        } else {
            $output .= '</a>';
        }
        $output .= '</li>';
        $step_count++;
    }
    $output .= '</ul>';
    return $output;
}
Example #13
0
function wpsc_checkout_url($slug = '')
{
    echo esc_url(wpsc_get_checkout_url($slug));
}