How to get which invoice id an active product was purchased on ?

Discussion in 'aMember Pro v.4' started by spicyniknaks, Apr 23, 2012.

  1. spicyniknaks

    spicyniknaks New Member

    Joined:
    Feb 27, 2012
    Messages:
    20
    I am writing a plugin and the problem I have is that I want to get the invoice id that contains an active product. I know how to navigate through the invoices and items and how to get active product id's, however with the following scenario I have problems tracking which invoice the active product is in.

    Scenario
    1. Someone purchases a product
    2. A PayPal refund/chargeback is issued. ( After PayPal refund the invoice is still marked as "Paid" which I think is misleading/incorrect)
    3. The customer still has access and then re-purchases the same product
    4. A new invoice is issued

    Now, if I parse through all invoices for a user and all items in each invoice I am unable to see anything in the invoice or item model which indicates which one contains the active product. I am guessing that I could go through the payments and work out which one had the refund applied and ignore those invoices, but I am sure there must be a better way.

    If the invoice was marked as "Not Paid" or "Cancelled" when a refund/chargeback for the same or greater purchase value was applied to it then that would be the best solution as I could just ignore those invoices.

    If anyone has any pointers then that would be much appreciated.
  2. spicyniknaks

    spicyniknaks New Member

    Joined:
    Feb 27, 2012
    Messages:
    20
    After a bit more digging I am now able to get all the payments for an invoice and all the refunds for an invoice but I don't think aMember links specific payments to specific products, it seems to operate more of a general pot where payments are made into for each invoice.

    I can match the invoice to a product and I can see payments, but payments don't seem to be linked to individual products. I guess this is because not all aMember "products" are actually physical products and more of a generic purchasable item.

    So I think I am correct in saying that if someone purchases two products e.g. Product 1 & Product 2 and then asks for a refund of Product 2 then you can't refund a specific line item on the invoice the way most systems work, you can only issue a refund for the whole amount or a partial refund. So if you refund for the value of Product 2 then your system can't automatically prevent access for users who don't have Product 2.

    I would like to find a solution to this, but I think this is going to be more involved than I had hoped.
  3. spicyniknaks

    spicyniknaks New Member

    Joined:
    Feb 27, 2012
    Messages:
    20
    Just to update anyone else that is looking at this. I have done some more testing with purchasing multiple products and I see that you can't do partial refunds through aMember, although you can through PayPal. If you do a partial refund through PayPal then aMember records the partial refund amount, but treats the refund as a total refund and removes access to all products purchased - which I think is fine.

    It's good to know just exactly how payments and refunds are handled within aMember, it's just very time consuming trying all the different permutations.

Share This Page