Pay Per Minute

Discussion in 'Customization & add-ons' started by dyter07, Mar 8, 2006.

  1. dyter07

    dyter07 New Member

    Joined:
    Jan 31, 2005
    Messages:
    8
    Hi there, just testing the Free Trial Version and the product is realy great, I like it.

    I need to setup a "Pay per Minute" Solution for a videochat site.

    Anyone having experience in this matter? It should be possible to make it...
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Unfortunately, aMember is unable do per minute billing.
  3. dyter07

    dyter07 New Member

    Joined:
    Jan 31, 2005
    Messages:
    8
    Regarding this matter I made some steps forward the last days. Can you tell me how aMember handels the "amember_payments amount" field?

    Because if aMember is updating this field every time on a purchase with the amount of money purchased than we may have the solution here allready. But by testing it manualy with a sample $10 transaction the amount is not added to the allready existing amount, its just writing $10 over. So if e.g. someone would have ordered $10 one time, than spends $3 and wants to order another $10 to the $7 left the result is $10 and not $17. Got what I mean? ;)
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Could you explain how do you want to implement your task, then I will be able to give you exact suggestion.
    aMember payments.amount field can be changed different ways and its behaviour depends on payment processor.
  5. dyter07

    dyter07 New Member

    Joined:
    Jan 31, 2005
    Messages:
    8
    Thanks, I use CCBill by the way.

    On a sucessful purchase the amount of the purchase must be added (!) to "amember_payments amount" thats all. Right now its simply overwriting the amount regardsless which amount is still in the field.

    Example: Client is buying for $10 and spends $3 in Videochat he will have $7 left. The right way is now when he will buy another $10 he must have $17 in the field. In the moment when he is buying the field is going up to $10.

    This way amember could handle pay per minute easely as far as I can say.

    Thanks a lot Alex ;)
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Here is right way :) described:
    1. You add 3 hidden fields to member profile (aMember CP -> Add Fields (SQL))
    balance - $ actual balance
    balance_credit - $ paid by member
    balance_debit - $ used by member
    2. You need to create a file amember/site.inc.php and implement the following hooks as described in the manual:
    - update_payments($payment_id)
    - finish_waiting_payment($payment_id)
    and code something like that in amember/site.inc.php:

    PHP:
    <?php
    function fwp($payment_id){
       global 
    $db;
       
    $p $db->get_payment($payment_id);
       
    $u $db->get_user($p['member_id']);
       
    /// find out balance_credit 
      
    $bc 0;
      foreach (
    $db->get_user_payments($p['member_id'], 1) as $pp){
         
    $bc += $pp['amount'];
      }
      
    $u['balance_credit'] = $bc;
      
    $u['balance'] = $u['balance_credit'] - $u['balance_debit'];
      
    $db->update_user($p['member_id'], $u);
    }
    setup_plugin_hook('update_payments''fwp');
    setup_plugin_hook('finish_waiting_payment''fwp');
    ?>
    That way balance and balance_credit in user profile will be automatically maintained. You should not change payment records manually or with code at all.
    3. In your code, you should maintain balance_debit and balance fields, and check value of balance field for decision - give access or not.

Share This Page