Пример #1
0
 /**
  * Submit
  * Charges the user for the purchase and if profit sharing is enabled
  * each product owner.
  * @since 1.3
  * @version 1.3
  */
 function submit()
 {
     // Since the wpsc_pre_submit_gateway action could change these values, we need to check
     if ($this->cost > 0 && $this->user_id != 0 && !empty($this->transaction_id)) {
         // Let other play before we start
         do_action_ref_array('mycred_wpecom_charg', array(&$this));
         // Charge
         $this->core->add_creds('wpecom_payment', $this->user_id, 0 - $this->cost, $this->prefs['log'], '', $this->purchase_id, $this->mycred_type);
         // Update Order
         $this->set_transaction_details($this->transaction_id, 3);
         transaction_results($this->cart_data['session_id'], false);
         // Payout Share
         if ($this->prefs['share'] > 0) {
             // Loop though items
             foreach ((array) $this->cart_items as $item) {
                 // Get product
                 $product = get_post((int) $item['product_id']);
                 // Continue if product has just been deleted or owner is buyer
                 if ($product === NULL || $product->post_author == $this->user_id) {
                     continue;
                 }
                 // Calculate Cost
                 $price = $item['price'];
                 $quantity = $item['quantity'];
                 $cost = $price * $quantity;
                 // Calculate Share
                 $percentage = apply_filters('mycred_wpecom_profit_share', $this->prefs['share'], $this, $product);
                 if ($percentage == 0) {
                     continue;
                 }
                 $share = $percentage / 100 * $cost;
                 // Payout
                 $this->core->add_creds('store_sale', $product->post_author, $share, $this->prefs['share_log'], $product->ID, array('ref_type' => 'post'), $this->mycred_type);
             }
         }
         // Let others play before we end
         do_action_ref_array('mycred_wpecom_charged', array(&$this));
         // Empty Cart, Redirect & Exit
         wpsc_empty_cart();
         $this->go_to_transaction_results($this->cart_data['session_id']);
         exit;
     } elseif (!empty($this->transaction_id)) {
         $this->set_transaction_details($this->transaction_id, 2);
     }
 }
 /**
  * submit method, sends the received data to the payment gateway
  * @access public
  */
 function submit()
 {
     $name_value_pairs = array();
     foreach ($this->collected_gateway_data as $key => $value) {
         $name_value_pairs[] = $key . '=' . urlencode($value);
     }
     $gateway_values = implode('&', $name_value_pairs);
     $redirect = get_option('paypal_multiple_url') . "?" . $gateway_values;
     // URLs up to 2083 characters long are short enough for an HTTP GET in all browsers.
     // Longer URLs require us to send aggregate cart data to PayPal short of losing data.
     // An exception is made for recurring transactions, since there isn't much we can do.
     if (strlen($redirect) > 2083 && !$this->cart_data['is_subscription']) {
         $name_value_pairs = array();
         foreach ($this->_construct_value_array(true) as $key => $value) {
             $name_value_pairs[] = $key . '=' . urlencode($value);
         }
         $gateway_values = implode('&', $name_value_pairs);
         $redirect = get_option('paypal_multiple_url') . "?" . $gateway_values;
     }
     if (defined('WPSC_ADD_DEBUG_PAGE') && WPSC_ADD_DEBUG_PAGE) {
         echo "<a href='" . esc_url($redirect) . "'>" . __("Test the URL here", 'wp-e-commerce') . "</a>";
         echo "<pre>" . print_r($this->collected_gateway_data, true) . "</pre>";
         exit;
     } else {
         if (defined('WPSC_PAYPAL_BUY_NOW') && WPSC_PAYPAL_BUY_NOW) {
             wpsc_empty_cart();
         }
         wp_redirect($redirect);
         exit;
     }
 }
function _wpsc_oklink_return()
{
    if (!isset($_REQUEST['wpsc_oklink_return'])) {
        return;
    }
    // oklink order param interferes with wordpress
    unset($_REQUEST['order']);
    unset($_GET['order']);
    if (!isset($_REQUEST['sessionid'])) {
        return;
    }
    global $sessionid;
    $purchase_log = new WPSC_Purchase_Log($_REQUEST['sessionid'], 'sessionid');
    if (!$purchase_log->exists() || $purchase_log->is_transaction_completed()) {
        return;
    }
    $status = 1;
    if (isset($_REQUEST['cancelled'])) {
        # Unsetting sessionid to show error
        do_action('wpsc_payment_failed');
        $sessionid = false;
        unset($_REQUEST['sessionid']);
        unset($_GET['sessionid']);
    } else {
        $status = WPSC_Purchase_Log::ORDER_RECEIVED;
        $purchase_log->set('processed', $status);
        $purchase_log->save();
        wpsc_empty_cart();
    }
}