/**
  * Process the SetExpressCheckout API Call
  *
  * @return void
  *
  * @since 3.9
  */
 public function process()
 {
     $total = $this->convert($this->purchase_log->get('totalprice'));
     $options = array('return_url' => $this->get_return_url(), 'message_id' => $this->purchase_log->get('id'), 'invoice' => $this->purchase_log->get('sessionid'), 'address_override' => 1);
     $options += $this->checkout_data->get_gateway_data();
     $options += $this->purchase_log->get_gateway_data(parent::get_currency_code(), $this->get_currency_code());
     if ($this->setting->get('ipn', false)) {
         $options['notify_url'] = $this->get_notify_url();
     }
     // SetExpressCheckout
     $response = $this->gateway->setup_purchase($options);
     if ($response->is_successful()) {
         $params = $response->get_params();
         if ($params['ACK'] == 'SuccessWithWarning') {
             $this->log_error($response);
             wpsc_update_customer_meta('paypal_express_checkout_errors', $response->get_errors());
         }
         // Successful redirect
         $url = $this->get_redirect_url(array('token' => $response->get('token')));
     } else {
         // SetExpressCheckout Failure
         $this->log_error($response);
         wpsc_update_customer_meta('paypal_express_checkout_errors', $response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-express-checkout', 'payment_gateway_callback' => 'display_paypal_error'), $this->get_return_url());
     }
     wp_redirect($url);
     exit;
 }
 public function process()
 {
     $total = $this->convert($this->purchase_log->get('totalprice'));
     $options = array('return_url' => $this->get_return_url(), 'invoice' => $this->purchase_log->get('sessionid'));
     $options += $this->checkout_data->get_gateway_data();
     $options += $this->purchase_log->get_gateway_data(parent::get_currency_code(), $this->get_currency_code());
     if ($this->setting->get('ipn', false)) {
         $options['notify_url'] = $this->get_notify_url();
     }
     $response = $this->gateway->setup_purchase($options);
     if ($response->is_successful()) {
         $url = ($this->setting->get('sandbox_mode') ? self::SANDBOX_URL : self::LIVE_URL) . $response->get('token');
         wp_redirect($url);
     } else {
         $_SESSION['paypal_express_checkout_errors'] = serialize($response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-express-checkout', 'payment_gateway_callback' => 'display_paypal_error'), $this->get_return_url());
     }
     wp_redirect($url);
     exit;
 }
Пример #3
0
 /**
  * Call the CreateButton API
  *
  * @return void
  *
  * @since 3.9
  */
 public function process()
 {
     $total = $this->convert($this->purchase_log->get('totalprice'));
     $options = array('return_url' => $this->get_return_url(), 'message_id' => $this->purchase_log->get('id'), 'invoice' => $this->purchase_log->get('sessionid'), 'address_override' => 1, 'paymentaction' => 'sale', 'template' => 'templateD', 'vendor' => $this->setting->get('vendor_id'));
     $options += $this->checkout_data->get_gateway_data();
     $options += $this->purchase_log->get_gateway_data(parent::get_currency_code(), $this->get_currency_code());
     if ($this->setting->get('ipn', false)) {
         $options['notify_url'] = $this->get_notify_url();
     }
     // Detect Mobile Devices
     if (wp_is_mobile()) {
         $options['template'] = 'mobile-iframe';
     }
     // BMCreateButton API call
     $response = $this->gateway->createButton($options);
     if ($response->is_successful()) {
         $params = $response->get_params();
         $website_code = $params['WEBSITECODE'];
         // Log any warning
         if ($params['ACK'] == 'SuccessWithWarning') {
             $this->log_error($response);
             wpsc_update_customer_meta('paypal_pro_checkout_errors', $response->get_errors());
         }
         // Write the Button code
         echo $website_code;
     } else {
         // Log errors and redirect user
         $this->log_error($response);
         wpsc_update_customer_meta('paypal_pro_checkout_errors', $response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-pro', 'payment_gateway_callback' => 'display_paypal_error'), $this->get_return_url());
         // Redirect to the Error Page
         wp_redirect($url);
     }
     // Stop further execution
     exit;
 }