检测 Paypal 订阅取消

发布于 2024-08-18 12:17:45 字数 143 浏览 2 评论 0原文

我编写了一个简单的贝宝订阅系统,用户可以在其中输入他们的信息,单击按钮,然后开始订阅。我想知道如何知道用户何时取消订阅?我已经看到 $txn_type subscr_cancel 但我不知道如何使用它,因为 paypal 不会再次调用我的处理程序。

谢谢!

I have written a simple paypal subscription system, where a user can enter their information, click the button, and start a subscription. Im wondering how I can find out when the user cancels the subscription though? I have seen $txn_type subscr_cancel but I have no idea how to use that, since paypal doesn't call my handler again.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

城歌 2024-08-25 12:17:45

您是否使用IPN(如果是)那么,当取消订阅时,PayPal 返回 $_POST['txn_type'] = subscr_cancel 以及 subscr_date = 订阅日期、subscr_id = 订阅 ID 等,现在您可以处理取消请求返回的订阅 ID。
同样,订阅结束时您会得到 $_POST['txn_type'] = subscr_eot
一旦您在 paypal 设置中设置了 IPN url,它将始终调用您的 IPN 处理程序。
使用 switch case 来处理不同的请求,如下所示,

switch ($_POST['txn_type']) {
    case 'cart':
          //for products without subscription
     break;
    case 'subscr_payment':
        //subscription payment recieved
        break;

    case 'subscr_signup':
        //subscription bought payment pending
        break;

    case 'subscr_eot':
       //subscription end of term
        break;

    case 'subscr_cancel':
        //subscription canceled
        break;
 }

Are you using IPN if yes then, when a subscription is cancelled paypal returns $_POST['txn_type'] = subscr_cancel along with subscr_date = subscription date, subscr_id = subscription ID, etc now you can process cancel request for the returned subscription id.
similarly you get $_POST['txn_type'] = subscr_eot when subscription ends.
Once you have setup IPN url in the paypal settings it will always call your ipn handler.
use switch case to handle different requests like so,

switch ($_POST['txn_type']) {
    case 'cart':
          //for products without subscription
     break;
    case 'subscr_payment':
        //subscription payment recieved
        break;

    case 'subscr_signup':
        //subscription bought payment pending
        break;

    case 'subscr_eot':
       //subscription end of term
        break;

    case 'subscr_cancel':
        //subscription canceled
        break;
 }
岁月染过的梦 2024-08-25 12:17:45

当用户实际取消订阅时,会发送类型为“subscr_cancel”的 IPN。这不应该用于取消订阅,因为这可能在订阅期间的任何时候发生。

应使用“subscr_eot”类型的 IPN 来取消订阅。当用户的订阅期到期时发送此消息。

The IPN with a type of 'subscr_cancel' is sent when the user actually cancels the subscription. This should not be used to cancel the subscription as this can happen anytime during the subscription period.

The IPN with the 'subscr_eot' type should be used to cancel the subscription. This is sent when the user's subscription period has expired.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文