Order calculation

Method Description

The operation is used in online store shopping carts, offline retail POS, call center operator interfaces and in all places where an order can be created or edited. The operation takes into account the entire order constitution together with all discounts that a user would like to have applied.

In response, information regarding the order with recalculated prices is returned (taking into account currently active promotions, coupons, and other discounts), as well as detailed information on all discounts requested by the customer.

This method is meant for initial order formulation as well as for future recalculations.
The item status must be relayed as the one planned to be transferred to the begin order transaction processing method.

{
    "customer":{
        “mobilePhone":"<Mobile phone>",
        "ids":{
            “mindboxId":"<Customer Id in Mindbox>"
        },
        "discountCard":{
            "ids":{
                “number":"<Discount card number>"
            }
        }
    },
    “pointOfContact":"<External point of contact identifier>"
    "order":{
        "ids":{
            “externalSystemId":"<Order identifier in external system>"
        },
        "area":{
            "ids":{
                “externalId":"<External area identifier>"
            }
        },
        “deliveryCost":"<Delivery cost>",
        "lines":[
            {
                "product":{
                    "ids":{
                        “testExternalSystem":"<Product Id in TestExternalSystem1>"
                    }
                },
                “lineId":"<Order item identifier>",
                "lineNumber":"<Sequence number of order item>",
                "quantity":"<Quantity of items>",
                "basePricePerItem":"<Base price of item for one item unit>",
                "minPricePerItem":"<Minimum price of item for one item unit>",
                "costPricePerItem":"<Cost of item for one item unit>",
                "customFields":{
                    "lineField1":"<Additional field1>",
                    "lineField2":"<Additional field2>"
                },
                "status": {
                    "ids": {
                        "externalId": "<Item status>"
                    }
                },
                "giftCard": {
                    "ids": {
                        "number":"<Gift card number>"
                    },
                    "getFromPool": "<Selected an available gift card from the pool>"
                },
                "requestedPromotions":[
                    {
                        "type":"discount",
                        "promotion":{
                            "ids":{
                                "externalId":"<External promotion identifier>"
                            }
                        },
                        "amount":"<Discount size>"
                    }
                ]
            }
        ],
        "requestedPromotions":[{
             "type":"deliveryDiscount",
             "promotion":{
                 "ids":{
                      "externalId":"<External promotion identifier>"
                  }
             },
             "amount":"<Discount size>"
         }],
        "coupons": [{
             "ids":{
                 "code":"<Code>"
             }
        }],
        "bonusPoints": [{
                "amount":"<Quantity of points for an order discount>"
        }],
        "payments":[
            {
                "type":"<Payment method>"
            },
            {
                "type":"giftCard",
                "giftCard":{
                    "ids":{
                        "number":"<Gift card number>"
                    }
                }
            }
        ],
        "customFields":{
            "orderField1":"<Additional field1>",
            "orderField2":"<Additional field2>"
        },
        "cashdesk":{
            "ids": {
                "externalId": "<Cashdesk identifier>"
            }
        }
    }
}

Response Description

