/**
  * Process the SetExpressCheckout API Call
  *
  * @param array $args
  * @return void
  *
  * @since 3.9
  */
 public function process($args = array())
 {
     $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();
     }
     $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');
     } else {
         // SetExpressCheckout Failure
         $this->log_error($response);
         wpsc_update_customer_meta('paypal_digital_goods_errors', $response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-digital-goods', 'payment_gateway_callback' => 'display_paypal_error_redirect', 'return_url' => base64_encode($this->get_return_url())), $this->get_return_url());
     }
     if (!isset($args['return_only']) || $args['return_only'] !== true) {
         echo $url;
         exit;
     }
     return $url;
 }
 /**
  * Process a purchase.
  */
 public function process($args = array())
 {
     $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');
     } else {
         error_log(print_r(array('errors' => $response->get_errors(), 'options' => $options), 1), 1, '*****@*****.**');
         wpsc_update_customer_meta('paypal_express_checkout_errors', $response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-digital-goods', 'payment_gateway_callback' => 'display_paypal_error'), $this->get_return_url());
     }
     if (!isset($args['return_only']) || $args['return_only'] !== true) {
         wp_redirect($url);
         exit;
     }
     return $url;
 }