Kevin Carwile

Points PHP API: Get A Member Balance


The following api method is made available through the points economy application to get the points balance for a member.

Get A Member Balance

class \IPS\Member

/**
* Get Balance
*
* @param	int|\IPS\points\Currency	$currency		Currency or currency id
* @param	int|\IPS\points\Bank		$bank			Bank or bank id
* @return	\IPS\points\Balance
* @throws	\IPS\points\Exception	An exception is thrown if the balance is not permitted
*/
public function balance( $currency, $bank=0 );

Example:

/* Load member */
$member = \IPS\Member::load( 1 );

try
{
    /* Get member balance for currency #1 and bank #0 ( spending account ) */
    $balance = $member->balance( 1, 0 );

    /* Total balance amount */
    $total = $balance->amount;

    /* Available balance amount */
    $available = $balance->available;

    /* Get Amount Being Held */
    $holding = $balance->holding;

    /* Get Amount Of Unclaimed Credit */
    $unclaimed = $balance->unclaimed;

    /* Get Amount Of Pending Debits */
    $unpaid = $balance->unpaid;
}
catch( \IPS\points\Exception $e )
{
	/* Points balance is not permitted */
	$reason = $e->getMessage();
}

 


  • Like 1
  Report Article


User Feedback


There are no comments to display.