KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it possible to use CURL and Paypal's Developer Sandbox? When I try this code it says in print_r($lines); that I need to login to the Sandbox, how can I make it send my browser cookie? This code is from http://leepeng.blogspot.com/2006/04/standard-paypal-php-integration.html $orderno = $_SESSION["ss_last_orderno"]; $ppAcc = "[SELLER HERE]"; $at = "[AT HERE]"; //PDT Identity Token $url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; //Test //$url = "https://www.paypal.com/cgi-bin/webscr"; //Live $tx = $_REQUEST['tx']; //this value is return by PayPal $cmd = "_notify-synch"; $post = "tx=$tx&at=$at&cmd=$cmd"; //Send request to PayPal server using CURL $ch = curl_init ($url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt ($ch, CURLOPT_POSTFIELDS, $post); $result = curl_exec ($ch); //returned result is key-value pair string $error = curl_error($ch); if (curl_errno($ch) != 0) //CURL error exit("ERROR: Failed updating order. PayPal PDT service failed."); $longstr = str_replace("\r", "", $result); $lines = split("\n", $longstr); print_r($lines); //parse the result string and store information to array if ($lines[0] == "SUCCESS") { //successful payment $ppInfo = array(); for ($i=1; $i<count($lines); $i++) { $parts = split("=", $lines[$i]); if (count($parts)==2) { $ppInfo[$parts[0]] = urldecode($parts[1]); } } $curtime = gmdate("d/m/Y H:i:s"); //capture the PayPal returned information as order remarks $oremarks = "##$curtime##\n". "PayPal Transaction Information...\n". "Txn Id: ".$ppInfo["txn_id"]
Tags (comma-separated)
Save Edits
Cancel