Detect Paypal Cancelation for certain product and perform PHP Actions

Discussion in 'Payments processing' started by adbox, Jul 2, 2012.

  1. adbox

    adbox New Member

    Joined:
    May 11, 2011
    Messages:
    6
    Hello!

    I know my IPN is in /plugins/payment/paypal_r.php, but how do I detect a subscription cancellation for a certain product id so I can revoke license key privileges for those product?

    Is there a better way to do this?

    Also, is an easy way to pull the paypal id email address from the user's amember username?

    Also is there an easy way to synchronize vbulletin users table with amember via cron, allowing certain vb usergroups to have certain privledges?

    Thanks for your help!
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can use subscription_deleted hook for this. It will be executed when subscription expire.
    http://manual.amember.com/Creating_....24member_id.2C_.24product_id.2C_.24member.29
    Here is example:
    PHP:
    foreach($db->get_user_payments($user_id1) as $p){
    foreach(
    $p['data'] as $k=>$v){
      if(
    is_array($v) && array_key_exists('payer_email'$v)){
      
    //   $v['payer_email']  is payment sender email address. 
      
    }
    }
    }
    Why you want to do this from cron? vBulletin plugin already do this instantly.
  3. adbox

    adbox New Member

    Joined:
    May 11, 2011
    Messages:
    6
    Thank you very much for the information it's already very helpful .

    I'm in the process of writing my first plugin now. More on the paypal id though. I'm building a protected area that displays a license key & license email and and I'll use the paypal email id to generate the license key and leave the license email just as the paypal id.

    Is there a way that I can pull the user id from the _amember_user session?

    Here's an example of my protected area's code:


    PHP:
    <?php
    session_start
    ();
    $_product_id = array(3);
    include_once(
    './plugins/protect/php_include/check.inc.php');
    include_once(
    './custom_functions.php');
    $user $_SESSION['_amember_user'];
    $first_name $user[name_f];
    $last_name $user[name_l];
    $email $user[email];
    //$paypalid = ?
    Thanks again for you help your are helping move forward in strides.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Do you mean aMember user id? use this:
    $_SESSION[_amember_id];
    If you need paypal email:
    PHP:
    foreach($db->get_user_payments($_SESSION[_amember_id], 1) as $p){
    foreach(
    $p['data'] as $k=>$v){
      if(
    is_array($v) && array_key_exists('payer_email'$v)){
      
    //   $v['payer_email']  is payment sender email address. 
      
    }
    }
    }

Share This Page