Skip to content

Credits

Plugin allows to sell "credits" - count of credits will be configured in product billing plan settings, and added to user account after purchase. This module does not have any consumer-visible part, it just provides API that developers may use to implement its own "credits" billing system base on aMember.

  • Sell limited count of downloads from big files catalog
  • Sell time-based access to website or software
  • Sell service tickets
  1. Code to deduct "credits" must be implemented by your system!
  2. Credits are not expiring with subscription (!). aMember does not take account of subscription dates at all when accounting credits
  3. Once accounted, credit records are not updated if product setting changed
require_once 'path/to/amember/bootstrap.php';
$plugin = Am_Di::getInstance()->plugins_misc->loadGet('credits');
// no comment, for currently logged in user
$plugin->debit(120);
// with comment, for currently logged in user
$plugin->debit(120, "Used 120 credits");
// debit 120 credits from user# 1234
$plugin->debit(120, "Used 120 credits", 1234);
// balance - get current number of credits, for currently logged in user
$plugin->balance();
// balance - get current number of credits, for user# 1234
$plugin->balance(1234);
//credit 120 credits for currently logged in user
$plugin->credit(120, "Add 120 credits");
//credit 120 credits for user# 1234
$plugin->credit(120, "Add 120 credits", 1234);