Paypal Cancellation Detection

I wrote a simple PayPal subscription system where a user can enter their information, click a button and start a subscription. I am wondering how I can find out when a user cancels a subscription? I saw $ txn_type subscr_cancel, but I have no idea how to use this, since paypal no longer calls my handler.

Thanks!

+7
handler php paypal paypal-ipn
source share
2 answers

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; } 
+23
source share

An IPN of type 'subscr_cancel' is sent when the user actually cancels the subscription. This should not be used to cancel the subscription, as this can happen at any time during the subscription period.

To unsubscribe, use an IPN of type "subscr_eot". This is sent when the user has expired.

+6
source share

All Articles