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
| Property | Returns | Description |
|---|---|---|
| currencyId | String | Unique 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.
| Parameter | Description |
|---|---|
entity | the 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.
| Parameter | Description |
|---|---|
c | the cart the debit is for |
debitItems | the 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.
| Parameter | Description |
|---|---|
c | the cart the debit is for |
debitItems | the individual line items to debit |
parameters | payment-related form parameters supplied by the caller |
websiteBranch | the 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.
| Parameter | Description |
|---|---|
c | the cart the debit is for |
debitItems | the individual line items to debit |
parameters | payment-related form parameters supplied by the caller |
profile | the profile whose account is debited |
websiteBranch | the 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.
| Parameter | Description |
|---|---|
entity | the entity whose balance is checked |
amount | the 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.
| Parameter | Description |
|---|---|
profile | the profile making the purchase |
org | the profile's organisation |