3 payment subscription

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

  1. pwwatson aMember Pro Customer

    Member Since:
    Jul 10, 2010
    Message Count:
    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 aMember User & Partner

    Member Since:
    May 16, 2006
    Message Count:
    4,400
    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 aMember Pro Customer

    Member Since:
    Jul 10, 2010
    Message Count:
    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 Administrator

    Member Since:
    Jan 24, 2004
    Message Count:
    6,008
    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 aMember Pro Customer

    Member Since:
    Jul 10, 2010
    Message Count:
    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 Administrator

    Member Since:
    Jan 8, 2003
    Message Count:
    5,909
    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 aMember Pro Customer

    Member Since:
    Jul 10, 2010
    Message Count:
    17
  8. pwwatson aMember Pro Customer

    Member Since:
    Jul 10, 2010
    Message Count:
    17
    Alex, is that adding lifetime access for product #1 or for the first product in that invoice?
  9. alex Administrator

    Member Since:
    Jan 24, 2004
    Message Count:
    6,008
    Yes, the first product in invoice. There likely must be a condition to add lifetimeaccess or not.
  10. fmagusto aMember Pro Customer

    Member Since:
    Nov 30, 2011
    Message Count:
    234
    Hello
    I need the same thing, but to add nine months to the product that the person has paid. how?
    Thank
    Frederic
  11. alexander Administrator

    Member Since:
    Jan 8, 2003
    Message Count:
    5,909
    Change that part:
    $access->expire_date = '2037-12-31';
    and set whatever you need date here.
  12. homescholar aMember Pro Customer

    Member Since:
    Dec 3, 2008
    Message Count:
    2
    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