Пример #1
0
 /**
  * Checks the status of what part of the checkout we are on
  * And sees if we need to do anything special for the express checkout
  * @param array &$auth
  * @param array &$checkout_steps
  * @param int &$current_stage
  */
 function checkOutStatus(&$auth, &$checkout_steps, &$current_stage, &$ship_to_info_id, $ppex = 0)
 {
     require_once CLASSPATH . "payment/" . __CLASS__ . ".cfg.php";
     global $vmLogger;
     if (in_array('CHECK_OUT_GET_PAYMENT_METHOD', $checkout_steps[$current_stage])) {
         $vmLogger->debug('At Payment Method -> Redirecting to Confirm');
         //Fake the Credit Card Details to bypass the credit card checking of VM
         $_SESSION['ccdata']['creditcard_code'] = '242';
         $_SESSION['ccdata']['credit_card_code'] = "242";
         $_SESSION['ccdata']['order_payment_name'] = "PayPal Express";
         $_SESSION['ccdata']['order_payment_number'] = "4834879217180125";
         $_SESSION['ccdata']['order_payment_expire_month'] = 11;
         //The year date will need to be changed as the years progress
         $_SESSION['ccdata']['order_payment_expire_year'] = 2016;
         // calculate the unix timestamp for the specified expiration date
         // default the day to the 1st
         $expire_timestamp = @mktime(0, 0, 0, $_SESSION["ccdata"]["order_payment_expire_month"], 15, $_SESSION["ccdata"]["order_payment_expire_year"]);
         $_SESSION["ccdata"]["order_payment_expire"] = $expire_timestamp;
         $current_stage++;
         if (isset($checkout_steps[$current_stage]) == false) {
             $current_stage++;
             ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
             return;
         }
         if (in_array('CHECK_OUT_GET_SHIPPING_ADDR', $checkout_steps[$current_stage])) {
             ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
             return;
         }
         //Request used for when going from a regular link instead of a post from form
         $_REQUEST['checkout_stage'] = $current_stage;
         $_POST['checkout_this_step'] = $checkout_steps[$current_stage];
     } else {
         if (in_array('CHECK_OUT_GET_SHIPPING_ADDR', $checkout_steps[$current_stage]) && empty($ship_to_info_id)) {
             if ($auth['user_id']) {
                 $db = new ps_DB();
                 $q = "SELECT * FROM #__{vm}_user_info ";
                 $q .= "WHERE user_id =" . (int) $auth['user_id'] . ' ';
                 $q .= "AND address_type = 'ST' ";
                 $q .= "ORDER by address_type_name, mdate DESC";
                 $db->query($q);
                 if ($db->num_rows() > 0) {
                     while ($db->next_record()) {
                         if ($_SESSION['ppex_userdata']['address_1'] == $db->f("address_1") && $_SESSION['ppex_userdata']['city'] == $db->f("city") && $_SESSION['ppex_userdata']['zip'] == $db->f("zip")) {
                             $_REQUEST['ship_to_info_id'] = $db->f('user_info_id');
                             $ship_to_info_id = $db->f('user_info_id');
                             $current_stage++;
                             if (isset($checkout_steps[$current_stage]) == false) {
                                 $current_stage++;
                                 ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
                                 return;
                             }
                             if (in_array('CHECK_OUT_GET_PAYMENT_METHOD', $checkout_steps[$current_stage])) {
                                 ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
                                 return;
                             }
                             //Request used for when going from a regular link instead of a post from form
                             $_REQUEST['checkout_stage'] = $current_stage;
                             $_POST['checkout_this_step'] = $checkout_steps[$current_stage];
                             break;
                         }
                     }
                 } else {
                     $q = "SELECT * FROM #__{vm}_user_info ";
                     $q .= "WHERE user_id =" . (int) $auth['user_id'] . ' ';
                     $q .= "AND address_type = 'BT' ";
                     $q .= "ORDER by address_type_name, mdate DESC";
                     $db->query($q);
                     if ($db->num_rows() > 0) {
                         while ($db->next_record()) {
                             if ($_SESSION['ppex_userdata']['address_1'] == $db->f("address_1") && $_SESSION['ppex_userdata']['city'] == $db->f("city") && $_SESSION['ppex_userdata']['zip'] == $db->f("zip")) {
                                 $_REQUEST['ship_to_info_id'] = $db->f('user_info_id');
                                 $ship_to_info_id = $db->f('user_info_id');
                                 $current_stage++;
                                 if (isset($checkout_steps[$current_stage]) == false) {
                                     $current_stage++;
                                     ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
                                     return;
                                 }
                                 if (in_array('CHECK_OUT_GET_PAYMENT_METHOD', $checkout_steps[$current_stage])) {
                                     ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $ppex);
                                     return;
                                 }
                                 //Request used for when going from a regular link instead of a post from form
                                 $_REQUEST['checkout_stage'] = $current_stage;
                                 $_POST['checkout_this_step'] = $checkout_steps[$current_stage];
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     if ((int) $ppex == 2 && PAYPAL_API_USE_SHIPPING != '1') {
         if ($auth['user_id']) {
             $db = new ps_DB();
             $q = "SELECT * FROM #__{vm}_user_info ";
             $q .= "WHERE user_id =" . (int) $auth['user_id'] . ' ';
             $q .= "AND address_type = 'ST' ";
             $q .= "ORDER by address_type_name, mdate DESC";
             $db->query($q);
             if ($db->num_rows() > 0) {
                 while ($db->next_record()) {
                     if ($_SESSION['ppex_userdata']['address_1'] == $db->f("address_1") && $_SESSION['ppex_userdata']['city'] == $db->f("city") && $_SESSION['ppex_userdata']['zip'] == $db->f("zip")) {
                         $_REQUEST['ship_to_info_id'] = $db->f('user_info_id');
                         $ship_to_info_id = $db->f('user_info_id');
                         break;
                     }
                 }
             } else {
                 $q = "SELECT * FROM #__{vm}_user_info ";
                 $q .= "WHERE user_id =" . (int) $auth['user_id'] . ' ';
                 $q .= "AND address_type = 'BT' ";
                 $q .= "ORDER by address_type_name, mdate DESC";
                 $db->query($q);
                 if ($db->num_rows() > 0) {
                     while ($db->next_record()) {
                         if ($_SESSION['ppex_userdata']['address_1'] == $db->f("address_1") && $_SESSION['ppex_userdata']['city'] == $db->f("city") && $_SESSION['ppex_userdata']['zip'] == $db->f("zip")) {
                             $_REQUEST['ship_to_info_id'] = $db->f('user_info_id');
                             $ship_to_info_id = $db->f('user_info_id');
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #2
0
    $Itemid = $sess->getShopItemid();
    if ($auth['user_id'] > 0) {
        $show_basket = true;
    } else {
        $show_basket = false;
    }
    $current_stage = ps_checkout::get_current_stage();
    $checkout_steps = ps_checkout::get_checkout_steps();
    /*if ($shipping_rate_id && $ship_to_info_id && $payment_method_id && !isset($_GET['checkout_stage'])) {
    		$current_stage=count($checkout_steps);
    	} elseif( $ship_to_info_id && $payment_method_id && empty($shipping_rate_id) && isset( $_GET['checkout_last_step'] ) && !isset($_GET['checkout_stage'])) {
    		$_POST['checkout_this_step'] = $checkout_steps[$current_stage];
    		$current_stage++;
    	}*/
    if (isset($_SESSION['ppex_userdata']['payer_id'])) {
        ps_paypal_api::checkOutStatus($auth, $checkout_steps, $current_stage, $ship_to_info_id, $paypal_express_checkout);
    }
} else {
    $ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
    $shipping_rate_id = urldecode(vmGet($_REQUEST, "shipping_rate_id", null));
    $payment_method_id = vmGet($_REQUEST, 'payment_method_id');
    if (file_exists(CLASSPATH . "payment/ps_paypal_api.cfg.php")) {
        include_once CLASSPATH . "payment/ps_paypal_api.cfg.php";
        require_once CLASSPATH . 'payment/ps_paypal_api.php';
        $paypal_api_payment_method_id = ps_paypal_api::getPaymentMethodId('ps_paypal_api');
    }
    $Itemid = $sess->getShopItemid();
    /* Decide, which Checkout Step is the next one 
     * $checkout_this_step controls the step thru the checkout process
     * we have the following steps
     * -CHECK_OUT_GET_SHIPPING_ADDR