function uc_paypal_api_request in Ubercart 7.3
Same name and namespace in other branches
- 5 payment/uc_paypal/uc_paypal.module \uc_paypal_api_request()
- 6.2 payment/uc_paypal/uc_paypal.module \uc_paypal_api_request()
Sends a request to PayPal and returns a response array.
6 calls to uc_paypal_api_request()
- uc_paypal_ec_checkout in payment/
uc_paypal/ uc_paypal.module - Redirects if a customer selects PayPal Express Checkout as a payment method.
- uc_paypal_ec_form_submit in payment/
uc_paypal/ uc_paypal.module - Submit handler for uc_paypal_ec_form().
- uc_paypal_ec_review in payment/
uc_paypal/ uc_paypal.pages.inc - Handles the review page for Express Checkout Shortcut Flow.
- uc_paypal_ec_review_redirect in payment/
uc_paypal/ uc_paypal.pages.inc - Handles the review page for Express Checkout Mark Flow.
- uc_paypal_ec_submit_form_submit in payment/
uc_paypal/ uc_paypal.module - Additional submit handler for uc_cart_checkout_review_form().
File
- payment/
uc_paypal/ uc_paypal.module, line 972 - Integrates various PayPal payment services and Instant Payment Notifications (IPN) with Ubercart!
Code
function uc_paypal_api_request($request, $server) {
// We use $request += to add API credentials so that if a key already exists,
// it will not be overridden.
$request += array(
'USER' => variable_get('uc_paypal_api_username', ''),
'PWD' => variable_get('uc_paypal_api_password', ''),
'VERSION' => '3.0',
'SIGNATURE' => variable_get('uc_paypal_api_signature', ''),
);
$data = '';
foreach ($request as $key => $value) {
$data .= $key . '=' . urlencode(str_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, 1);
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', array(
'!error' => $error,
), WATCHDOG_ERROR);
}
curl_close($ch);
return _uc_paypal_nvp_to_array($response);
}