コード例 #1
0
 public ActionResult SaveBillingCardInfo(UserModel.User user, System.Web.Mvc.FormCollection collection)
 {
     var billingID = user.GetBillingID(User.Identity.Name);
     if (billingID != String.Empty)
     {
         Customer customer = Gateway.BrainTreeGateway.Customer.Find(billingID);
         string token = customer.CreditCards[0].Token;
         var request = new CustomerRequest
         {
             CreditCard = new CreditCardRequest
             {
                 CardholderName = collection["name"],
                 Number = collection["number"],
                 ExpirationMonth = collection["month"],
                 ExpirationYear = collection["year"],
                 CVV = collection["cvv"],
                 Options = new CreditCardOptionsRequest
                 {
                     UpdateExistingToken = token
                 }
             }
         };
         Result<Customer> updateResult = Gateway.BrainTreeGateway.Customer.Update(billingID, request);
         if (updateResult.IsSuccess())
         {
             var mongo = new Mongo();
             var config = mongo.GetUserConfiguration(User.Identity.Name);
             if (config.AccountInfoNotification)
             {
                 MailgunAgent.SendChangeEmail(user.GetCurrentEmail(User.Identity.Name), "Your Queue View credit card has been changed.");
             }
             return RedirectToAction("AccountDashboard", "User", new { ADCC = "ChangeCard" });
         }
         else
         {
             //Fail to update with Braintree
             return RedirectToAction("AccountDashboard", "User", new { ADCCFAIL = updateResult.Message });
         }
     }
     else
     {
         //Fail to retrieve Billing ID
         return RedirectToAction("Error", "User");
     }
 }
コード例 #2
0
 public string GetBillingType(UserModel.User user)
 {
     try
     {
         var billingID = user.GetBillingID(User.Identity.Name);
         if (billingID != String.Empty)
         {
             Customer customer = Gateway.BrainTreeGateway.Customer.Find(billingID);
             return customer.CreditCards[0].CardType.ToString();
         }
         else
         {
             //Fail to retrieve Billing ID
             return string.Empty;
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return string.Empty;
     }
 }