protected function getNextTransactionSequenceNumber()
    {
        $query = "SELECT MAX(sequence_number) AS max_sequence_number
                    FROM `pkg_shop_payment_transaction`
                   WHERE `pkg_shop_payment_transaction`.`shop_order_id` = '".MySqlLegacySupport::getInstance(
            )->real_escape_string(
                $this->order->id
            )."'
                GROUP BY `pkg_shop_payment_transaction`.`shop_order_id`
                 ";
        if ($aSum = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
            $iSequenceNumber = $aSum['max_sequence_number'] + 1;
        } else {
            $iSequenceNumber = 1;
        }

        return $iSequenceNumber;
    }