function doMethod($methodName, $nvpArray) { // create final name/value/pair array $nvpArray = array_merge(array('METHOD' => $methodName, 'VERSION' => '51.0', 'PWD' => $this->pass, 'USER' => $this->user, 'SIGNATURE' => $this->sig), $nvpArray); // make it a urlencoded string $nvpStr = ra::toNVP($nvpArray); //funx::debug($nvpStr); // create curl $c = curl_init(); curl_setopt($c, CURLOPT_URL, $this->endpoint); //curl_setopt($c, CURLOPT_VERBOSE, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_POSTFIELDS, $nvpStr); // execute method on paypal server $response = curl_exec($c); // parse the response $ret = $response ? ra::fromNVP($response) : array('L_LONGMESSAGE' => 'Couldn\'t talk to payment server. Please try again later. ' . curl_error($c) . '(' . curl_errno($c) . ')'); // debug message funx::debug("Response to {$methodName}: " . var_export($response, true) . "\n" . var_export($ret, true)); $this->lastErrorTxt = "Response was " . str_replace(array(" '"), array("<br /> '"), var_export($ret, true)) . "<br /><br />" . "NVP was " . var_export(str_replace(array("&", $this->user, $this->pass, $this->sig, urlencode($nvpArray['ACCT'])), array("<br /> &", '', '', '', substr($nvpArray['ACCT'], -5, 5)), $nvpStr), true) . ''; return $ret; }