PayPal付款后返回商家网站

时间:2015-03-25 22:18:22

标签: php paypal return

我的网站上有一个PHP表单,当用户点击提交时 - 他们被重定向到预订确认页面。此时,我已按如下方式设置了PayPal连接(Sandbox);

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">

        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="business" value="youremail@email.com">
        <input type="hidden" name="currency_code" value="EUR">
        <input type="hidden" name="upload" value="1">

        <b>First name:</b><span style="padding-left:5em;"></span>
        <input type="text" name="first_name" style="width:20em;">
        <br><br>
        <b>Last name:</b><span style="padding-left:5.1em;"></span>
        <input type="text" name="last_name" style="width:20em;">
        <br>
        <b>Email Address:</b><span style="padding-left:3.35em;"></span>
        <input type="text" name="email" style="width:20em;">

        <input type="hidden" name="custom" value="<?php echo $randomString ?>"/>
        <input type="hidden" name="return" value="http://www.example.com/thank-you/">
        <input type="hidden" name="notify_url" value="https://www.example.com/my_ipn.php">
        <input type="hidden" name="rm" value="2"> 

        <?php 
        if (($Adults > 0) && ($Students > 0) && ($Children > 0))
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";

            echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Student - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_2' value='15'>";
            echo "<input type='hidden' name='quantity_2' value='" . $Students . "'>";

            echo "<input type='hidden' name='item_name_3' value='" . $selectroute ." (Child - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_3' value='15'>";
            echo "<input type='hidden' name='quantity_3' value='" . $Children . "'>";
        }
        elseif (($Adults > 0) && ($Students > 0))
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";

            echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Student - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_2' value='15'>";
            echo "<input type='hidden' name='quantity_2' value='" . $Students . "'>";
        }
        elseif (($Students > 0) && ($Children > 0))
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Student - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Students . "'>";

            echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Child - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_2' value='15'>";
            echo "<input type='hidden' name='quantity_2' value='" . $Children . "'>";
        }
        elseif (($Adults > 0) && ($Children > 0))
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";

            echo "<input type='hidden' name='item_name_2' value='" . $selectroute ." (Child - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_2' value='15'>";
            echo "<input type='hidden' name='quantity_2' value='" . $Children . "'>";
        }
        elseif ($Adults > 0)
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Adult - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Adults . "'>";
        }
        elseif ($Students > 0)
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Student - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Students . "'>";
        }
        elseif ($Children > 0)
        {
            echo "<input type='hidden' name='item_name_1' value='" . $selectroute ." (Child - " . $ticket .")'>";
            echo "<input type='hidden' name='amount_1' value='15'>";
            echo "<input type='hidden' name='quantity_1' value='" . $Children . "'>";
        }
        ?>

        <input type="image" src="https://www.paypalobjects.com/webstatic/en_US/btn/btn_paynow_cc_144x47.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style="position:relative; top: 8em; padding-left:15em;">
        <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
    </form>

上面的表格采用用户在PHP预订表单上输入的值,并按预期在Paypal的“订单摘要”部分显示。然后我可以作为买家登录并付款。然后,我希望返回http://www.example.com/thank-you/,但我登陆PayPal页面,该页面说明了交易ID并确认付款已被处理。

如何返回Merchant网站上的Thank You页面而不是PayPal网站?

我已启用自动返回功能,并设置了返回网址。正如您在上面所看到的,我已经指定了return和rm变量,但没有运气。

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:1)

终于 - 我开始工作了。

有点愚蠢的错误 - 但是为了防止其他人遇到这个问题 - 我已将代码中的企业电子邮件留作youremail@email.com,如上所示。

我将业务变量值更改为商家电子邮件地址后,就可以了!