dongqiao9394 2013-06-19 12:57
浏览 26
已采纳

将用户电子邮件与来自IPN的PayPal电子邮件相匹配

I'm configuring a PayPal IPN listener from this tutorial and ipnlistener.php.

When I need a user to pay, I show him this form

<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" 
    method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="<? echo $myPaypalEmail; ?>">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="item_name" value="Digital Download">
    <input type="hidden" name="amount" value="<? echo $price; ?>">
    <input type="hidden" name="return" value="THIS URL">
    <input type="hidden" name="notify_url" value="myhost.com/ipn.php">
    <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" 
        border="0" name="submit">
</form>

Following the guide, I correctly receive a POST request to the file ipn.php. I receive a lot of useful data about the payment but my problem is: how can I know which user made the payment?

A "user" is a person registering on my website, giving me personal informations and his/her email address. How can I connect these informations to the POST request I receive back from PayPal? The email used to register on my website may be different from the one used in PayPal.

I can think of 2 solutions:

a) Place a unique user id in the return URL, parse it with $_GET and then... This could hardly solve the problem.

b) Get the payment ID as soon as the transaction starts. But I have no idea on how to do that.

As you can see, my problem is to associate a user with the transaction id. The workflow is:

HTML Form -> Paypal website -> ipn.php

HTML Form has user info while ipn.php receive transaction info: I need the user info to go into ipn.php in order to check if the total has been correctly paid and to perform stuff on the user account. How can I do this?

Many thanks.

  • 写回答

2条回答 默认 最新

  • doutu1889 2013-06-19 19:10
    关注

    You could also pass the user ID in the "custom" field. This can be literally anything you want, up to 255 characters. This gets passed to Paypal and is sent in the IPN response as well. I use this field to distinguish between my various databases when I am storing IPN data.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示