如何将 Paypal IPN 确认连接到用户?
我想使用 Paypal 的 IPN 服务来验证我的网站的定期订阅费付款。 如何将 IPN 确认与站点中的用户联系起来?
IPN 确认消息有姓名、电子邮件、paypal ID、定期付款 ID,但它似乎没有给出唯一标识符,因为我不知道 paypal ID 或定期付款 ID 来自哪里,而且它可能不是微不足道的唯一标识符将用户在其 PayPal 帐户上(或在其中输入)的姓名/电子邮件与我在我的网站上为他们提供的姓名/电子邮件进行匹配(可能有很多 John Smith,并且该人可能会选择使用不同的电子邮件。)
1) 当我向 Paypal 发送初始付款请求时,我可以在要求他们发回给我的 URL 中附加一个唯一的 UUID,因此,如果我为该用户保存该唯一 ID,我可以将该付款确认信息与该用户进行匹配发起了它。 我是否让事情变得更加困难了? 有更容易的方法吗?
2) 另外,对于定期/订阅费用,PayPal 是否始终使用我在初始付款启动时指定的 URL? 是否有人有使用 IPN 定期 Paypal 付款的实际经验,它是否重复使用该唯一 URL? 或者在收到第一笔定期付款后我是否必须将 Paypal ID 与用户关联?
I wanted to use Paypal's IPN service to verify payments for a recurring subscription charge for my website. How do you tie the IPN confirmations to a user in your site?
The IPN confirmation message has a name, email, paypal ID, recurring payment ID, but it seems to not give a unique identifier since I don't know where the paypal ID or recurring payment id comes from and it may not be trivial to uniquely match up the name/email that a user has on their paypal account (or entered there) with the name/email I have for them on my site (there may be many John Smith's and the person may choose to use a different email.)
1) When I send the initial payment request to Paypal, I can attach a unique UUID in the URL I ask them to send back to me, so if I save that unique ID for that user I can match that payment confirmation to the user who initiated it. Am I making that harder than it is? Is there an easier way?
2) Also, for a recurring/subscription charge, does paypal always use the URL I specified with the initial payment initiation? Does anyone have practical experience using the recurring Paypal payments with IPN's, does it reuse that unique URL? Or do I have to associate the Paypal ID's with the user after the first recurring payment is received?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将唯一数据附加到付款请求几乎是公认的方法。
我对重复收费没有任何经验。
Attaching unique data to the payment request is pretty much the accepted way to do it.
I don't have any experience with recurring charges.
我最近还使用 Paypal 设置了一些定期付款。
我实际上希望人们在支付订阅费用后注册成为会员,如果他们愿意的话。 因为必须注册成为会员可能会给销售过程增加一些摩擦。 因此,我不会随订阅按钮一起发送任何用户信息。
我的 IPN 脚本的作用是生成一个与激活表中的 Paypal 订阅 ID 绑定的唯一激活代码,然后将此代码发送给支付订阅费用的任何人,并附上有关如何激活的说明。
激活时,您需要注册或登录。 此时,用户 ID 已添加到激活表中的相关行。
当 EndOfTerm IPN 通知出现在 IPN 脚本中时,IPN 脚本会根据 IPN 中给出的订阅者 ID 从激活表中查找用户 ID。 然后我可以对该用户执行任何我需要执行的操作来禁用他们的订阅。
IPN 脚本的 URL 始终保持不变。
I recently also set up some reoccurring payments with Paypal.
I actually wanted people to register as members after paying for the subscription, if they wanted to. As having to sign up as a member could add some friction to the sale process. So I don't send any user info along with the Subscribe button.
What my IPN script does is generate a unique activation code tied to the Paypal subscriptionID in the Activations table, then it sends this code to whoever paid for the subscription, with instructions on how to activate.
At the point of activation, you need to register or login. At this point the userID is added to the relevant row in the Activations table.
When the EndOfTerm IPN notification comes in the IPN script looks up the userID from the Activations table based on the SubscriberID given in the IPN. Then I can do whatever I need to do to that user to disable their subscription.
At all time the URL of the IPN script remains the same.
1) 您可以发送带有初始订阅设置的“item_number”参数,该参数将传回给您。 我建议在其中嵌入一个识别令牌。
2) 如果您指的是“返回”参数,则不是,该参数用于在订阅设置结束时将用户发送至该参数。 续订是自动的,不会“ping”该页面。
1) You can send an 'item_number' parameter with the initial subscription setup, which will get passed back to you. I'd suggest embedding an identification token in it.
2) If you mean the 'return' parameter, no, that's for sending the user to at the conclusion of the subscription setup. The renewal is automatic and doesn't 'ping' that page.
1) 您想要使用
item_number
参数。 在向客户显示的 HTML 表单中设置此项,它将通过 paypal IPN 返回给您,因此您可以在此处放置数据库行 ID,并在以后使用它来匹配正确的人。1) You want to be using the
item_number
parameter. Set this in your HTML form shown to the customer, and it will be returned to you by the paypal IPN, so you can put a database row ID in here, and use it to match up to the right person later.