async Task <BatchSettleResponse> ICommonGameActionsProvider.BatchSettle(BatchSettle request)
        {
            var errorCode        = GameApiErrorCode.NoError;
            var errorDescription = (string)null;
            var errorsList       = new ConcurrentBag <BatchCommandTransactionError>();
            var txCount          = 0;
            var isDuplicateBatch = 0;
            var timer            = new Stopwatch();
            var playerBalances   = new Dictionary <Guid, decimal>();

            timer.Start();
            try
            {
                _gameQueries.ValidateBatchIsUnique(request.BatchId, Context.GameProviderId);

                if (false == await _gameQueries.ValidateSecurityKey(Context.GameProviderId, request.SecurityKey))
                {
                    throw new ArgumentException("Invalid security key.");
                }

                txCount = await ProcessBatchSettleTransactionsAsync(request, errorsList);

                playerBalances = _gameQueries.GetPlayableBalances(request.Transactions.Select(x => x.UserId));
            }
            catch (DuplicateBatchException ex)
            {
                isDuplicateBatch = 1;
                errorCode        = _errors.GetErrorCodeByException(ex, out errorDescription);
            }
            catch (Exception ex)
            {
                errorCode = _errors.GetErrorCodeByException(ex, out errorDescription);
            }

            timer.Stop();

            return(new BatchSettleResponse
            {
                BatchId = request.BatchId,
                TransactionCount = txCount,
                BatchTimestamp = DateTimeOffset.UtcNow.ToString("O"),
                Elapsed = timer.ElapsedMilliseconds,
                Errors = errorsList.ToList(),
                ErrorCode = errorCode,
                ErrorDescription = errorDescription,
                IsDuplicate = isDuplicateBatch,
                PlayerBalances = new Dictionary <Guid, decimal>(playerBalances)
            });
        }