You are here

function uc_paypal_api_request in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_paypal/uc_paypal.module \uc_paypal_api_request()
  2. 7.3 payment/uc_paypal/uc_paypal.module \uc_paypal_api_request()
6 calls to uc_paypal_api_request()
uc_paypal_ec_checkout in payment/uc_paypal/uc_paypal.module
uc_paypal_ec_form_submit in payment/uc_paypal/uc_paypal.module
uc_paypal_ec_review in payment/uc_paypal/uc_paypal.module
uc_paypal_ec_review_redirect in payment/uc_paypal/uc_paypal.module
uc_paypal_ec_submit_form_submit in payment/uc_paypal/uc_paypal.module

... See full list

File

payment/uc_paypal/uc_paypal.module, line 1342
Integrates various PayPal payment services and Instant Payment Notifications (IPN) with Ubercart!

Code

function uc_paypal_api_request($request, $server) {
  $request['USER'] = variable_get('uc_paypal_api_username', '');
  $request['PWD'] = variable_get('uc_paypal_api_password', '');
  $request['VERSION'] = '3.0';
  $request['SIGNATURE'] = variable_get('uc_paypal_api_signature', '');
  $data = '';
  foreach ($request as $key => $value) {
    $data .= $key . '=' . urlencode(ereg_replace(',', '', $value)) . '&';
  }
  $data = substr($data, 0, -1);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $server);
  curl_setopt($ch, CURLOPT_VERBOSE, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  $response = curl_exec($ch);
  if ($error = curl_error($ch)) {
    watchdog('uc_paypal', $error, WATCHDOG_ERROR);
  }
  curl_close($ch);
  return _uc_paypal_nvp_to_array($response);
}