/** * Pull and Record PayPal Details * * @return void */ public function pull_paypal_details() { $this->set_purchase_log_for_callbacks(); // Pull the User Details from PayPal $this->paypal_data = $paypal = $this->gateway->get_details_for($_GET['token']); $payer = $paypal->get('payer'); $address = $paypal->get('shipping_address'); // PurchaseLog Update if (isset($address['country_code'])) { $this->purchase_log->set('billing_country', $address['country_code']); $this->purchase_log->set('shipping_country', $address['country_code']); } if (isset($address['state'])) { $this->purchase_log->set('billing_region', $address['state']); $this->purchase_log->set('shipping_region', $address['state']); } // Save Checkout Form Fields $form = WPSC_Checkout_Form::get(); $fields = $form->get_fields(); $_POST['wpsc_checkout_details'] = array(); foreach ($fields as $field) { $this->set_post_var($field, $payer, $address); } // Save details to the Forms Table WPSC_Checkout_Form_Data::save_form($this->purchase_log, $fields); }
public function save_shipping_and_billing_info() { global $wpsc_cart; $purchase_log = $this->get_purchase_log(); $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)); $form = WPSC_Checkout_Form::get(); $fields = $form->get_fields(); foreach ($fields as $field) { if (!array_key_exists($field->id, $_POST['wpsc_checkout_details'])) { continue; } $value = $_POST['wpsc_checkout_details'][$field->id]; switch ($field->unique_name) { case 'billingstate': wpsc_update_customer_meta('billing_region', $value); $purchase_log->set('billing_region', $value); break; case 'shippingstate': wpsc_update_customer_meta('shipping_region', $value); $purchase_log->set('shipping_region', $value); break; case 'billingcountry': wpsc_update_customer_meta('billing_country', $value); $purchase_log->set('billing_country', $value); break; case 'shippingcountry': wpsc_update_customer_meta('shipping_country', $value); $purchase_log->set('shipping_region', $value); break; case 'shippingpostcode': wpsc_update_customer_meta('shipping_zip', $value); break; } } _wpsc_update_location(); //keep track of tax if taxes are exclusive $wpec_taxes_controller = new wpec_taxes_controller(); if (!$wpec_taxes_controller->wpec_taxes_isincluded()) { $tax = $wpsc_cart->calculate_total_tax(); $tax_percentage = $wpsc_cart->tax_percentage; } else { $tax = 0.0; $tax_percentage = 0.0; } $purchase_log->set(array('wpec_taxes_total' => $tax, 'wpec_taxes_rate' => $tax_percentage)); $purchase_log->save(); //Check to ensure purchase log row was inserted successfully if (is_null($purchase_log->get('id'))) { $this->message_collection->add(__('A database error occured while processing your request.', 'wp-e-commerce'), 'error'); return; } $wpsc_cart->log_id = $purchase_log->get('id'); wpsc_update_customer_meta('current_purchase_log_id', $purchase_log->get('id')); WPSC_Checkout_Form_Data::save_form($purchase_log, $fields); $this->init_shipping_calculator(); if (wpsc_uses_shipping() && !$this->shipping_calculator->has_quotes) { $this->message_collection->add(__('Sorry, but we cannot ship products to your submitted address. Please either provide another shipping address or contact the store administrator about product availability to your location.', 'wp-e-commerce'), 'error'); return; } $this->wizard->completed_step('shipping-and-billing'); $url = add_query_arg($_GET, wpsc_get_checkout_url($this->wizard->pending_step)); wp_redirect($url); exit; }