Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Curl Paypal Sandbox
    primarykey
    data
    text
    <p>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?</p> <p>This code is from <a href="http://leepeng.blogspot.com/2006/04/standard-paypal-php-integration.html" rel="noreferrer">http://leepeng.blogspot.com/2006/04/standard-paypal-php-integration.html</a> </p> <pre><code> $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&amp;at=$at&amp;amp;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&lt;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"]."\n". "Txn Type: ".$ppInfo["txn_type"]."\n". "Item Number: ".$ppInfo["item_number"]."\n". "Payment Date: ".$ppInfo["payment_date"]."\n". "Payment Type: ".$ppInfo["payment_type"]."\n". "Payment Status: ".$ppInfo["payment_status"]."\n". "Currency: ".$ppInfo["mc_currency"]."\n". "Payment Gross: ".$ppInfo["payment_gross"]."\n". "Payment Fee: ".$ppInfo["payment_fee"]."\n". "Payer Email: ".$ppInfo["payer_email"]."\n". "Payer Id: ".$ppInfo["payer_id"]."\n". "Payer Name: ".$ppInfo["first_name"]." ".$ppInfo["last_name"]."\n". "Payer Status: ".$ppInfo["payer_status"]."\n". "Country: ".$ppInfo["residence_country"]."\n". "Business: ".$ppInfo["business"]."\n". "Receiver Email: ".$ppInfo["receiver_email"]."\n". "Receiver Id: ".$ppInfo["receiver_id"]."\n"; //Update database using $orderno, set status to Paid //Send confirmation email to buyer and notification email to merchant //Redirect to thankyou page } //Payment failed else { print "Please try again..."; //Delete order information //Redirect to failed page } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload