3 payment subscription

Discussion in 'aMember Pro v.4' started by pwwatson, Mar 31, 2012.

  1. pwwatson

    pwwatson aMember Pro Customer

    Joined:
    Jul 10, 2010
    Messages:
    17
    If I have a product that's set up to pay $50 for 3 months (payment split over 3 month period) will the user have a lifetime subscription to the product after that period? If not, what hook would you suggest and how do I find out how many payments for that product the user made?

    Thanks,
    Paul
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,412
    this is a little tricky, as setting the content item to "lifetime" will continue to give access to the product if they cancelafter 1 mos etc..
    So I think you will need to create 2 protected content items
    1) start to 2 mos.
    2) 2 mos to lifetime.

    David
  3. pwwatson

    pwwatson aMember Pro Customer

    Joined:
    Jul 10, 2010
    Messages:
    17
    I'm not sure what you mean. In version 3, there wasn't the ability to make 3 monthly payments for a product and then receive a lifetime subscription. I was wondering if this capability was introduced in version 4. If not, in version 3, I had a hook that checked for three payments for that particular product, and if there were, they the expiration date was set to lifetime. So, if this capability isn't in version 4, I was wanting to know how to find out how many payments for a particular product were made, since the code has changed so much.

    Thanks,
    Paul
  4. alex

    alex Administrator Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,009
    Paul,
    there is the same in product configuration in v4, but there is a change in content protection:
    at aMember Cp -> Protect Content, you can allow access "for lifetime".
  5. pwwatson

    pwwatson aMember Pro Customer

    Joined:
    Jul 10, 2010
    Messages:
    17
    I see. That won't work in my case as my software checks to see if they're currently subscribed for that product before allowing them to run the software. Thus I need the subscription to be for lifetime. So how do I find out how many payments for a particular product were made, so that I can change it's expire date?
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    5,912
    Here is example:
    PHP:
    function addAccess(Am_Event_PaymentAfterInsert $event){
        
    $invoice $event->getInvoice();
        
    $products $invoice->getProducts();
        
    $product_id $products[0]->pk();
        if(
    $invoice->getExpectedPaymentsCount() == $invoice->getPaymentsCount() && $product_id == 1){
            
    // Add access; 
                
    $access Am_Di::getInstance()->accessRecord;
                
    $access->begin_date date('Y-m-d');
                
    $access->expire_date '2037-12-31';
                
    $access->product_id $product_id;
                
    $access->user_id $invoice->user_id;
                
    $access->insert();
            
        }
    }
    Am_Di::getInstance()->hook->add('paymentAfterInsert''addAccess');
    Above will add lifetime access for product 1 when last payment for invoice will be received.
  7. pwwatson

    pwwatson aMember Pro Customer

    Joined:
    Jul 10, 2010
    Messages:
    17
  8. pwwatson

    pwwatson aMember Pro Customer

    Joined:
    Jul 10, 2010
    Messages:
    17
    Alex, is that adding lifetime access for product #1 or for the first product in that invoice?
  9. alex

    alex Administrator Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,009
    Yes, the first product in invoice. There likely must be a condition to add lifetimeaccess or not.
  10. fmagusto

    fmagusto aMember Pro Customer

    Joined:
    Nov 30, 2011
    Messages:
    235
    Hello
    I need the same thing, but to add nine months to the product that the person has paid. how?
    Thank
    Frederic
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    5,912
    Change that part:
    $access->expire_date = '2037-12-31';
    and set whatever you need date here.
  12. homescholar

    homescholar aMember Pro Customer

    Joined:
    Dec 3, 2008
    Messages:
    3
    i try to use this function but when we make the purchase using dummy credit card details the invoice is pending in amember and we can't get set the access. is this cause of dummy card details or do we need to use another event instead of PaymentAfterInsert? if we need to use another event then please let me know.

Share This Page