Detecting Paypal Subscription Cancellation

后端 未结 2 1869
别那么骄傲
别那么骄傲 2020-12-29 12:23

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 whe

相关标签:
2条回答
  • 2020-12-29 13:01

    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.

    0 讨论(0)
  • 2020-12-29 13:06

    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;
     }
    
    0 讨论(0)
提交回复
热议问题