简体   繁体   English

贝宝(Paypal)订阅IPN-用户多次订阅的问题

[英]Paypal subscriptions IPN - problem with users subscribing multiple times

I'm using paypal subscriptions and the instant payment notification (IPN) to handle subscribers on my site. 我正在使用Paypal订阅和即时付款通知(IPN)处理我网站上的订阅者。

For the most part it works well but there is one occasional problem I've encountered. 在大多数情况下,它运行良好,但偶尔会遇到一个问题。

Usually if a user cancels their subscription, I wait for the "end of term" (subscr_eot) notification before disabling access to my site. 通常,如果用户取消其订阅,则在禁用对我的网站的访问之前,我会等待“期限终止”(subscr_eot)通知。

So if they prepay for the whole month, and then cancel right away, they still have access for the rest of the month (as it should be). 因此,如果他们预付了整个月的费用,然后立即取消,则该月剩下的时间仍然可以访问(应该如此)。

But some users are having this problem where they: 但是某些用户在以下位置遇到此问题:

  1. Cancel their subscription 取消订阅
  2. Before the "end of term" is reached they decide to re-subscribe 在达到“学期结束”之前,他们决定重新订阅
  3. When the "end of term" is reached for their first subscription, my app receives the notification and fires off an email to the user with something like "your account has been disabled, if you ever want to sign up again, you can re-subscribe by clicking here". 当他们的第一个订阅达到“期限”时,我的应用会收到通知,并向用户发送一封电子邮件,提示您“您的帐户已被禁用,如果您想再次注册,则可以点击此处进行订阅”。
  4. This confuses them because they are thinking...that's weird, I thought I subscribed like a week ago (and they did). 这让他们感到困惑,因为他们在想...这很奇怪,我以为我像一个星期前一样订阅了(他们也这样做了)。 So they go subscribe AGAIN. 因此,他们再次订阅。 Now they have two concurrent running subscriptions to my site and I get a support email in a month or two ("wtf you billed me twice this month jerk!!") 现在他们有两个同时运行的对我网站的订阅,一两个月后我会收到支持电子邮件(“ wtf,您本月两次向我收取了帐单!”)

So I haven't found a good way to fix this. 所以我还没有找到解决这个问题的好方法。 I guess the best solution would be to do an additional API call when the "end of term" notification is received which asks paypal "hey did this person already re-subscribe?". 我想最好的解决方案是在收到“期末”通知时,再进行一次API调用,询问Paypal“嘿,这个人已经重新订阅了吗?”。 If so then no need to fire off that email. 如果是这样,则无需启动该电子邮件。 But I haven't seen any way to do this API call yet. 但是我还没有任何方法可以进行此API调用。

Another solution is to disable their account immediately when they cancel (the "subscr_cancel" notification) but then I get different angry support emails "hey I prepaid for the whole month why was my account disabled already!!". 另一个解决方案是在取消帐户时立即禁用其帐户(“ subscr_cancel”通知),但随后我收到不同的愤怒支持电子邮件:“嘿,我预付了整个月的费用,为什么我的帐户已经被禁用!”。

Anyone else solved this? 还有其他人解决吗?

I know this is an old thread, but I haven't seen an actual answer to this question, so if someone happens to wonder across this like I did, here's a solution. 我知道这是一个老话题,但是我还没有看到这个问题的实际答案,因此,如果有人像我一样想知道这个问题,那么可以找到一个解决方案。

If someone cancels their account (subscr_cancel) before their end of term (subscr_eot) I would set it up in my database to handle it. 如果有人在期满(subscr_eot)之前取消其帐户(subscr_cancel),我会在数据库中对其进行设置以进行处理。 For instance, if you have a "Users" table in your database, just add a new "int" field and call it "Term." 例如,如果您的数据库中有一个“用户”表,则只需添加一个新的“ int”字段并将其命名为“ Term”即可。 By default, this field should be set to "0." 默认情况下,此字段应设置为“ 0”。 Then, inside of your IPN, set it up so that if a user cancels their subscription before the end of the term, it sets the "Term" field for that user to "1." 然后,在您的IPN内部进行设置,以便如果用户在期限结束之前取消其订阅,则它将该用户的“期限”字段设置为“ 1”。 If that user goes back and re-subscribes to your services, have the IPN update the "Term" field for that user back to "0." 如果该用户返回并重新订阅您的服务,请让IPN将该用户的“期限”字段更新为“ 0”。

Then, inside of your mailing script, just have it check the "Term" field for that user when it runs for the end of term. 然后,在您的邮件脚本内部,当它在学期末运行时,请检查该用户的“学期”字段。 If it's set to "0" then don't send the email. 如果将其设置为“ 0”,则不要发送电子邮件。 If it's set to "1" then send the email saying, "Adios!" 如果将其设置为“ 1”,则发送电子邮件,说“ Adios!”。

How to prevent duplicate PayPal payments? 如何防止重复的贝宝付款?

You would want to add a unique identifier to the "invoice" parameter; 您可能想在“发票”参数中添加唯一标识符; and enable "Block duplicate payments" within the 'Profile' > 'My selling tools' section on your account at www.paypal.com 并在www.paypal.com上帐户的“配置文件”>“我的销售工具”部分中启用“阻止重复付款”

As far as I know there is no paypal api to examine subscriptions if you are using website payment standard/pro buttons, which I assume you are. 据我所知,如果您使用的是网站付款标准/专业按钮,则没有Paypal api可以检查订阅。

I deal with this by keeping the active/cancel/resubscribe state in my database and update the state based on the IPN messages I get from paypal. 我通过在数据库中保留活动/取消/重新订阅状态并根据从贝宝获得的IPN消息来更新状态来处理此问题。 I map the IPN messages to my uses with the custom field in the button, which is sent back on every IPN message. 我通过按钮中的custom字段将IPN消息映射到我的用途,该字段将在每条IPN消息上发送回去。

There are also a lot of third parties which help you manage this process since paypal's api is a little weak in this area. 还有很多第三方可以帮助您管理此过程,因为Paypal的api在此方面有些弱。 Recurly is one I've looked at and plan to implement, and there are others out there as well. 递归是我研究过并计划实施的一个,还有其他一些。

Cite: Re: When is subscr_eot issued? 引用: 回复:subscr_eot何时发布?

If you started accepting subscriptions after November 2009, the subscriber ID's will start ' I- ' - and will not return a 'subscr_eot' at the end of their time. 如果您在2009年11月之后开始接受订阅,则订阅者ID将以“ I- ”开头-并且在其时间结束时不会返回“ subscr_eot”。 Paypal expect you to keep note of how long they are subscribed for and update the account to downgrade (or whatever) when that period expires, unless the customer pays again in the meantime. 贝宝(Paypal)希望您能记住他们的订购时间,并在该期限到期时将帐户更新为降级(或其他任何方式),除非客户在此期间再次付款。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM