Runtime_CalculateCharges
#
Description#
This function allows you to apply a shipping method and/or a payment method to a checkout session. Tax is automatically recalculated when this function runs. If calling this function from a Miva page, there is a helper function with the same name that is part of runtime.js.
Request Body Parameters#
Parameter |
Type | Description |
---|---|---|
Session_Type |
String | This will always be “runtime” |
Session_ID |
String | The Session ID of the basket |
Checkout_Session_ID |
String | Checkout Session ID. This is available once OCST (Bill To/Ship To) has been submitted |
PaymentMethod |
String | Optional. Needs to be in the following format: module_code:method_code. Example: ‘authnet:visa’ |
ShippingMethod |
String | Optional. Needs to be in the following format: module_code:method_code. Example: ‘flatrate:freeship’ |
Response Parameters#
Parameter |
Type | Description |
---|---|---|
success |
boolean | Boolean value for if the request was successful |
total |
Number | Basket Total after payment, shipping, tax have been applied |
subtotal |
Number | Basket subtotal. Tax is not included in this calculation |
formatted_total |
String | Basket Total after payment, shipping, tax have been applied |
formatted_subtotal |
String | Basket subtotal. Tax is not included in this calculation |
Note
Content-Type for the request must be ‘application/json’
Example Request#
{
"Store_Code": "{{Store_Code}}",
"Function": "Runtime_CalculateCharges",
"Session_Type": "runtime",
"Checkout_Session_ID": "6c91bb39caaa7aa4866a7f9ddc2edasd",
"Session_ID": "b4ddb93804b45e1e3c9b22165ddasds",
"PaymentMethod": "",
"ShippingMethod": "flatrate:FREESHIP"
}
Example Response#
{
"success": 1,
"data": {
"total": 7.8,
"subtotal": 7.5,
"formatted_total": "$7.80",
"formatted_subtotal": "$7.50"
}
}