IPN向我发送了option_selection1值,但我认为我的听众不能通过电子邮件将这些值发送给我,因为它们是网址。
在html表单中,买方在文本字段中输入他的选项。 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: noreply@domainname.com/";
$mail_To = "my@gmail.com";
$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发送给侦听器的消息:
&option_selection1=http://www.testwebsite.com/home.html&option_selection2=http://www.facebook.com/testpage&option_name1=websitel&option_name2=fb
答案 0 :(得分:0)
这将准备$ cart_items数组中的所有内容,以便您可以遍历项目并相应地提取所需的数据。
$i = 1;
$cart_items = array();
while(isset($_POST['item_number' . $i]))
{
$item_number = isset($_POST['item_number' . $i]) ? $_POST['item_number' . $i] : '';
$item_name = isset($_POST['item_name' . $i]) ? $_POST['item_name' . $i] : '';
$quantity = isset($_POST['quantity' . $i]) ? $_POST['quantity' . $i] : '';
$mc_gross = isset($_POST['mc_gross_' . $i]) ? $_POST['mc_gross_' . $i] : 0;
$mc_handling = isset($_POST['mc_handling' . $i]) ? $_POST['mc_handling' . $i] : 0;
$mc_shipping = isset($_POST['mc_shipping' . $i]) ? $_POST['mc_shipping' . $i] : 0;
$custom = isset($_POST['custom' . $i]) ? $_POST['custom' . $i] : '';
$option_name1 = isset($_POST['option_name1_' . $i]) ? $_POST['option_name1_' . $i] : '';
$option_selection1 = isset($_POST['option_selection1_' . $i]) ? $_POST['option_selection1_' . $i] : '';
$option_name2 = isset($_POST['option_name2_' . $i]) ? $_POST['option_name2_' . $i] : '';
$option_selection2 = isset($_POST['option_selection2_' . $i]) ? $_POST['option_selection2_' . $i] : '';
$option_name3 = isset($_POST['option_name3_' . $i]) ? $_POST['option_name3_' . $i] : '';
$option_selection3 = isset($_POST['option_selection3_' . $i]) ? $_POST['option_selection3_' . $i] : '';
$option_name4 = isset($_POST['option_name4_' . $i]) ? $_POST['option_name4_' . $i] : '';
$option_selection4 = isset($_POST['option_selection4_' . $i]) ? $_POST['option_selection4_' . $i] : '';
$option_name5 = isset($_POST['option_name5_' . $i]) ? $_POST['option_name5_' . $i] : '';
$option_selection5 = isset($_POST['option_selection5_' . $i]) ? $_POST['option_selection5_' . $i] : '';
$option_name6 = isset($_POST['option_name6_' . $i]) ? $_POST['option_name6_' . $i] : '';
$option_selection6 = isset($_POST['option_selection6_' . $i]) ? $_POST['option_selection6_' . $i] : '';
$option_name7 = isset($_POST['option_name7_' . $i]) ? $_POST['option_name7_' . $i] : '';
$option_selection7 = isset($_POST['option_selection7_' . $i]) ? $_POST['option_selection7_' . $i] : '';
$option_name8 = isset($_POST['option_name8_' . $i]) ? $_POST['option_name8_' . $i] : '';
$option_selection8 = isset($_POST['option_selection8_' . $i]) ? $_POST['option_selection8_' . $i] : '';
$option_name9 = isset($_POST['option_name9_' . $i]) ? $_POST['option_name9_' . $i] : '';
$option_selection9 = isset($_POST['option_selection9_' . $i]) ? $_POST['option_selection9_' . $i] : '';
$btn_id = isset($_POST['btn_id' . $i]) ? $_POST['btn_id' . $i] : '';
$current_item = array(
'item_number' => $item_number,
'item_name' => $item_name,
'quantity' => $quantity,
'mc_gross' => $mc_gross,
'mc_handling' => $mc_handling,
'mc_shipping' => $mc_shipping,
'custom' => $custom,
'option_name1' => $option_name1,
'option_selection1' => $option_selection1,
'option_name2' => $option_name2,
'option_selection2' => $option_selection2,
'option_name3' => $option_name3,
'option_selection3' => $option_selection3,
'option_name4' => $option_name4,
'option_selection4' => $option_selection4,
'option_name5' => $option_name5,
'option_selection5' => $option_selection5,
'option_name6' => $option_name6,
'option_selection6' => $option_selection6,
'option_name7' => $option_name7,
'option_selection7' => $option_selection7,
'option_name8' => $option_name8,
'option_selection8' => $option_selection8,
'option_name9' => $option_name9,
'option_selection9' => $option_selection9,
'btn_id' => $btn_id
);
array_push($cart_items, $current_item);
$i++;
}