Solved

PayPal Issues

Posted on 2011-09-13
5
305 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 109

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now