Paypal付款结果 - 检查谁支付了什么

时间:2014-07-25 21:30:21

标签: php paypal web paypal-ipn

一般来说,我正在寻找一种方法来确定谁付出了什么"当我收到Paypal付款时。

我正在开发一个电子商务网站,并尝试使用PayPal作为付款方式。但是,我对如何将响应(来自Paypal的IPN消息,我目前打算单独依赖)与我网站上发生的特定交易相关联感到困惑。

我的预期是,当客户点击我的paypal按钮付款时,我可以告诉paypal"嗨,这是一个ID为1234"的交易;然后paypal可以告诉我"交易1234已完成\取消"。但是,我没有找到一些" stamp"我可以进行交易,以便我知道谁为什么付了钱。 txn_id变量似乎接近我的预期,但正如我现在所理解的,它是由paypal生成的,而不是由我分配的。

我还想过在我发送给paypal的redirect_url上做一些技巧。可能是我可以为每个交易生成一个网址,将该网址作为代码发送给paypal;所以,当有人请求我知道该交易只支付PayPal,我知道该网址的存在。但是,我不确定这种方法的安全性,并认为可能还有其他方法。

提前感谢任何想法或方向!

2 个答案:

答案 0 :(得分:1)

在我的情况下,与custominvoice合作可以将它们发送回notify_url链接。

答案 1 :(得分:1)

你可以像这样使用paypal按钮 - 只需替换适当的值并更新

<input type="hidden" name="custom" value="90"> 

使用js动态值。然后,您可以访问 notify_url

中的自定义字段
<div class="paypal-button-loader-script-tag">
    <form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" class="paypal-button" target="_top">
        <div class="hide" id="errorBox"></div>
        <input type="hidden" name="button" value="buynow data-quantity=">
        <input type="hidden" name="amount" value="1">
        <input type="hidden" name="currency_code" value="USD">
        <input type="hidden" name="item_name" value="Moneyfan">
        <input type="hidden" name="notify_url" value="yourwebsite.com">
        <input type="hidden" name="custom" value="90">
        <input type="hidden" name="return" value="http://yourwebsite.com">
        <input type="hidden" name="cancel_return" value="http://yourwebsite.com">
        <input type="hidden" name="env" value="www.sandbox">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="business" value="example.com">
        <input type="hidden" name="bn" value="JavaScriptButton_buynow data-quantity=">
        <button type="submit" class="paypal-button large">undefined</button>
    </form>
</div>
相关问题