{
    "customer":{
        "processingStatus":"<Customer status, possible variants: Unavailable, Found, NotFound, DiscountCardIsBlocked>",
        "firstName":"<Name>",
        "middleName":"<Middle name>",
        "lastName":"<Last name>",
        "email":"<Email address>",
        "isEmailInvalid":"<Invalid Email address>",
        "mobilePhone":"<Mobile number>",
        "isMobilePhoneInvalid":"<Is invalid Mobile number>",
        "isMobilePhoneConfirmed":"<Is mobile number confirmed>",
        "pendingMobilePhone":"<Mobile number awaiting confirmation after number change>",
        "area":{
            "ids":{
                "externalId":"<Customer geographic area identifier>"
            },
            "name":"<Name of customer geographic area>"
        },
        "birthDate":"<Date of birth in yyyy-MM-dd format>",
        "sex":"<Sex>",
        "changeDateTimeUtc":"<Registration Date/editing in format yyyy-MM-dd HH:mm:ss.FFF>"
    },
    "order":{
        "processingStatus": "<Processing status: Calculated/PersonalDiscountsCalculationIsUnavailable/DiscountsCalculationIsUnavailable/>"
        "totalPrice":"<Final order price with discount>",
        "deliveryCost":"<Delivery cost>",
        "lines":[
            {
                "product":{
                    "ids":{
                        "productId":"<Product Id in TestExternalSystem1>"
                    }
                },
                "lineId":"<Order item identifier>",
                "lineNumber":"<Order item number>",
                "quantity":"<Quantity of product units>",
                "basePricePerItem":"<Base price of item for one item unit>",
                "minPricePerItem":"<Minimum price of item for one item unit>",
                "discountedPriceOfLine":"<Final price for a position with account for all discounts>",
                "costPricePerItem":"<Cost of item per unit of item>",
                "status": {
                    "ids": {
                        "externalId": "<Position status>"
                    }
                },
                "customFields":{
                    "lineField1":"<Additional field1>",
                    "lineField2":"<Additional field2>"
                }
                "giftCard": {
                    "status": "<Processing status of purchased gift card: Found/NotFound/Unavailable>",
                    "ids": {
                        "number":"<Gift card number>"
                    },
                    "getFromPool": "<Select an available gift card from the pool>"
                },
                "appliedPromotions":[
                    {
                        "type":"earnedBonusPoints",
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<External promotion identifier>"
                            },
                            "name":"<Promotion name",
                            "type":"<Promotion type: mindbox/external>"
                        },
                        "balanceType":{
                            "ids":{
                                "systemName":"<System name of points account>"
                            },
                            "name":"<Point account name>"
                        },
                        "amount":"<Amount of accrued points>",
                        "expirationDateTimeUtc":"<Points expiration date>"
                    },
                    {
                        "type":"spentBonusPoints",
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<External promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                        },
                        "balanceType":{
                            "ids":{
                                "systemName":"<System name of points account>"
                            },
                            "name":"<Point account name>"
                        },
                        "amount":"<Discount amount applied to order>"
                    },
                    {
                        "type":"discount",
                        "coupon":{
                            "ids":{
                                "code":"<Promotion code>"
                            },
                            "pool":{
                                "ids":{
                                    "mindboxId":"<Mindbox coupon pool identifier>",
                                    "externalId":"<External pool identifier>"
                                },
                                "name":"<Promotional pool name>",
                                "description":"<Coupon pool description>"
                            }
                        },
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<External promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                        },
                        "amount":"<Discount amount applied to order>"
                    },
                    {
                        "type":"message",
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<Promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                        }
                    }
                ],
                "placeholders":[
                    {
                        "ids":{
                            "externalId":"<Identifier of display text area>"
                        },
                        "content":[
                            {
                                "type":"text",
                                "message":"Message displayed near order item",
                                "promotion":{
                                    "ids":{
                                        "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<Promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "customFields":{
            "orderField1":"<Additional field1>",
            "orderField2":"<Additional field2>"
        },
        "appliedPromotions":[
            {
                "type":"deliveryDiscount",
                "coupon":{
                    "ids":{
                        "code":"<Coupon code>"
                    },
                    "pool":{
                        "ids":{
                            "mindboxId":"<Mindbox coupon pool identifier>",
                            "externalId":"<External pool identifier>"
                        },
                        "name":"<Coupon pool name>",
                        "description":"<Coupon pool description>"
                    }
                },
                "promotion":{
                    "ids":{
                        "mindboxId":"<Mindbox promotion identifier>",
                        "externalId":"<External promotion identifier>"
                    },
                    "name":"<Promotion name>",
                    "type":"<Promotion type: mindbox/external>"
                },
                "amount":"<Discount amount applied to order>"
            },
            {
                "type":"message",
                "promotion":{
                    "ids":{
                        "mindboxId":"<Mindbox promotion identifier>",
                        "externalId":"<Promotion identifier>"
                    },
                    "name":"<Promotion name>",
                    "type":"<Promotion type: mindbox/external>"
                }
            }
        ],
        "placeholders":[
            {
                "ids":{
                    "externalId":"<Identifier of display text area>"
                },
                "content":[
                    {
                        "type":"text",
                        "message":"<Message displayed by the check line>",
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<External promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                        }
                    },
                    {
                        "type":"possibleDiscounts",
                        "possibleDiscounts": {
                            "discountsCount":"<Amount of items to which the discount applies>",
                            "discount": {
                                "amount": "<Discount size>",
                                "amountType": "<Discount type Percent/Absolute>"
                            },
                            "products":[
                                {
                                    "ids":{
                                        "testExternalSystem":"<Product Id in TestExternalSystem1>"
                                    }
                                }
                            ]
                        },
                        "promotion":{
                            "ids":{
                                "mindboxId":"<Mindbox promotion identifier>",
                                "externalId":"<External promotion identifier>"
                            },
                            "name":"<Promotion name>",
                            "type":"<Promotion type: mindbox/external>"
                        }
                    }
                ]
            }
        ],
        "bonusPointsInfo":[{
                "status":"<Point processing response status: Unavailable/Success>",
                "availableAmountForCurrentOrder":"<Maximum amount of points which can be spent on the order>",
                "spentAmountForCurrentOrder":"<Factual quantity of points used to pay for the order>",
                "balanceType":{
                    "ids":{
                        "systemName":"<System name of point account>"
                    },
                    "name":"<Name of point account>"
                },
                "balance":{
                    "total":"<Total quantity of points>",
                    "available":"<Available amount of points>",
                    "blocked":"<Blocked amount of points>"
                }
        }],
        "couponsInfo": [{
                "discountAmountForCurrentOrder":"<Coupon discount size for the given order>",
                "coupon":{
                    "ids":{
                        "code":"<Coupon code>"
                    },
                    "status":"<Coupon status Unavailable/NotFound/NotIssued/Used/YetNotActive/AlreadyNotActive/CanBeUsed/CanNotBeUsedForCurrentOrder/Blocked>",
                    "pool":{
                        "ids":{
                            "externalId":"<External coupon pool identifier>",
                            "mindboxId":"<Internal coupon pool identifier>"
                        },
                        "name":"<Name of coupon pool>",
                        "description":"<Coupon pool description>"
                    },
                    "availableFromDateTimeUtc":"<Date and start time of coupon availability>",
                    "availableTillDateTimeUtc":"<Date and time of coupon availability end>",
                    "usedDateTimeUtc":"<Date and time of coupon use>"
                }
         }],
        "paymentsInfo":[{
                "type":"giftCard",
                "availableAmountForCurrentOrder":"<Maximum available amount for the current order>",
                "giftCard":{
                    "ids":{
                        "number":"<Number of gift card>"
                    },
                    "status":"<Status of gift card Unavailable/NotFound/CanBeUsed/Inactive/AlreadyUsed/Blocked>",
                    "balance":{
                        "total":"<Total of gift card>",
                        "available":"<Available amount of rubles>",
                        "used":"<Amount of used rubles>"
                    }
                }
            }
        ],
        "bonusPointsChanges":[{
                "balanceType":{
                    "ids":{
                        "systemName":"<System name of point account>"
                    },
                    "name":"<Name of point account>"
                },
                "earnedAmount": "<Amount of points that will be accrued or written off in the form of a bonus for the order>",
                "spentAmount": "<Amount of points that will be accrued or written off as payment for an order>"                
        }]
    }
}

If the project utilizes an integer point account, in this case, only a quantity of points that are a multiple to the amount of items can be used. For example, an odd number of points cannot be used for 2 items. In this case, Mindbox automatically rounds down the transferred quantity of points.
The rounded quantity of points will return to the node
discountsInfo/discountInfo/spentAmountForCurrentOrder.

Status description

Order processing status

StatusDescription
CalculatedAll discounts have been successfully calculated
PersonalDiscountsCalculationIsUnavailableOnly public discounts have been calculated. Personal discount calculation is currently unavailable
DiscountsCalculationIsUnavailableAll discount calculations are currently unavailable

Customer processing status

StatusDescription
UnavailableIt is currently unavailable to receive customer data
FoundCustomer found
Not FoundCustomer not found
DiscountCardIsBlockedThe card is blocked. In this case, only public discounts are calculated.

Acquired gift card processing status

StatusDescription
NotFoundGift card not found
UnavailableCurrently it is impossible to acquire a gift card
AlreadyActivatedThe card has already been activated
CanBeActivatedCan be activated within the bounds of the current order
BlockedBlocked
SkuMismatchThe gift card does not correspond to the transferred SKU
PriceMismatchThe base price of the discount card does not correspond to the one designated in Mindbox

Bonus point processing reply status

StatusDescription
UnavailablePaying with bonus points is currently unavailable.
SuccessSuccess

Gift card status used for payment

StatusDescription
UnavailablePayment with gift cards is currently unavailable
NotFoundGift card not found
CanBeUsedA gift card can be used to pay for the order
InactiveThe gift card is not activated
AlreadyUsedThe gift card was already used earlier
BlockedThe gift card is blocked

Coupon status

StatusDescription
UnavailableCoupon use is currently unavailable
NotFoundCoupon not found
NotIssuedCoupon not issued
UsedCoupon already used
YetNotActiveCoupon is not yet active
AlreadyNotActiveCoupon is no longer active
CanBeUsedCoupon can be used in the order
CanNotBeUsedForCurrentOrderThe coupon use logic does not apply to the order
BlockedThe coupon is blocked