Represents a type of currency that can be used to make payments in the shopping cart. Different currencies are not interchangeable. In this context "currency" includes actual physical currencies like USD or AUD, as well as things that act as a means of payment within Kademi without being real-world currencies, such as reward points or trade dollars. Implementations know how to check and debit an entity's balance, and are looked up by their currency id when a cart is checked out.


Properties

PropertyReturnsDescription
currencyIdStringUnique identifier for this type of currency, used to look it up when checking out a cart.

Methods

balance(BaseEntity entity)

Returns: BigDecimal

Calculates the current balance of this currency held by the given entity, for example a profile or organisation.

ParameterDescription
entitythe entity whose balance is calculated

debit(Cart c, List<DebitItem> debitItems)

Returns: void

Debits the appropriate account for the given cart by the total of the supplied debit items.

ParameterDescription
cthe cart the debit is for
debitItemsthe individual line items to debit

debit(Cart c, List<DebitItem> debitItems, Map<String,String> parameters, Branch websiteBranch)

Returns: String

Debits the appropriate account for the given cart by the total of the supplied debit items, using the given form parameters and website branch to complete the payment.

ParameterDescription
cthe cart the debit is for
debitItemsthe individual line items to debit
parameterspayment-related form parameters supplied by the caller
websiteBranchthe website branch the payment is being made against

debit(Cart c, List<DebitItem> debitItems, Map<String,String> parameters, Profile profile, Branch websiteBranch)

Returns: String

Debits the appropriate account for the given cart on behalf of the given profile, by the total of the supplied debit items.

ParameterDescription
cthe cart the debit is for
debitItemsthe individual line items to debit
parameterspayment-related form parameters supplied by the caller
profilethe profile whose account is debited
websiteBranchthe website branch the payment is being made against

getCurrencyId()

Returns: String

Unique identifier for this type of currency, used to look it up when checking out a cart.

isBalanceSufficient(BaseEntity entity, BigDecimal amount)

Returns: boolean

Checks whether the given entity's balance in this currency is at least the given amount.

ParameterDescription
entitythe entity whose balance is checked
amountthe amount that must be available

isForEntity(Profile profile, Organisation org)

Returns: BaseEntity

Resolves the entity, either the profile or its organisation, that holds the account for this currency.

ParameterDescription
profilethe profile making the purchase
orgthe profile's organisation
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.