检测贝宝订阅取消 [英] Detecting Paypal Subscription Cancellation

查看:71
本文介绍了检测贝宝订阅取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个简单的Paypal订阅系统,用户可以在其中输入信息,单击按钮并开始订阅.我想知道我如何确定用户何时取消订阅?我已经看过$ 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.

谢谢!

推荐答案

您是否正在使用IPN(如果是),那么当取消订阅时,贝宝会返回$_POST['txn_type'] = subscr_cancel以及subscr_date =订阅日期,subscr_id =订阅ID等,现在您可以处理对返回的订阅ID的取消请求. 同样,订阅结束时,您会得到$_POST['txn_type'] = subscr_eot. 在贝宝设置中设置IPN网址后,它将始终调用您的ipn处理程序. 像这样使用switch case处理不同的请求,

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;
 }

这篇关于检测贝宝订阅取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