Hi. I've searched on these boards for an answer to this, and most of the responses that I see point the OP to the PayPal boards, where I've posted this question and not gotten a response. So, I thought I'd throw caution to the wind and post it here too in the hopes that some kind soul can and will help me out.

I'm trying to integrate PayPal Website Payments Standard into a custom shopping cart that I've written. My client doesn't want to upgrade to Payments Pro (which I've successfully integrated in the past - hence my frustration here) due to the additional fees. Basically, here's what I've got so far -

	private function buildPurchase(){
		$this->getCartTotal();
		$orderId = $this->insertOrder();

//set up the PayPal variables to be passed
	$params = "cmd=_cart";
	$params .= "&upload=1";
	$params .= "&business=".parent::getPPBusiness();
	$cart = $this->getCartDetails(-1);
	for($i=0; $i<$this->_numItems; $i++){
		$curNo = $i+1;
		$params .= "&item_name_{$curNo}=".$cart[$i]['product_name'];
		$params .= "&amount_{$curNo}=".$cart[$i]['price'];
		$params .= "&quantity_{$curNo}=".$cart[$i]['quantity'];
	}
	$params .= "&submit=PayPal";
	$params .= "&return=[returnURL]";
	$params .= "&cancel_return=[cancelURL]";
//		$params .= "&notify_url=[notifyURL]";
//		$params .= "&rm=2";

//instantiate the cURL request
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, parent::getPPAddy());
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode(stripslashes($params)));
//		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 4);
//		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
		curl_setopt($ch, CURLOPT_FAILONERROR, true);
		curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);

//send the cURL request
	$ppResult = curl_exec($ch);

//close the cURL session
	curl_close($ch);
}

With the code as listed above, I get no cURL errors, and the PayPal sandbox header appears atop my cart page, asking me to log in to use the functions of the sandbox. From what I've read, I should be redirected to a payment page with the cart total. If I uncomment the lines indicating the verification and the RETURNTRANSFER and FOLLOWLOCATION cURL options, nothing happens at all.

I do have a PayPal Sandbox test merchant set up (the parent::getPPBusiness() function returns the dummy e-mail associated with the account), and have turned on "Paypal account optional" in the account settings. According to the docs, I should be taken to the PayPal website, where I (as the buyer) can log in with the appropriate credentials if necessary. However, as I said above, all that happens is that the PayPal Sandbox header appears at the top of the cart page and asks me to log in to that. I never actually get to the payment gateway.

I've even tried creating a saved button on the PayPal server and using that in its' own form for checkout, but nothing happens and I can't see a way to safely pass the aggregate cart total to the "button" for processing.

I'm hoping that I'm just missing something very simple and easy and that someone here can spot it immediately and will hit me in the head for it. 'Cause I'd love that kind of smack.

Anyone have any ideas?

    Write a Reply...