2012-10-03 55 views
1

想知道如果有人可以給我任何指針?PayPal的ipn/cart變量

我目前正在建設的網站銷售'活動'門票....假期。

我想要做的是通過購買的數量減少數據庫字段中的票數,但無法找到一個將拉回信息的貝寶車變量。自定義變量似乎只能使用一次,並且item_name和item_number變量已被使用,(item_number)標識數據庫中的'event_id'字段和(item_name)以顯式標識事件名稱。

我可以傳遞正確的門票數量,通過減少金額並在sumbitting到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 

回答

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不被讀取解碼。