PayPal ipn/购物车变量



想知道是否有人可以给我任何指示?

我目前正在建立的网站出售"活动"门票。假期。

我正在尝试做的是将数据库字段中的门票数量减少购买的数量,但找不到PayPal购物车变量来拉回信息。自定义变量似乎只能使用一次,并且已经使用了item_name和item_number变量,(item_number)用于标识数据库中的"event_id"字段,(item_name)用于明显标识事件名称。

我可以通过减少数量并在汇总到PayPal之前在隐藏的表单字段中回显出来,将要更新的正确数量的票证传递给PayPal但我无法返回结果。我正在寻找一个可以适应我需求的PayPal形式的"名称"字段(如果存在的话)

下面是数据库循环:"custom"变量不起作用,因为它不能是custom1,custom2等。

    mysql_connect('xxxxxxxx', 'xxxxxx', 'xxxxxxxx') or exit(0);
    mysql_select_db('xxxxxx') or exit(0);
$num_cart_items = $_POST['num_cart_items'];

$i=1;
while (isset($_POST['item_number'.$i]))//read the item details
{
$item_ID[$i]=$_POST['item_number'.$i];
$custom[$i]=$_POST['custom'.$i];
$i++;
}
$item_count = $i-1;
for ($j=1;$j<=$item_count;$j++) 
{
$struery = "UPDATE events SET event_tickets = '".$custom[$j]."' WHERE event_id = '".$item_ID[$j]."'";
$result = mysql_query($struery) or die("Cart - paypal_cart_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
$i++;
}// end database loop

Thanks for any info.
Os

您可以将自定义变量作为 JSON 编码字符串。然后解码它。

$i=1;
$custom = json_decode($_POST['custom], TRUE);
while (isset($_POST['item_number'.$i]))//read the item details
{
    $item_ID[$i] = $_POST['item_number'.$i];
    $custom[$i] = $custom[$i];
    $i++;
}

或者你甚至可以在发送到PayPal时base64_encode它,然后 верут 解码回来,当你将用户重定向到PayPal时,你希望变量不可读。

最新更新