Skip to content
Last updated

WHMCS\Module\Gateway\BalanceInterface

Interface · implements JsonSerializable

BalanceInterface is used as part of the WHMCS\Module\Gateway\Balance object to ensure that all required methods are present for output. Utilise the factory method to initialise the BalanceInterface object that will be added to a BalanceCollection object in your custom gateway module.

Methods

getAmount

public function getAmount(): Price

Get the amount for the BalanceInterface object as a WHMCS\View\Formatter\Price object.

Returns Price

getColor

public function getColor(): string

Get the color for the BalanceInterface object. e.g. #5dc560

Returns string

getCurrencyCode

public function getCurrencyCode(): string

Get the currency code for the BalanceInterface object.

Returns string

getCurrencyObject

public function getCurrencyObject(): ?Currency

Get the WHMCS\Billing\Currency object for the BalanceInterface object using the currencyCode as the query term. Will return null for an unknown currency.

Returns Currency\|null

getLabel

public function getLabel(): string

Get the label for the BalanceInterface item. This should be the translated value.

Returns string

factory

public static function factory(float $amount, string $currencyCode, ?string $label = null, ?string $color = null): BalanceInterface

Initialise the BalanceInterface object providing the data that will be used on output.

Parameters

TypeNameDescription
float$amountThe amount for the BalanceInterface object. e.g. 10.00
string$currencyCodeThe currency code for the BalanceInterface object. e.g. USD
string|null$labelThe language string to be used for the label. e.g. status.available
string|null$colorThe color to be used for the BalanceInterface object output. e.g. #5dc560

Returns BalanceInterface