Helper/Order.php
private function holdOnTotalsMismatch($order, $transaction)
    {
        $boltTotal = $transaction->order->cart->total_amount->amount;
        $storeTotal = round($order->getGrandTotal() * 100);

        // Stop if no mismatch
        if ($boltTotal == $storeTotal) {
            return;
        }

        // Put the order ON HOLD and add the status message.
        // Do it once only, skip on subsequent hooks
        if ($order->getState() != OrderModel::STATE_HOLDED) {

            // Put the order on hold
            $this->setOrderState($order, OrderModel::STATE_HOLDED);

            // Add order status history comment
            $comment = __(
                'BOLTPAY INFO :: THERE IS A MISMATCH IN THE ORDER PAID AND ORDER RECORDED.<br>
             Paid amount: %1 Recorded amount: %2<br>Bolt transaction: %3',
                $boltTotal / 100,
                $order->getGrandTotal(),
                $this->formatReferenceUrl($transaction->reference)
            );
            $order->addStatusHistoryComment($comment);

            $order->save();
        }

        // Get the order and quote id
        list($incrementId, $quoteId) = array_pad(
            explode(' / ', $transaction->order->cart->display_id),
            2,
            null
        );
        if (!$quoteId) {
            $quoteId = $transaction->order->cart->order_reference;
        }

        // If the quote exists collect cart data for bugsnag
        try {
            $quote = $this->cartHelper->getQuoteById($quoteId);
            $cart = $this->cartHelper->getCartData(true, false, $quote);
        } catch (NoSuchEntityException $e) {
            // Quote was cleaned by cron job
            $cart = ['The quote does not exist.'];
        }

        // Log the debug info
        $this->bugsnag->registerCallback(function ($report) use (
            $transaction,
            $cart,
            $incrementId,
            $boltTotal,
            $storeTotal
        ) {
            $report->setMetaData([
                'TOTALS_MISMATCH' => [
                    'Reference' => $transaction->reference,
                    'Order ID' => $incrementId,
                    'Bolt Total' => $boltTotal,
                    'Store Total' => $storeTotal,
                    'Bolt Cart' => $transaction->order->cart,
                    'Store Cart' => $cart
                ]
            ]);
        });

        throw new LocalizedException(__(
            'Order Totals Mismatch Reference: %1 Order: %2 Bolt Total: %3 Store Total: %4',
            $transaction->reference, $incrementId, $boltTotal, $storeTotal
        ));
    }
private function holdOnTotalsMismatch($order, $transaction)
    {
        $boltTotal = $transaction->order->cart->total_amount->amount;
        $storeTotal = round($order->getGrandTotal() * 100);

        // Stop if no mismatch
        if ($boltTotal == $storeTotal) {
            return;
        }

        // Put the order ON HOLD and add the status message.
        // Do it once only, skip on subsequent hooks
        if ($order->getState() != OrderModel::STATE_HOLDED) {

            // Put the order on hold
            $this->setOrderState($order, OrderModel::STATE_HOLDED);

            // Add order status history comment
            $comment = __(
                'BOLTPAY INFO :: THERE IS A MISMATCH IN THE ORDER PAID AND ORDER RECORDED.<br>
             Paid amount: %1 Recorded amount: %2<br>Bolt transaction: %3',
                $boltTotal / 100,
                $order->getGrandTotal(),
                $this->formatReferenceUrl($transaction->reference)
            );
            $order->addStatusHistoryComment($comment);

            $order->save();
        }

        // Get the order and quote id
        list($incrementId, $quoteId) = array_pad(
            explode(' / ', $transaction->order->cart->display_id),
            2,
            null
        );
        if (!$quoteId) {
            $quoteId = $transaction->order->cart->order_reference;
        }

        // If the quote exists collect cart data for bugsnag
        try {
            $quote = $this->cartHelper->getQuoteById($quoteId);
            $cart = $this->cartHelper->getCartData(true, false, $quote);
        } catch (NoSuchEntityException $e) {
            // Quote was cleaned by cron job
            $cart = ['The quote does not exist.'];
        }

        // Log the debug info
        $this->bugsnag->registerCallback(function ($report) use (
            $transaction,
            $cart,
            $incrementId,
            $boltTotal,
            $storeTotal
        ) {
            $report->setMetaData([
                'TOTALS_MISMATCH' => [
                    'Reference' => $transaction->reference,
                    'Order ID' => $incrementId,
                    'Bolt Total' => $boltTotal,
                    'Store Total' => $storeTotal,
                    'Bolt Cart' => $transaction->order->cart,
                    'Store Cart' => $cart
                ]
            ]);
        });

        throw new LocalizedException(__(
            'Order Totals Mismatch Reference: %1 Order: %2 Bolt Total: %3 Store Total: %4',
            $transaction->reference, $incrementId, $boltTotal, $storeTotal
        ));
    }
