![](/img/trans.png)
[英]How can I get posted data passed along when the user is first redirected through Paypal?
[英]Can't pass through POST data when redirected through paypal
我已經建立了一個網站,客戶可以在其中輸入他們的信息(姓名,地址等),並希望他們能夠通過Paypal使用信用卡付款。 那很好。 我已經設置了貝寶即時付款通知,並通過貝寶進行了設置,以使客戶重定向到我的頁面。 除了不會傳遞數據並將其保存到我的SQL數據庫之外,所有其他方法都可以正常工作。 我知道將數據插入數據庫的代碼可以正常工作。 問題是由於貝寶頁面介於兩者之間,因此數據沒有傳遞到該頁面。
這是我有的PHP
if (isset($_POST['child_name'])
&& isset($_POST['age'])
&& isset($_POST['hometown'])
&& isset($_POST['boy_girl'])
&& isset($_POST['email'])
&& isset($_POST['first_name'])
&& isset($_POST['last_name'])
&& isset($_POST['address1'])
&& isset($_POST['address2'])
&& isset($_POST['city'])
&& isset($_POST['state'])
&& isset($_POST['zip'])
&& isset($_POST['country'])) {
$child_name = $_POST['child_name'];
$age = $_POST['age'];
$hometown = $_POST['hometown'];
$boy_girl = $_POST['boy_girl'];
$email = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
}
這是HTML
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NT2YC6LP7SWBE">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="child_name" id="child_name" value ="<? echo $child_name; ?>" maxlength="20"/>
<input type="hidden" name="age" id="age" value ="<? echo $age; ?>" maxlength="4"/>
<input type="hidden" name="hometown" id="hometown" value ="<? echo $hometown; ?>" maxlength="32"/>
<input type="hidden" name="boy_girl" id="boy_girl" value ="<? echo $boy_girl; ?>" maxlength="4"/>
<input type="hidden" name="first_name" id="first_name" value ="<? echo $first_name; ?>" maxlength="32"/>
<input type="hidden" name="last_name" id="last_name" value ="<? echo $last_name; ?>" maxlength="32"/>
<input type="hidden" name="email" id="email" value ="<? echo $email; ?>" maxlength="64"/>
<input type="hidden" name="address1" id="address1" value ="<? echo $address1; ?>" maxlength="64"/>
<input type="hidden" name="address2" id="address2" value ="<? echo $address2; ?>" maxlength="32"/>
<input type="hidden" name="city" id="city" value ="<? echo $city; ?>" maxlength="32"/>
<input type="hidden" name="state" id="state" value ="<? echo $state; ?>" maxlength="20"/>
<input type="hidden" name="zip" id="zip" value ="<? echo $zip; ?>" maxlength="10"/>
<input type="hidden" name="country" id="country" value ="<? echo $country; ?>" maxlength="32"/>
<input type="hidden" name="payment_type" id="payment_type" value ="paypal" maxlength="6"/>
<input type="hidden" name="paid" id="paid" value ="yes" maxlength="3"/>
<input type="hidden" name="mailed" id="mailed" value ="no" maxlength="3"/>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
我只是采用了貝寶給我的表格,並添加了隱藏的輸入。 這在另一個頁面上可以很好地工作,但這是因為action屬性直接導致將要插入數據的頁面。 在這里,操作會將他們發送到Paypal的站點,而數據再也無法挖掘到。 我該如何調整?
由於流程原因,您無法執行此操作。 兩種解決方案:
嘗試使用分隔符將所有信息存儲在Paypal的custom
字段(255個字符)中
使用唯一鍵將定制信息存儲在數據庫中,並將唯一鍵存儲在custom
字段中,以便稍后可以使用IPN響應進行檢索
在獲得IPN響應之前,您不應做任何與數據庫相關的事情,這就是IPN的意義所在。 您在這里描述的是PDT,它依賴客戶在始終不會發生的付款過程之后返回您的頁面。
正如kalpaitch所建議的那樣,您應該將數據保存到會話中,並在訪問者從貝寶頁面返回時將其拉回。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.