ericlee
ericlee

Reputation: 2753

PayPal recurring payment cancelled with remaining days

I've a subscription-based membership, however I encountered the following problem:

  1. User subscribed on May 1st 2012 with a monthly indefinite payment.
  2. IPN sent to server, activating subscription
  3. User cancelled on May 3rd 2012.
  4. IPN sent to server, subscription is cancelled and server cancelled the membership.

However as the user subscribed on May 1st 2012, he still has some days left if he were to cancel before one month. Any way to solve this? Does PayPal sends any IPN for this type of issue?

One solution I thought of is doing a cronjob every night to check if the month is up.

Upvotes: 7

Views: 2398

Answers (4)

Ondřej Ševčík
Ondřej Ševčík

Reputation: 1599

It is pretty old (2012) question but I was able to Google it when I was looking for that information in 2019.

Right now, PayPal webhook for cancelled payment includes date of the next payment. This means you can mark user status as cancelled and set his account expiry date to the next payment date.

The relevant information is inside .resource.billing_info.next_billing_time

Upvotes: 1

Allen Crider
Allen Crider

Reputation: 21

One of the D/V pairs in the IPN message is next_payment_date followed by a date presented like this: 03:00:00 Jul 06, 2013 PDT

I convert the date to YYYY-MM-DD and store that in the database in addition to the profile_status value which comes in the IPN message. When an individual subscribes, I also have a simple TRUE/FALSE subscriber cell in the database.

So if a subscriber cancels, their profile_status is updated in the database to 'Cancelled' and the subscriber cell updated to FALSE.

When a user visits premium content, the subscriber cell in database is checked for TRUE. If so, they get the content. If FALSE, then the profile_status cell is checked and if that cell is 'Expired' or NULL, then they don't get content. If the cell's content is 'Cancelled', then the next_payment_date data is pulled, one day added (to deal with the timezone issue) and if it is greater than the current time, the premium content loads. If it is less than the current date, then their profile_status cell is updated to 'Expired' and the they don't get content.

Upvotes: 2

Ja͢ck
Ja͢ck

Reputation: 173572

When we implemented subscription services on our own website, we basically handle the events like this:

  • subscription confirmation - we mark the user's subscription on our server as "automatic renewal"
  • money received - we move the user's subscription expiry date based on the agreed term (monthly or yearly); using trial periods, this event only gets sent when the trial period finishes
  • subscription cancelation - we mark the user's subscription on our server as "manual renewal"
  • money refunded - we move the user's subscription expiry date back based on the agreed term.

Upon user sign in, we check whether the subscription has expired (which is easy if you store that in your db).

Basically, subscription events are separate from payment events. A subscription can be cancelled but that doesn't mean the payment gets refunded; that would be a separate event.

Btw, payment and subscription events can come in different order (e.g. payment can come first, followed by subscription notification); it's important to cater for that.

Upvotes: 4

zolipapa
zolipapa

Reputation: 676

When user subscribes, paypal will create a recurring payment profile, which means the user will have to pay monthly (yearly, daily depending on the profile) the sum, on the day he subscribed (ex. 1st May, 1st June, 1st July). When the user cancels, he cancels the payment profile, not the payment itself. So after that paypal will not ask for any other payment. If you want to give the user the days, which were left you have to store the information about the subscription.

You can store in a db the day he subscribed and the day he cancelled.From there you can tell how many days the user still has. Paypal sends IPN messages both on the creation of the recurring payment profile, on the payment itself and on the cancel as well.

You can find information on the IPN messages here: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

Upvotes: 2

Related Questions