Solved

PayPal Issues

Posted on 2011-09-13
5
303 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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

919 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

24 Experts available now in Live!

Get 1:1 Help Now