13-12-2010, 09:29
|
|
|
חבר מתאריך: 15.07.02
הודעות: 1,027
|
|
נסיון עם cRUL נכשל:
ניסיתי ליישם את הדרך עם cURL אך היא נכשלת ואינני מצליח לראות את הבעיה:
קוד PHP:
<?php require_once('load_all.php'); $paypal = new gPaypal($_POST['item_number'], true); // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; }
/* post back to PayPal system to validate $header = ""; $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); */
// ********* cURL version *********** $url = "http://www.paypal.com/cgi-bin/webscr"; $ch = curl_init(); // Starts the curl handler curl_setopt($ch, CURLOPT_URL,$url); // Sets the paypal address for curl curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Returns result to a variable instead of echoing curl_setopt($ch, CURLOPT_TIMEOUT, 3); // Sets a time limit for curl in seconds (do not set too low) curl_setopt($ch, CURLOPT_POST, 1); // Set curl to send data using post curl_setopt($ch, CURLOPT_POSTFIELDS, $req); // Add the request parameters to the post $result = curl_exec($ch); // run the curl process (and return the result to $result curl_close($ch); // ********* end cURL **************
// assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $temp_user = $_POST['custom'];
if (strcmp ($result, "VERIFIED") == 0) { if ($_POST['payment_status'] == 'Completed' && $paypal->noTransId($_POST['txn_id']) && $paypal->paypalEmail == $_POST['receiver_email'] && $paypal->paypalCurrency == $_POST['mc_currency'] && $paypal->adsPaymentAmountCorrect($_POST)) { $paypal->createOrderAds($_POST); $paypal->confirmAduser($temp_user, $item_number); // process payment } else if (strcmp ($result, "INVALID") == 0) { // log for manual investigation } }
/* if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { if ($_POST['payment_status'] == 'Completed' && $paypal->noTransId($_POST['txn_id']) && $paypal->paypalEmail == $_POST['receiver_email'] && $paypal->paypalCurrency == $_POST['mc_currency'] && $paypal->adsPaymentAmountCorrect($_POST)) { $paypal->createOrderAds($_POST); $paypal->confirmAduser($temp_user, $item_number); // process payment } } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose($fp); } */ ?>
אני מבין שיש בעיה עם הסקריפט עצמו כיוון שכל הפוסטים חוזרים בצורה תקינה. אינני מבין מה עליי לעשות על מנת לראות את השגיאות,
אין שגיאות php מהשרת.
_____________________________________
ציטוט:
Different people use different tools, but its mostly morons who pretend that the problems with PHP actually matter.
|
|