title: Exception of type 'Braintree.Exceptions.AuthenticationException' and Private key is seen as "PrivateKey"
body: <p>Check out Controller</p>
  
  <pre><code>public class CheckoutsController : Controller
  {
  
  
  
      public IBraintreeConfiguration config = new BraintreeConfiguration();
  
      public static readonly TransactionStatus[] transactionSuccessStatuses = {
                                                                                  TransactionStatus.AUTHORIZED,
                                                                                  TransactionStatus.AUTHORIZING,
                                                                                  TransactionStatus.SETTLED,
                                                                                  TransactionStatus.SETTLING,
                                                                                  TransactionStatus.SETTLEMENT_CONFIRMED,
                                                                                  TransactionStatus.SETTLEMENT_PENDING,
                                                                                  TransactionStatus.SUBMITTED_FOR_SETTLEMENT
                                                                              };
  
      public ActionResult New()
      {
          var gateway = config.GetGateway();
  </code></pre>
  
  <p>This is the line that is triggering the error ('Braintree.Exceptions.AuthenticationException')</p>
  
  <pre><code> var clientToken = gateway.ClientToken.generate();
          ViewBag.ClientToken = clientToken;
          return View();
      }
  
      public ActionResult Create()
      {
          var gateway = config.GetGateway();
          Decimal amount;
  
          try
          {
              amount = Convert.ToDecimal(Request["amount"]);
          }
          catch (FormatException e)
          {
              TempData["Flash"] = "Error: 81503: Amount is an invalid format.";
              return RedirectToAction("New");
          }
  
          var nonce = Request["payment_method_nonce"];
          var request = new TransactionRequest
          {
              Amount = amount,
              PaymentMethodNonce = nonce,
              Options = new TransactionOptionsRequest
              {
                  SubmitForSettlement = true
              }
          };
  
          Result&lt;Transaction&gt; result = gateway.Transaction.Sale(request);
          if (result.IsSuccess())
          {
              Transaction transaction = result.Target;
              return RedirectToAction("Show", new { id = transaction.Id });
          }
          else if (result.Transaction != null)
          {
              return RedirectToAction("Show", new { id = result.Transaction.Id });
          }
          else
          {
              string errorMessages = "";
              foreach (ValidationError error in result.Errors.DeepAll())
              {
                  errorMessages += "Error: " + (int)error.Code + " - " + error.Message + "\n";
              }
              TempData["Flash"] = errorMessages;
              return RedirectToAction("New");
          }
  
      }
  
      public ActionResult Show(String id)
      {
          var gateway = config.GetGateway();
          Transaction transaction = gateway.Transaction.Find(id);
  
          if (transactionSuccessStatuses.Contains(transaction.Status))
          {
              TempData["header"] = "Sweet Success!";
              TempData["icon"] = "success";
              TempData["message"] = "Your test transaction has been successfully processed. See the Braintree API response and try again.";
          }
          else
          {
              TempData["header"] = "Transaction Failed";
              TempData["icon"] = "fail";
              TempData["message"] = "Your test transaction has a status of " + transaction.Status + ". See the Braintree API response and try again.";
          };
  
          ViewBag.Transaction = transaction;
          return View();
      }
  }
  </code></pre>
  
  <p>BrainTree Configuration </p>
  
  <pre><code> public class BraintreeConfiguration : IBraintreeConfiguration
  {
      public string Environment { get; set; }
      public string MerchantId { get; set; }
      public string PublicKey { get; set; }
      public string PrivateKey { get; set; }
      private IBraintreeGateway BraintreeGateway { get; set; }
  
      public IBraintreeGateway CreateGateway()
      {
          Environment = System.Environment.GetEnvironmentVariable("BraintreeEnvironment");
          MerchantId = System.Environment.GetEnvironmentVariable("BraintreeMerchantId");
          PublicKey = System.Environment.GetEnvironmentVariable("BraintreePublicKey");
          PrivateKey = System.Environment.GetEnvironmentVariable("BraintreePrivateKey");
  
          if (MerchantId == null || PublicKey == null || PrivateKey == null)
          {
              Environment = GetConfigurationSetting("BraintreeEnvironment");
              MerchantId = GetConfigurationSetting("BraintreeMerchantId");
              PublicKey = GetConfigurationSetting("BraintreePublicKey");
              PrivateKey = GetConfigurationSetting("BraintreePrivateKey");
  
          }
  
          return new BraintreeGateway(Environment, MerchantId, PublicKey, PrivateKey);
      }
  
      public string GetConfigurationSetting(string setting)
      {
          //watch this
          MerchantId = "**************";
          PublicKey = "***************";
  </code></pre>
  
  <p>The merchant id and public Key are being assigned their correct values but the private Key is being assigned as "PrivateKey"</p>
  
  <pre><code>        PrivateKey = "*************************";
          return ConfigurationManager.AppSettings[setting];
      }
  
      public IBraintreeGateway GetGateway()
      {
          if (BraintreeGateway == null)
          {
              BraintreeGateway = CreateGateway();
          }
  
          return BraintreeGateway;
      }
  }
  </code></pre>