I'm trying to use the PayPal AdaptivePayments API and I'm trying to set the url for paypal IPN which is supposed to be "ipnNotificationUrl" but I don't know where to add it in the request.
Here is my code:
ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
/*
*******************************************************************
PayPal API Credentials
Replace <API_USERNAME> with your API Username
Replace <API_PASSWORD> with your API Password
Replace <API_SIGNATURE> with your Signature
*******************************************************************
*/
//PayPal API Credentials
$API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO
$API_Password = "1287090610"; //TODO
$API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO
//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload with minimum required parameters
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"currencyCode" => "USD",
"cancelUrl" => "http://www.paypal.com",
"returnUrl" => "http://www.paypal.com",
"receiverList.receiver(0).email" => "r_1_1266351681_biz#paypal.com", //TODO
"receiverList.receiver(0).amount" => "20.0", //TODO
"receiverList.receiver(1).email" => "r_2_1266352427_biz#paypal.com", //TODO
"receiverList.receiver(1).amount" => "30.0" //TODO
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//set url to approve the transaction
$payPalURL = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" . $kArray["payKey"];
//print the url to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
echo '<p>' . $payPalURL . '</p>';
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
/*
//optional code to redirect to PP URL to approve payment
If ( $kArray["responseEnvelope.ack"] == "Success") {
header("Location:". $payPalURL);
exit;
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
*/
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
Thanks a lot!
It should be in $bodyparms array:
"returnUrl" => "http://www.paypal.com",
"ipnNotificationUrl" => "http://www.baseem.com/ipnhandler.php",
Related
I am validating the email address using the following code :
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus");
$API_UserName = "";
$API_Password = "";
$API_Signature = "";
$API_AppID = "";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"emailAddress" => $email, // email to be validate
"matchCriteria" => "NONE"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = #fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
{
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp); //close the stream
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
{
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
if( $kArray["responseEnvelope.ack"] == "Success")
{
// do nothing
}
else
{
// error
}
However this code works for sandbox account. What changes do i make to validate the paypal account.
Any help will be appreciated.
https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus
this is sandbox link change it to live account link. Thats it.
Three Things
GetVerifiedStatusAPI requires your adaptive payment application to be approved with "getverifiedstatus" feature enabled.
You will need to submit the application(with GetVerifiedStatus checkbox enabled, get the application approved at www.paypal-apps.com to get the APP-ID
Change the endpoint to https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus
P.S Your account should be Business/premier Verified account
How to check email or mobile phone paypal account status using php api ?
OK, If i want to send money to this e-mail paypal (xxx#xx.com) or mobile phone (1234567890)
Before send money, can i check xxx#xx.com Or 1234567890 status account. EG: Active or Not active
Yes you can get the status of the PayPal account either by email or the phone number. You should the "GETVERIFIEDSTATUS" API for this purpose . You will have to provide the first and the last name along with email/phone . Kindly refer the below link for API info :
https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-accounts/GetVerifiedStatus_API_Operation/#id098QF50F04Y
Apart from that I have included the the php code :
When using email :
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to sandbox
//$url = trim("https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to Live
$API_UserName = "XXXXXXXXX"; //PayPal Test API Credentials, Replace it with live if in live mode
$API_Password = "XXXXXXXX";
$API_Signature = "XXXXXXXX";
$API_AppID = "APP-80W284485P519543T"; //Default App ID for Sandbox, replace it with live id if in live mode
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"emailAddress" =>"XXXXXXXXX",
"firstName" =>"Eshan Business TEST",
"lastName" =>" Account",
"matchCriteria" => "NAME"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = #fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
{
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp); //close the stream
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
{
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the request to screen for testing purposes
echo "Header info:" . "<br>";
print_r($params['http']['header']);
echo "<br><br>" . "Request Info:" . "<br>";
print_r(urldecode($params['http']['content']));
echo "<br><br>" . "Response:" . "<br>";
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success")
{
foreach ($kArray as $key =>$value)
{
echo $key . ": " .$value . "<br/>";
}
}
else
{
foreach ($kArray as $key =>$value)
{
echo $key . ": " .$value . "<br/>";
}
}
}
catch(Exception $e)
{
echo "Message: ||" .$e->getMessage()."||";
}
echo "<br>";
?>
When using Phone Number :
<?php
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to sandbox
//$url = trim("https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"); //set PayPal Endpoint to Live
$API_UserName = "XXXXXXXXXXXX"; //PayPal Test API Credentials, Replace it with live if in live mode
$API_Password = "XXXXXXXXXXXX";
$API_Signature = "XXXXXXXXXXX";
$API_AppID = "APP-80W284485P519543T"; //Default App ID for Sandbox, replace it with live id if in live mode
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"accountIdentifier.mobilePhoneNumber" =>"4088359375",
"firstName" =>"Eshan Personal Test",
"lastName" =>" Account",
"matchCriteria" => "NAME"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = #fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
{
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp); //close the stream
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
{
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the request to screen for testing purposes
echo "Header info:" . "<br>";
print_r($params['http']['header']);
echo "<br><br>" . "Request Info:" . "<br>";
print_r(urldecode($params['http']['content']));
echo "<br><br>" . "Response:" . "<br>";
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success")
{
foreach ($kArray as $key =>$value)
{
echo $key . ": " .$value . "<br/>";
}
}
else
{
foreach ($kArray as $key =>$value)
{
echo $key . ": " .$value . "<br/>";
}
}
}
catch(Exception $e)
{
echo "Message: ||" .$e->getMessage()."||";
}
echo "<br>";
?>
I am implementing code for php with adaptive payment after the transaction complete at last page i get the error that Your payment can't be completed. Please return to the participating website and try again. what is the wrong with this code. Here is my code.
enter code here
<?php
//turn php errors on
//ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
$API_UserName = "s.patel_api1.sactp.ca"; //TODO
$API_Password = "PA9YLDURHKTU52LH"; //TODO
$API_Signature = "An5ns1Kso7MWUdW4ErQKJJJ4qi4-AOPwV4AdrC6q3hsN81pmNWMXn7f-"; //TODO
$receiver_email = "rushi.mtech#gmail.com"; //TODO
$amount = 25; //TODO
//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"cancelUrl" => "http://localhost/success.php",
"returnUrl" => "http://localhost/cancel.php",
"currencyCode" => "CAD",
"receiverList.receiver.email" => $receiver_email,
"receiverList.receiver.amount" => $amount
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
$rushi;
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
foreach ($kArray as $key =>$value){
// echo $key . ": " .$value . "<br/>";
if($key == "payKey")
{
$rushi = $value;
echo $rushi;
}
}
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
?>
Plus i embaded html fromhere please guide me
I am at my wits end trying to get this work but cant understand it. I have to use Adaptive payments in a webapp which is created using cakephp framework. I have API credentials like API Username, Password and Signature. But the main problem i am facing is how to call the Pay API to get the API key which is the first thing required to make this work. I am new to this so i dont have much knowledge about this and after lot digging in google i am asking this question. Can someone please give steps for using Adaptive Payments..
Thanks in advance for your help!
You have to follow only three steps:
1- You send a PayRequest message to PayPal
{"returnUrl":"http://example.com/returnURL.htm", \ "requestEnvelope":{"errorLanguage":"en_US"},"currencyCode":"USD", \ "receiverList":{"receiver":[{"email":"david#example.com", \
"amount":"10.00",}]},"cancelUrl":"http://example.com/cancelURL.htm",\ "actionType":"PAY"}
2- You receive a response with a pay key.
{"responseEnvelope":\ {"timestamp":"2009-10-06T14:30:39.383-07:00","ack":"Success",\ "correlationId":"cfe8f8783f1d3","build":"DEV"},\ "payKey":"AP-17266198048308436","paymentExecStatus":"CREATED"}
3- You must redirect the sender’s browser to PayPal to approve the payment.
This would be an example code for step 1 (it works on my local server):
<?php
//turn php errors on
ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
$api_appid = 'APP-80W284485P519543T'; // para sandbox
//PayPal API Credentials
$API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO
$API_Password = "1287090610"; //TODO
$API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO
$receiver_email = "fake#email.com"; //TODO
$amount = 25; //TODO
//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload with minimum required parameters
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"cancelUrl" => "http://cancelUrl",
"returnUrl" => "http://returnUrl",
"currencyCode" => "EUR",
"receiverList.receiver.email" => $receiver_email,
"receiverList.receiver.amount" => $amount
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
foreach ($kArray as $key =>$value){
echo $key . ": " .$value . "<br/>";
}
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
?>
You have many examples here: https://www.x.com/developers/paypal/documentation-tools/paypal-code-samples
I'm trying to rewrite an fopen() POST request to work with a proxy.
The code is based on an example on the Paypal site (https://www.x.com/developers/PayPal/documentation-tools/code-sample/216632).
My default workarounds for fopen() as well as for file_get_contents() and cURL lib don't work for the relatively complex post header and contents. (Either fail to go through proxy or get Invalid request: {0}, even when no proxy is set)
Here's the (simplified) post example code:
$url = trim('https://svcs.sandbox.paypal.com/AdaptiveAccounts/AddBankAccount');
$API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO
$API_Password = "1287090610"; //TODO
$API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO
$API_SANDBOX_EMAIL_ADDRESS = "rishaque#paypal.com"; //TODO
$API_DEVICE_IPADDRESS = "127.0.0.1"; //TODO
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "XML";
$API_ResponseFormat = "XML";
$xml = simplexml_load_string($xml_str);
$contents = $xml->asXML();
try
{
$params = array("http" => array(
"method" => 'POST',
"content" => $contents,
'header' => 'X-PAYPAL-SECURITY-USERID: ' . $API_UserName ."\r\n" .
'X-PAYPAL-SECURITY-PASSWORD: ' . $API_Password . "\r\n" .
'X-PAYPAL-SECURITY-SIGNATURE: ' . $API_Signature . "\r\n" .
'X-PAYPAL-REQUEST-DATA-FORMAT: ' . $API_RequestFormat . "\r\n" .
'X-PAYPAL-RESPONSE-DATA-FORMAT: ' . $API_ResponseFormat . "\r\n" .
'X-PAYPAL-APPLICATION-ID: ' . $API_AppID . "\r\n" .
'X-PAYPAL-SANDBOX-EMAIL-ADDRESS: ' . $API_SANDBOX_EMAIL_ADDRESS . "\r\n" .
'X-PAYPAL-DEVICE-IPADDRESS: ' . $API_DEVICE_IPADDRESS . "\r\n" ));
$ctx = stream_context_create($params);
$fp = #fopen($url, 'r', false, $ctx); // PROXIFY!
$response = stream_get_contents($fp);
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp);
// ... handle the response content ...
}
catch(Exception $e)
{
echo 'Message: ||' .$e->getMessage().'||';
}
?>
My proxy file_get_contents():
if (!empty($_context_params)) {
$http_arr = $_context_params['http'];
$http_arr['proxy'] = $proxy_path;
$http_arr['request_fulluri'] = true;
$_context_params['http'] = $http_arr;
}
else
{
$_context_params = array( 'http' => array( 'proxy' => $proxy_path, 'request_fulluri' => true ) );
}
return file_get_contents( $_url, false, stream_context_create( $_context_params ) );
My proxied fopen:
$parsed_proxy_path = parse_url($proxy_path);
$_proxy_name = $parsed_proxy_path['host'];
$_proxy_port = $parsed_proxy_path['port'];
$proxy_fp = fsockopen( $_proxy_name, $_proxy_port );
if ( !$proxy_fp )
return false;
$parsed_url = parse_url($_url);
$host = $parsed_url['host'];
$request = "GET $_url HTTP/1.0\r\nHost:$host\r\n\r\n";
fputs( $proxy_fp, $request );
return $proxy_fp;
My cURL experiment: (CodeIgniter curl lib takes care of proxy for me)
$http_params = $params['http'];
$this->curl->create($this->cfg->paypal_req_url);
$this->curl->option('header', true);$this->curl->option('verbose', true);
$this->curl->option('useragent', 'cURL/PHP');
$this->curl->http_header($http_params['header']);
$this->curl->http_header("Content-length: ".strlen($contents));
$this->curl->post(array("content"=> $contents));
$res = $this->curl->execute();
Any ideas where to go from here? I'm a bit stuck..
How do I debug the request going out from cURL? Is the request even reproducible with cURL?
Will it work with GET instead of POST?
Is XMLRPC an option?
Note: The example code works for me when not behind a proxy.
Thanks in advance,
Alex
Here's the code I used to get it to work with cURL.
Note: It uses the codeigniter cURL lib by Phil Sturgeon.
Note: I resolved to switching from XML to query string for the contents.
$contents = array(
"actionType"=>"PAY",
"cancelUrl"=>$cancel_url,
"returnUrl"=>$return_url,
"currencyCode"=>$currency,
"sender"=>$sendingmail,
"memo"=>$memo,
"requestEnvelope.errorLanguage"=>$error_lang,
"receiverList.receiver.amount"=>$amount,
"receiverList.receiver.email"=>$receivingmail,
);
if (isset($notification_url)) { $contents["ipnNotificationUrl"]=$notification_url; }
if ($receivingmail == $this->cfg->paypal_email) { $contents["feesPayer"]="SENDER"; }
if ($sendingmail == $this->cfg->paypal_email) { $contents["senderEmail"]=$sendingmail; }
// ------------------------------
// create request and add headers
// ------------------------------
$options = array( "useragent" => "cURL/PHP" );
$this->curl->create($this->cfg->paypal_req_url);
$this->curl->http_header("Content-type", "application/x-www-form-urlencoded");
$this->curl->http_header("X-PAYPAL-SECURITY-USERID", $this->cfg->paypal_user_name);
$this->curl->http_header("X-PAYPAL-SECURITY-SIGNATURE", $this->cfg->paypal_signature);
$this->curl->http_header("X-PAYPAL-SECURITY-PASSWORD", $this->cfg->paypal_password);
$this->curl->http_header("X-PAYPAL-APPLICATION-ID", $this->cfg->paypal_app_id);
$this->curl->http_header("X-PAYPAL-REQUEST-DATA-FORMAT", "NV");
$this->curl->http_header("X-PAYPAL-RESPONSE-DATA-FORMAT", "XML");
$this->curl->post($contents, $options);
$response = $this->curl->execute();
For those stuck with PHP4 it might be useful answering the original question of getting it to work through proxy with fopen?
Cheers,
Alex