我的网站链接到Paypal。在我的网站上,我将信息传递给PayPal,如下所示;
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="youremail@email.com">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="custom" value="<?php echo $randomString ?>"/>
<input type="hidden" name="return" value="http://www.example.com/thank-you/">
<input type="hidden" name="rm" value="2">
<?php
if (($Adults > 0) && ($Students > 0) && ($Children > 0))
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";
echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Student - " . $ticket .")'>";
echo "<input type='hidden' name='amount_2' value='15'>";
echo "<input type='hidden' name='quantity_2' value='" . $Students . "'>";
echo "<input type='hidden' name='item_name_3' value='" . $selectroute ." (Child - " . $ticket .")'>";
echo "<input type='hidden' name='amount_3' value='15'>";
echo "<input type='hidden' name='quantity_3' value='" . $Children . "'>";
}
elseif (($Adults > 0) && ($Students > 0))
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";
echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Student - " . $ticket .")'>";
echo "<input type='hidden' name='amount_2' value='15'>";
echo "<input type='hidden' name='quantity_2' value='" . $Students . "'>";
}
elseif (($Students > 0) && ($Children > 0))
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Student - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Students . "'>";
echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Child - " . $ticket .")'>";
echo "<input type='hidden' name='amount_2' value='15'>";
echo "<input type='hidden' name='quantity_2' value='" . $Children . "'>";
}
elseif (($Adults > 0) && ($Children > 0))
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";
echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Child - " . $ticket .")'>";
echo "<input type='hidden' name='amount_2' value='15'>";
echo "<input type='hidden' name='quantity_2' value='" . $Children . "'>";
}
elseif ($Adults > 0)
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";
}
elseif ($Students > 0)
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Student - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Students . "'>";
}
elseif ($Children > 0)
{
echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Child - " . $ticket .")'>";
echo "<input type='hidden' name='amount_1' value='15'>";
echo "<input type='hidden' name='quantity_1' value='" . $Children . "'>";
}
?>
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/btn/btn_paynow_cc_144x47.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style="position:relative; top: 8em; padding-left:45em;">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
付款后,用户将被重定向回我网站上的“感谢您”页面。在此页面上,我可以在确认电子邮件中使用通过PayPal传递的信息。
$ItemName1 = $keyarray['item_name1'];
$ItemName2 = $keyarray['item_name2'];
$ItemName3 = $keyarray['item_name3'];
$TotalCost = $keyarray['mc_gross'];
$Quantity1 = $keyarray['quantity1'];
$Quantity2 = $keyarray['quantity2'];
$Quantity3 = $keyarray['quantity3'];
$ItemCost1 = $keyarray['mc_gross_1'];
$ItemCost2 = $keyarray['mc_gross_2'];
$ItemCost3 = $keyarray['mc_gross_3'];
$Currency = $keyarray['mc_currency'];
$BookingReference = $keyarray['custom'];
$FirstName = $keyarray['first_name'];
$LastName = $keyarray['last_name'];
$Email = $keyarray['payer_email'];
我已经使用了自定义变量,我相信我只能使用一次 - 这是正确的吗?但是我需要传递另外两个包含离开时间和返回时间的变量 - 如果我不能再次使用自定义变量,我将如何传递这些变量?
答案 0 :(得分:1)
将它们与分隔符连接:
// PHP
concatenatedString = "value1:value2:value3";
// HTML
<input type="hidden" name="custom" value="<?php echo concatenatedString ?>"/>
然后当它返回时,您可以拆分值并正确分配它们。