Solved

PayPal Issues

Posted on 2011-09-13
5
302 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Be on the lookout for my next question.

PayPal is a nightmare.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

5 Experts available now in Live!

Get 1:1 Help Now