PayPal立即购买按钮自定义变量无效

时间:2016-06-30 08:52:10

标签: paypal paypal-buttons

我试图通过3个经典步骤执行付款:

1)带有PayNow按钮的订单页面

2)PayPal付款

3)重定向到"付款已完成页面"

我想要达到的目标是让ID从第1步到第3步。我尝试做的是将此字段插入" custom"变量如:

<input type="hidden" name="custom" value="--Server Code--">

PayPal付款后,PayPal会将我重定向到我的页面:

http://www.mysite.cm/tx=blalba?aaaa

在此网址中没有自定义字段。如果,从API,我联系PayPal获取销售详细信息,我得到的任何与我的自定义字段无关。

我做错了什么? 我正在考虑使用Cookie,但我更喜欢以标准方式进行。

  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
        <input type="hidden" name="cmd" value="_s-xclick">
        <input type="hidden" name="return" value="testestest">
        <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal è il metodo rapido e sicuro per pagare e farsi pagare online.">
        <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
    </form>

2 个答案:

答案 0 :(得分:2)

PayPal自定义变量在IPN(Instante付款通知)中返回,而非在用户完成付款后返回您的网站时返回。

在你的情况下,只需一个会话变量即可。

编辑:

另一种方法可能是在“return”字段中添加正确的url值。例如:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="return" value="http://www.website.com?pram=value">
    <input type="hidden" name="cancel" value="http://www.website.com?param=value">
    <input type="hidden" name="business" value="yourpaypal@email.com">
    <input type="hidden" name="item_name" value="Test">
    <input type="hidden" name="amount" value="9.00">
    <input type="hidden" name="currency_code" value="EUR">

    <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal è il metodo rapido e sicuro per pagare e farsi pagare online.">
   <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
</form>

答案 1 :(得分:0)

现有的答案已经提到IPN是要走的路,但缺少的是如何实际实现这一点的更多信息。

我最近自己必须这样做,所以这里有适合我的解决方案:

首先,您需要将自己的ID添加到&#34;立即付款&#34;按钮的HTML,例如进入&#34; custom&#34;变量,如问题所示。

在我自己的实现中,我在使用&#34; custom&#34;时遇到了一些问题。变量(不再记得细节),所以我将我的ID作为URL参数传递到IPN&#34;通知&#34;而是URL:

<input type="hidden" name="notify_url" value="https://example.com/notify/?id=xyz">

这是我的按钮的完整HTML代码:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="ABCDEFGHILJKLM">
    <table>
    <tr><td><input type="hidden" name="on0" value="Betrag">Betrag</td></tr><tr><td><select name="os0">
        <option value="Gebuehr">Gebuehr €3,50 EUR</option>
        <option value="Gebuehr und Spende">Gebuehr und Spende €5,00 EUR</option>
    </select> </td></tr>
    </table>
    <input type="hidden" name="currency_code" value="EUR">
    <input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">
    <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
    <input type="hidden" name="notify_url" value="https://example.com/notify/?id=xyz">
</form>

付款流程完成后,PayPal会将IPN message发布到我的通知网址,其中包含有关交易的大量信息(请参阅链接以获取更多信息)。< / p>

我的ID是通过URL参数传递的,所以我可以这样得到(在PHP中)

$uid = "";
if (!empty($_GET['id'])) {
    $uid = $_GET['id'];
}

当然,你需要check whether the IPN call is actually coming from PayPal

相关问题