Michael Watson
Michael Watson

Reputation: 1119

Paypal IPN get subscription end date (recurring)

I'm developing a site that has annual or monthly paypal subscription options. From the IPN data that receives, can I determine if the subscription is annual or monthly? Doesn't seem possible.

At the moment it's set up just for monthly payments, so in my own db I store something along the lines of:

$data = array(              
              'id'                  => $ipnData['custom'],
              'subscribed'          => 1,
              'subscription_fee'    => $ipnData['mc_amount3'],
              'subscribed_until'    => date("Y-m-d H:i:s",strtotime($ipnData['subscr_date'] . '+1 Month'))
              );

You'll see I'm using the subscription_date variable and just incrementing it by a month. But now, potentially subscriptions can be annual, and I need somehow to get the date in which the next payment would be taken. This doesn't seem to be a variable? A return of the original T3 would be great.

I can do this with custom fields, but that seems a bit daft. Cheers.

Upvotes: 2

Views: 1038

Answers (1)

Chris Greenwood
Chris Greenwood

Reputation: 1216

PayPal will send a notification when the subscription ends: txn_type = "subscr_eot"

The moment you receive this is the moment the subscription expires. This is when you would downgrade/cancel their account. Note that this is different from txn_type="subscr_cancel" which is triggered when a user cancels their subscription; this could be the day after they subscribe and they may have time remaining on the subscription. In this case you will still receive the subscr_eot when the time runs out.

I also found this to be a bit counter-intuitive.

Upvotes: 4

Related Questions