Do you use IPN, if so, then when the subscription is canceled, paypal returns $_POST['txn_type'] = subscr_cancel along with subscr_date = date of subscription, subscr_id = identifier of the subscription, etc. you can now process the cancellation request for the returned subscription id. Similarly, you get $_POST['txn_type'] = subscr_eot when the subscription ends. Once you set the IPN URL in PayPal settings, it will always call your ipn handler. use the switch case to handle various requests, e.g.
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; }
Pragati sureka
source share