private function holdOnTotalsMismatch ( $ order , $ transaction ) { $ boltTotal = $ transaction -> order -> cart -> total_amount -> amount ; $ storeTotal = round ( $ order -> getGrandTotal ( ) * 100 ) ; // Stop if no mismatch if ( $ boltTotal == $ storeTotal ) { return ; } // Put the order ON HOLD and add the status message. // Do it once only, skip on subsequent hooks if ( $ order -> getState ( ) != OrderModel :: STATE_HOLDED ) { // Put the order on hold $ this -> setOrderState ( $ order , OrderModel :: STATE_HOLDED ) ; // Add order status history comment $ comment = __ ( 'BOLTPAY INFO :: THERE IS A MISMATCH IN THE ORDER PAID AND ORDER RECORDED.<br>
             Paid amount: %1 Recorded amount: %2<br>Bolt transaction: %3' , $ boltTotal / 100 , $ order -> getGrandTotal ( ) , $ this -> formatReferenceUrl ( $ transaction -> reference ) ) ; $ order -> addStatusHistoryComment ( $ comment ) ; $ order -> save ( ) ; } // Get the order and quote id list ( $ incrementId , $ quoteId ) = array_pad ( explode ( ' / ' , $ transaction -> order -> cart -> display_id ) , 2 , null ) ; if ( ! $ quoteId ) { $ quoteId = $ transaction -> order -> cart -> order_reference ; } // If the quote exists collect cart data for bugsnag try { $ quote = $ this -> cartHelper -> getQuoteById ( $ quoteId ) ; $ cart = $ this -> cartHelper -> getCartData ( true , false , $ quote ) ; } catch ( NoSuchEntityException $ e ) { // Quote was cleaned by cron job $ cart = [ 'The quote does not exist.' ] ; } // Log the debug info $ this -> bugsnag -> registerCallback ( function ( $ report ) use ( $ transaction , $ cart , $ incrementId , $ boltTotal , $ storeTotal ) { $ report -> setMetaData ( [ 'TOTALS_MISMATCH' => [ 'Reference' => $ transaction -> reference , 'Order ID' => $ incrementId , 'Bolt Total' => $ boltTotal , 'Store Total' => $ storeTotal , 'Bolt Cart' => $ transaction -> order -> cart , 'Store Cart' => $ cart ] ] ) ; } ) ; throw new LocalizedException ( __ ( 'Order Totals Mismatch Reference: %1 Order: %2 Bolt Total: %3 Store Total: %4' , $ transaction -> reference , $ incrementId , $ boltTotal , $ storeTotal ) ) ; }
Record total amount mismatch between magento and bolt order.
Log the error in order comments and report via bugsnag.
Put the order ON HOLD if it's a mismatch.

@param OrderModel $order
@param \stdClass $transaction
@return bool true if the order was placed on hold, otherwise false
Record total amount mismatch between magento and bolt order . Log the error in order comments and report via bugsnag . Put the order ON HOLD if it s a mismatch .