Paypal 贝宝沙箱支付问题

Paypal 贝宝沙箱支付问题,paypal,sandbox,paypal-ipn,paypal-sandbox,Paypal,Sandbox,Paypal Ipn,Paypal Sandbox,我有以下用于paypal交易的post按钮: <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="my@email.com">

我有以下用于paypal交易的post按钮:

    <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="my@email.com">
        <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);
}
?>
关于返回到“my@email.com“,如果指定的电子邮件未映射到PayPal沙箱中的帐户,则可能发生这种情况。也许你在按钮中使用的是真正的电子邮件,而不是沙箱帐户电子邮件

另一种可能是您的测试帐户位于“my@email.com“不是一个商业账户。如果你有一个企业账户,它应该反映你的企业名称

至于没有收到IPN,沙箱在按时交付IPN方面并不总是做得很好,如果有的话。实际上,我建议您尝试使用快速结帐而不是网站付款标准进行集成。快速结帐最初有点令人困惑,但在您尝试理解它之后,它很容易实现。以下是我认为最好的解释Express Checkout工作原理的文档:

当您准备好深入研究实现时,您应该查看以下内容:

使用Express Checkout而不是依赖IPN的好处在于,当用户返回站点时,您就可以了解付款状态,而不必坐在那里等待IPN的出现

使用Express Checkout,您还可以使用自定义的“品牌名称”覆盖您的企业名称,这样您就可以在具有不同“品牌”的不同网站上使用相同的接收贝宝帐户


祝你好运

实际上,我使用了一个非沙盒帐户作为my@email.com,然后我把它改为我的沙盒商务邮件,并创建了一个新的个人作为买家。。。然后我输入了我的买家登录详细信息来购买物品,但它仍然没有执行ipn.php页面,它似乎没有进入那里。。。目前我想坚持使用IPN,因为它看起来很简单。谢谢,我明白了。如果你想坚持使用IPN,那么你应该看看他们的IPN测试仪——如果可以,那么你可以排除你的IPN.php是问题的根源,但是如果它不起作用,那么不幸的是,你不知道问题是否出在PayPal没有发送IPNi选择的快速结帐,我不知道这是否是我必须选择的正确项目,但它传递了一条消息:“IPN已成功发送。”。如果您使用按钮,您可能应该选择“web接受”,但如果您的IPN.php即使使用“快速签出”也成功,那么您可能很好。沙箱的问题是有时无法发送自动IPN。如果您需要额外的保证,您可以使用live帐户进行测试。别担心,你可以随时退还任何已支付的款项-费用也将被转回。