Solved

PayPal Issues

Posted on 2011-09-13
5
307 Views
Last Modified: 2012-05-12
We have been developing our website for months using PayPal in the "sandbox" mode. It worked fine. Today I tried to make it go live, with no success.

I am using PPHttpPost php function. The response in $httpParsedResponseAr["ACK"] is "Failure". I know the credit card being used is good, the expiration date was correct, etc.

It MIGHT be that the parameters being used for UserID, Password & Signature are no longer valid. I realize those are different for live use than sandbox & I changed them accordingly.

Is there some code I can look at to determine the error true cause?

Thanks
function PPHttpPost($methodName_, $nvpStr_) {
	global $environment;
	global $res;
	// Set up your API credentials, PayPal end point, and API version.
	$API_UserName = urlencode($res['username']);
	$API_Password = urlencode($res['password']);
	$API_Signature = urlencode($res['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');
	// Set the curl parameters.
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
	curl_setopt($ch, CURLOPT_VERBOSE, 1);
	// Turn 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);
	// Set the API operation, version, and API signature in the request.
	$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
	// Set the request as a POST FIELD for curl.
	curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
	// Get response from the server.
	$httpResponse = curl_exec($ch);
	if(!$httpResponse) {
		exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
	}
	// Extract the 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;
}

Open in new window

0
Comment
Question by:Richard Korts
5 Comments
 
LVL 4

Accepted Solution

by:
h4hardy earned 250 total points
ID: 36535498
for this you have to contact to paypal..sometime paypal also stopped the transaction for that particular account..you can try..

-- check the sandbox api username and password..can it active or not?

-- send the request to paypal with your code

let me know if i would help you.
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 36536341
I think my first approach would be to use var_dump() to see this: $httpResponse.  You will want to use "view source" to check the output.
0
 
LVL 17

Expert Comment

by:nanharbison
ID: 36537270
Another tip about setting up a credit card transactions, many of the providers offer a fake credit card number to try for each of MC and Visa for you to try when you are going live. Maybe you already know this.
0
 
LVL 29

Expert Comment

by:coreybryant
ID: 36539032
Most companies use the same testing numbers, but you should be able to produce results with these Credit Card Testing Numbers.

Visa: 4111111111111111 or 4012888888881881
MasterCard: 5105105105105100 or 5555555555554444
Discover: 6011000990139424 or 6011111111111117
American Express: 371449635398431 or 378282246310005

The expiration date should not matter (provided it is not before August 2011).  Plus before submitted to Paypal (or any electronic payment gateway), you should check to see if it validates (How Credit Card Numbers Are Determined).  This will save you a transaction fee.
0
 

Author Closing Comment

by:Richard Korts
ID: 36544878
Be on the lookout for my next question.

PayPal is a nightmare.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question