Parsing PayPal Subscription Ran Out

2019-01-26 21:25发布

On PayPal subscriptions, it appears that all I need to do is treat it like a regular IPN except look at the txn_type field. When I see one of the following status codes, I send an email to the admin to consider expiring that member manually in the admin panel of my software I'm building in PHP.

The statuses appear to be one of the following to indicate the customer either cancelled, had an end of term, or simply isn't paying anymore. Can anyone confirm that these are the right statuses to check for, or have I included a couple that aren't right?

  • subscr_cancel
  • subscr_eot
  • subscr_failed
  • recurring_payment_failed
  • recurring_payment_suspended_due_to_max_failed_payment
  • recurring_payment_outstanding_payment_failed
  • recurring_payment_profile_cancel
  • recurring_payment_expired

3条回答
手持菜刀,她持情操
2楼-- · 2019-01-26 21:29

I know i'm kind of late in this post, but here is a quick solution (php) for your question:

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;
 }
查看更多
老娘就宠你
3楼-- · 2019-01-26 21:42

I found that these are the ones to watch regarding "end of membership" type reactions in my code:

  • subscr_cancel
  • subscr_eot
  • recurring_payment_profile_canceled
  • recurring_payment_expired

All others are just "noise" regarding "end of membership" status. For instance, to react to any payment "failure" type IPNs would be wrong because eventually PayPal may rectify that problem with the customer after a reattempt, and so cancellation and expiration events are really what you should look for.

查看更多
干净又极端
4楼-- · 2019-01-26 21:46

If you've gone through the subscription button mechanism, and it's not one of the pre-approved recurring payment things then you'll only see the "subscr" prefixed ones, I think.

I personally don't respond to "subscr_cancel" in my app. The IPN for that is sent the moment the users cancels. I don't want to disable their access at that point so I wait for the "subscr_eot" one and do it then.

So if they sign up for a year, and cancel the next day, they still have access to the end of the year, which is when PayPal will send the "subscr_eot". They'll always send both.

查看更多
登录 后发表回答