1
IPN向我發送option_selection1值,但我認爲我的聽衆無法給我發送這些值,因爲他們是網址。Paypal IPN - 如何獲取option_selection的值在偵聽器中?
在html表單中,買方在文本表單中輸入他的optins。 IPN將此發送給監聽者。
我的聽衆的工作是獲取數據並向我發送詳細信息。
問題是:我收到所有正確的細節但沒有選擇值的電子郵件。
這裏是形式:
Your website url:<br>
<input type="hidden" name="on0" value="website">
<input type="text" name="os0" size="30" required><br><br>
Your fb page url:<br>
<input type="hidden" name="on1" value="fb">
<input type="text" name="os1" size="30" required>
而這裏的聽衆:
<?php
// 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 = "POST /cgi-bin/webscr HTTP/1.0\r\n";
// If testing on Sandbox use:
// $header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
// If testing on Sandbox use:
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item = $_POST['item_name'];
$quantity = $_POST['quantity'];
$total = $_POST['payment_gross'];
$website = $_POST['option_selection1'];
$fb = $_POST['option_selection2'];
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$email = $_POST['custom'];
$id = $_POST['txn_id'];
$time = $_POST['payment_date'];
if (!$fp)
{
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$mail_From = "From: [email protected]/";
$mail_To = "[email protected]";
$mail_Subject = "New Order Received";
$mail_Body = '';
$emailtext = '
New Order Received
-------------------------
Item: '.$item.'
Quantity: '.$quantity.'
Total paid: $ '.$total.'
Website: '.$website.'
fb: '.$fb.'
Buyer Information:
-------------------------
First Name: '.$firstname.'
Last Name: '.$lastname.'
Email: '.$email.'
-------------------------
Transaction ID: '.$id.'
Time: '.$time.'
';
mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From);
}
}
}
?>
這是消息IPN仙DS的聽衆:
&option_selection1=http://www.testwebsite.com/home.html&option_selection2=http://www.facebook.com/testpage&option_name1=websitel&option_name2=fb
你可以添加你用來提取IPN變量並通過電子郵件發送的代碼嗎? – antoniom
@antoniom你走了。 – Raven
@Biswajit在哪裏定義了$ squeeze? – Mark