Amounts
A total cart amount is not passed to OmniCart by a single property. Instead, amounts are specified per item identifier. This allows flexible control over the payment life cycle.
During the payment life cycle amounts can be canceled or refunded fully and partially.
See the Payment Life Cycle section for more information on the items payment life cycle.
init
and modify
requests
The amount
property is passed with the init
or modify
request. The optional amountMode
property defines how OmniCart will treat the value passed in the item amount
property. The available options for amountMode
are declared
and calculated
. amountMode
can be defined at the cart, tag, and item level.
By default, amountMode
is declared
.
"amountMode": "declared"
If amountMode
is set to declared
, the value of the amount
property is included in the payment form exactly as it was received form from by OmniCart. The additional quantity
and amuntModifier
properties are saved in OmniCart but have no effect on the final item price.
"amountMode": "calculated"
If amountMode
is set to calculated
, the amount
value is the price per unit of goods (actual items, liters, minutes, etc.). The final price is a product of the amount
, quantity
, and amountModifier
values.
quantity
- number or volume of goods. Can be a whole number or a decimal fracture. For example, you can sell mana in bottles or in liters.amountModifer
- additionalamount
multiplier. You can use it to apply discounts or for any purpose you see fit.
Technically, quantity
and amountModifer
are just amount
multipliers. However, quantity
can be defined only at the item level while amountModifer
can be defined at the cart, tag, and item level.
properties that affect the final item price
- declared
- calculated
"gems": {
"amount": 5000,
"quantity": 4,
"paymentFilter": {
"amountMode": "declared",
"amountModifier": 0.7,
}
}
In the example above, amountMode
is declared
. That means only the amount
value is taken into account. The final price for the gems
item is 5000
.
The quantity
and amountModifier
properties are stored by OmniCart but they do not affect the final item price.
"gems": {
"amount": 5000,
"quantity": 4,
"paymentFilter": {
"amountMode": "calculated",
"amountModifier": 0.7,
}
}
In the example above, amountMode
is calculated
. That means the final price is calculated by OmniCart upon receiving the init
or modify
request. The final item price is a product of amount
, quantity
, and amountModifier
, that is, 14000
.
The result is rounded to the nearest whole number. If the resulting number is less than 1
, OmniCart will return an error.
status
request
totalAmounts
and itemAmounts
objects
totalAmounts
and itemAmounts
are objects that are returned in successful responses to the status method.
See the Payment Life Cycle section for more information on payment statuses.
The totalAmounts
and itemAmounts
objects have same sets of properties. The difference is as follows.
The totalAmounts
object contains information on the total amounts per certain statuses for the entire request scope at the time of request. That means that if you, for example, filter your status request by a tag, the totalAmounts
object will contain the total amounts of all cart items marked with that tag. The status request returns only one totalAmounts
object.
The itemAmounts
objects are part of item objects and contain information on the amounts per certain statuses of specific items at the time of the request. There are as many itemAmounts
objects as there are items in the status scope. If a status request returns a single item, the itemAmounts
values are equal to the totalAmounts
values.
initiated
- the initial amount that was registered with theinit
request.captured
- the authorized amount that has been captured with thecapture
request. Note that item amounts can be partially canceled before being captured, so this value may be different from theinitiated
amount. Also, cart items do not have to be captured all at once, therefore, a cart may contain items that are authorized but hasn't been captured or canceled, hence, this value may change. However, thecaptured
amount cannot exceed theinitiated
amount.refunded
- the completed amount that has been refunded. Similar to the above, item amounts can be partially refunded, so this value may be different from thecaptured
amount. As in the previous case, you have an option to refund selected items from the cart, not necessarily the entire cart. That means that therefunded
value may change, however, therefunded
amount cannot exceed thecaptured
amount.
- totalAmounts
- itemAmounts
"cartId": "6f891edb-1e1f-48bb-b042-2cb790a0f402",
"currency": "XAU",
"totalAmounts": {
"initiated": 19900,
"captured": 0,
"refunded": 0,
"current": 19000
},
In the example above the sum of all initiated cart items is 19900
. After the cart was authorized, some of the cart items were fully or partially canceled
worth of 900
and none of them were captured
. Therefore, the captured
cart amount is 0
and the current
cart amount it 19000
.
"gems": {
"paymentStatus": "completed",
"itemAmounts": {
"initiated": 1200,
"captured": 1200,
"refunded": 200,
"current": 1000
},
In the example above the gems
item was initiated and captured for the amount of 1200
without cancellations. After being completed, this item was partially refunded for the amount of 200
. Since it's not a full refund, the item state is completed
but its current amount is less than the captured one.
current
- current amount of a cart or item. For example, if the some cart items areauthorized
and partially canceled, their current amount is less than theinitiated
amount. Similarly, if some cart items arecaptured
orcompleted
and partially refunded, theircurrent
amount is less that thecaptured
amount.
paymentSnapshot
object
The paymentSnapshot
object is part of the item object returned in response to the status
request. It contains values defined in previous init
or modify
requests (as described previously on this page).
Note that if amountMode
is set to declared
, the current
value of the itemAmounts
object duplicates the amount
(in the example to the right it is 600
) value since amount multipliers quantity
and amountModifier
are not applied.
Otherwise, if the amountMode
is set to calculated
, the current
value of the itemAmounts
object is a product of the amount
, quantity
, and amountModifier
values. In the example to the right it is 4000
.
properties that affect the final item price
- declared
- calculated
"paymentSnapshot": {
"amount": 600,
"amountMode": "declared",
"quantity": 6,
"amountModifier": 1
},
"paymentSnapshot": {
"amount": 500,
"amountMode": "calculated",
"quantity": 8,
"amountModifier": 1
},