I'm looking for a php code to integrate Paypal users balance into my website. Please help. Thank you in Advance
I don't think its possible.Paypal will not allow this ever,because of users privacy.You can try your luck with http://apapi.sourceforge.net/ though!
PayPal has a pretty good API that let's you do a lot of things. I'm not sure about querying another users balance, but you can query your own balance. Check out the API Developers Docs, most specifically the GetBalance(). Here is their provided example of doing it via NVP: https://cms.paypal.com/cms_content/US/en_US/files/developer/nvp_GetBalance_php.txt Other API call references: https://developer.paypal.com/webapps/developer/docs/classic/api/ Also, visit PayPal on GitHub to find more of their code examples! http://paypal.github.io/ Hope this helps!
Yes, you can. <?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)); } ?> PHP: This will return the balance for a paypal account if the API on that account has been activated and the credentials are correct.
Hehe, it's all good. I did it that way so people would actually read and familiarize themselves with the fact that PayPal has a whole website dedicated to their API and a GitHub with tons of examples. Often, when you simply provide a snippet of code, they don't know how to read/use the snippet/class and just end up asking more questions which would have been answered by the docs.
Pretty self explanatory message there... The security headers are not valid, therefore you're sending something to PayPal that is not expected. Check that you've entered valid login credentials, that the endpoint or location is what it needs to be, and anything else that may trigger a security error. I've not tested the script I linked you to, it may be old or outdated. That's why I also provided you with links to dive into PayPal's API yourself and to find what you need. Furthermore, if you visit the PayPal GitHub, you can find their OO GetBalance script and PHPUnitTest example.
I tried the same script you posted there few weeks ago. I don't remember what I got but it was completely different from what I got now. I was just wondering how does DP do it. It seems to be working great for them. I really appreciate your link to Paypal API link, I've been there before but was lost more than what I'm now. Nobody said I wanted someone to do for me. I think you are having some issues with figuring out what is going on around here. If you read my first post I clearly said: and I guess Phaaze already knew that, otherwise he would have said something... I'm always grateful for the things people have done for me, at the same time I'm more grateful for the people that use common sense and mind there own business other than try to start trouble between others. Thank you for being there.