gpt4 book ai didi

php - Paypal IPN - 如何在监听器中获取 option_selection 的值?

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:32 32 4
gpt4 key购买 nike

IPN 向我发送了 option_selection1 值,但我认为我的听众无法通过电子邮件将这些值发送给我,因为它们是 url。

在 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

最佳答案

这将在 $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++;
}

关于php - Paypal IPN - 如何在监听器中获取 option_selection 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35380592/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com