In addition to Solution-I, just a minor change, add
pTotalSum with second parameter insted of pTotalAmount like:
var pTotalSum = new SqlParameter("@TotalSumProcessed", SqlDbType.Decimal) { Direction = ParameterDirection.Output };
command.Parameters.Add(pTotalSum);