Paypal API
Paypal API
Has anyone messed with the Paypal API at all? Are there any examples out there for querying something like total amount in the account or people that donated and their amounts?
Re: Paypal API
Hi Xombie,
I'd be interested in any progress you might make on this score as, at some point, I will also need to start working with Paypal's APIs etc. Sorry that I cannot help at this point.
I'd be interested in any progress you might make on this score as, at some point, I will also need to start working with Paypal's APIs etc. Sorry that I cannot help at this point.
I may look like a mule, but I'm not a complete ass.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Paypal API
I'm lurking on this one too hehe. For once I'm not the one that's going to charge in and dig out its secrets, I just don't have the time.
BERESHEIT
Re: Paypal API
I'm pretty familiar with the PayPal IPN API. But I don't think that's what you're looking for. 
There is a GetBalance function for the "Website Payments Pro and Express Checkout API Operations". I don't know if these APIs are free though.
https://cms.paypal.com/us/cgi-bin/?&cmd ... _reference
See here also:
https://cms.paypal.com/us/cgi-bin/?&cmd ... brary_code
There are links there for querying for your balance information with sample code. I believe these APIs are free but I haven't actually tried them.
Here is a PHP example using cURL:

There is a GetBalance function for the "Website Payments Pro and Express Checkout API Operations". I don't know if these APIs are free though.
https://cms.paypal.com/us/cgi-bin/?&cmd ... _reference
See here also:
https://cms.paypal.com/us/cgi-bin/?&cmd ... brary_code
There are links there for querying for your balance information with sample code. I believe these APIs are free but I haven't actually tried them.
Here is a PHP example using cURL:
Code: Select all
<?php
$environment = 'sandbox'; // or 'beta-sandbox' or 'live'
/**
* Send HTTP POST Request
*
* @param string The API method name
* @param string The POST Message fields in &name=value pair format
* @return array Parsed HTTP Response body
*/
function PPHttpPost($methodName_, $nvpStr_) {
global $environment;
$API_UserName = urlencode('my_api_username');
$API_Password = urlencode('my_api_password');
$API_Signature = urlencode('my_api_signature');
$API_Endpoint = "https://api-3t.paypal.com/nvp";
if("sandbox" === $environment || "beta-sandbox" === $environment) {
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
}
$version = urlencode('51.0');
// setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// turning off the server and peer verification(TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// NVPRequest for submitting to server
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// setting the nvpreq as POST FIELD to curl
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// getting response from server
$httpResponse = curl_exec($ch);
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
// Extract the RefundTransaction response details
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value) {
$tmpAr = explode("=", $value);
if(sizeof($tmpAr) > 1) {
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
}
}
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
}
return $httpParsedResponseAr;
}
$nvpStr="";
$httpParsedResponseAr = PPHttpPost('GetBalance', $nvpStr);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
exit('GetBalance Completed Successfully: '.print_r($httpParsedResponseAr, true));
} else {
exit('GetBalance failed: ' . print_r($httpParsedResponseAr, true));
}
?>