R – How to Handle Cancelled Recurring Payments

paymentpaypalrecurring

I'm using Paypal to handle automated recurring payments for my website. Users pay to subscribe to my website so they can get periodic newsletters.

So let's say a customer cancels their membership a few months later. They do this by logging into Paypal and cancels future automated payments. How should I update my website to reflect this cancellation?

The first solution I'm thinking of is to schedule a cronjob that executes a script every midnight to update my database with information from Paypal.

The second solution is on newsletter mailout day, I execute a script to update my database with information from Paypal. The website will also execute the script every time a user "logs in" to my website.

Are there better ways to do this?

Best Solution

If I understand correctly, Paypal's servers will update yours automatically when the status of a subscription changes, if you have this configured. This is called IPN (Instant Payment Notification) and does indeed include cancellation notification. Here's the Paypal documentation for recurring (subscription) payments. Additionally you can poll their servers using their API for this information, so if you'd prefer to fetch it yourself, you can.

Related Question