我有以下按鈕後,我使用了支付寶交易:貝寶沙盒支付問題
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Item description">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="00.30">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="website.com/index.php" />
<input type="hidden" name="cancel_return" value="website.com/index.php" />
<input type="hidden" name="rm" value="2">
<input type="hidden" name="notify_url" value="website.com/ipn/ipn.php">
<input type="hidden" name="custom" value="user_id">
<input type="submit" value="upgrade" />
</form>
和ipn.php
<?php
include_once 'config.php';
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
mysql_query("UPDATE table SET column='1' WHERE column2='13'");
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
下面的代碼當我點擊升級按鈕,並支付,它沒有顯示我返回到網站按鈕...但有一個回到[email protected]按鈕,它有10秒的延遲,並帶我回到我的網站...雖然它彈出警告關於加密數據,我不知道它是什麼。
而且我在ipn.php使用查詢不execute.I甚至不知道,如果去ipn.php。
其實我使用非沙箱帳戶[email protected],然後我改成了我的沙箱企業電子郵件和創建新的個人作爲一個買方...然後我進入了我的買家的登錄信息,以購買物品,仍然沒有執行ipn.php頁面,它似乎沒有去那裏... 此刻我想堅持IPN,因爲它看起來很簡單。 謝謝 – fxuser
我明白了。如果你想堅持使用IPN,那麼你應該在https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session上看看他們的IPN測試人員 - 如果這樣做,那麼你可以排除你的ipn.php作爲問題的根源,但如果它不起作用,那麼不幸的是,你不會知道問題是否與貝寶不發送IPN – nioq
我選擇快速結帳,我不知道這是我必須選擇正確的項目,但它傳遞了消息:「IPN已成功發送。」 – fxuser