【问题标题】:Paypal ipn/cart variablesPaypal ipn/购物车变量
【发布时间】:2012-09-24 05:15:58
【问题描述】:

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

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

我正在尝试做的是将数据库字段中的门票数量减少购买的数量,但找不到将拉回信息的贝宝购物车变量。自定义变量似乎只能使用一次,并且 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

【问题讨论】:

    标签: variables paypal cart paypal-ipn


    【解决方案1】:

    您可以将自定义变量作为 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 发送到贝宝,然后将其解码回来,当您将用户重定向到贝宝时,您希望变量不可读。

    【讨论】:

      猜你喜欢
      • 2023-03-04
      • 2011-02-08
      • 2017-12-17
      • 2012-12-24
      • 2023-03-11
      • 2013-03-05
      • 2013-04-18
      • 2012-06-19
      • 2018-01-28
      相关资源
      最近更新 更多