Paypal ipn / cart变量

时间:2012-10-03 09:39:25

标签: variables paypal cart paypal-ipn

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

我目前正在建设的网站销售“活动”门票....假期。

我正在尝试做的是通过购买的数量减少数据库字段中的票证数量但是找不到将获取信息的paypal cart变量。它似乎只能使用一次自定义变量,并且已经使用了item_name和item_number变量,(item_number)用于标识数据库中的“event_id”字段,而(item_name)用于标识事件名称。

我可以通过减少金额并在汇总到Paypal之前在隐藏的表单字段中回显出来,将正确数量的票证更新到Paypal,但我无法得到结果。我正在寻找一个Paypal表单'name'字段,可以根据我的需要进行调整,如果存在的话

下面是数据库循环:'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

1 个答案:

答案 0 :(得分:0)

您可以将自定义变量作为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++;
}

或者您甚至可以base64_encode将其发送给PayPal,然后将其解码回来,当您将用户重定向到PayPal时,您希望变量不可读。