public string CreateRebillCustomer(VMCreateRebillCustomer customer) { var client = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); return client.CreateRebillCustomer(ref ewayHeader, customer.Title, customer.FirstName, customer.LastName, "", "", "", "", "", "au", customer.Email, "", "", "", "", "", "", "").RebillCustomerID; }
public string BillRecurring(VMRebillCustomer customer) { var client = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); return "";//client.CreateRebillEvent(ref ewayHeader, customer.RebillCustomerID, ).Result; }
public Subscription SubscribePet(VMSubscription subscription) { var user = _db.Users.SingleOrDefault(r => r.Id == subscription.UserId); var product = _db.Products.SingleOrDefault(r => r.Id == subscription.ProductId); var price = ((double) product.Price*100).ToString(CultureInfo.InvariantCulture); var day = DateTime.Now.Day; var month = DateTime.Now.Month; var year = DateTime.Now.Year; var rebillIntDate = string.Format("{0}/{1}/{2}", (day + 2).ToString("00"), month.ToString("00"), year); var rebillStartDate = string.Format("{0}/{1}/{2}", 1.ToString("00"), (month + 1).ToString("00"), year); var rebillEndDate = string.Format("{0}/{1}/{2}", day.ToString("00"), month.ToString("00"), year + 2); var clientRecurring = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); var status = clientRecurring.CreateRebillEvent(ref ewayHeader, user.RebillCustomerID, "Felix and Rover Subscription", "Product Subscription: " + product.DisplayName, subscription.NameOnCard, subscription.CCNumber, subscription.CCExpMonth, subscription.CCExpYear, price, rebillIntDate, price, rebillStartDate, "1", "3", rebillEndDate); if (status.Result.ToLower() == "success") { var sub = new Subscription() { UserId = subscription.UserId, PetId = subscription.PetId, ProductId = subscription.ProductId, VetId = subscription.VetId, RebillID = status.RebillID }; var newSub = _subRepo.CreateSubscription(sub); //var client = new managedCreditCardPaymentTestSoapClient(); //var success = client.ProcessPayment(GetEwayHeader(), Convert.ToInt64(user.TokenCustomerID), ((int) product.Price * 100), // "Initial Payment for Subscription", "Subscribed to Product: " + product.Name).ewayTrxnStatus; //string RebillCustomerID, string RebillInvRef, string RebillInvDes, string RebillCCName, string RebillCCNumber, //string RebillCCExpMonth, string RebillCCExpYear, string RebillInitAmt, string RebillInitDate, string RebillRecurAmt, //string RebillStartDate, string RebillInterval, string RebillIntervalType, string RebillEndDate //var successRecurring = clientRecurring.CreateRebillEvent(ref ewayHeader, user.RebillCustomerID, ) try { var body = "<h1>Subscription Successful</h1>"; body += "<p>Thank you for subscribing to felix and rover</p>"; body += "<p>The pet owner " + newSub.User.FullName + " and pet named " + newSub.Pet.Name + " will now receive the following product monthly:</p>"; body += "<p>Product name: " + newSub.Product.DisplayName + "</p>"; body += "<p>Amount: $" + newSub.Product.Price + "</p>"; body += "<p>Thank you,</p>"; body += "<p>Felix and Rover Team ^.^</p>"; EmailHelper.SendEmail(newSub.User.Email, "Felix and Rover (Product Subscription)", body); } catch (Exception) { } return newSub; } return null; }
public string Unsubscribe(int id) { var subscription = _db.Subscriptions.SingleOrDefault(r => r.Id == id); var user = _db.Users.SingleOrDefault(r => r.Id == subscription.UserId); var clientRecurring = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); var result = clientRecurring.DeleteRebillEvent(ref ewayHeader, user.RebillCustomerID, subscription.RebillID).Result; if (result.ToLower() == "success") { _db.Subscriptions.Remove(_db.Subscriptions.SingleOrDefault(r => r.Id == id)); _db.SaveChanges(); try { var body = "<h1>Successfully Unsubscribed</h1>"; body += "<p>We hope you enjoyed our services.</p>"; body += "<p>The pet owner " + subscription.User.FullName + " and pet named " + subscription.Pet.Name + " will now stop receiving the following product monthly:</p>"; body += "<p>Product name: " + subscription.Product.DisplayName + "</p>"; body += "<p>Amount: $" + subscription.Product.Price + "</p>"; body += "<p>Thank you,</p>"; body += "<p>Felix and Rover Team ^.^</p>"; EmailHelper.SendEmail(subscription.User.Email, "Felix and Rover (Unsubscribed)", body); } catch (Exception) { } return "success"; } return "fail"; }
public User RegisterUser(VMRegisterUser registerUser) { if (_db.Users.Any(r => r.Username == registerUser.Username) || _db.Users.Any(r => r.Email == registerUser.Email)) return null; var user = new User() { Username = registerUser.Username, Password = registerUser.Password, FirstName = registerUser.FirstName, LastName = registerUser.LastName, Email = registerUser.Email, PhoneNumber = registerUser.PhoneNumber, Address = registerUser.Address, VetId = registerUser.VetId }; //var client = new managedCreditCardPaymentTestSoapClient(); //user.TokenCustomerID = client.CreateCustomer(GetEwayHeader(), "Mr.", registerUser.FirstName, registerUser.LastName, "", "", "", "", // "", "au", registerUser.Email, "", "", "", "", "", "", "", registerUser.CCNumber, // registerUser.NameOnCard, registerUser.CCExpMonth, registerUser.CCExpYear); var rebillClient = new eWay.Rebill.Test.manageRebill_testSoapClient(); var ewayHeader = GetRebillEwayHeader(); user.RebillCustomerID = rebillClient.CreateRebillCustomer(ref ewayHeader, "Mr.", registerUser.FirstName, registerUser.LastName, "", "", "", "", "", "au", registerUser.Email, "", "", "", "", "", "", "").RebillCustomerID; _db.Users.Add(user); _db.SaveChanges(); if (user.Email != null) { try { EmailHelper.SendEmail(user.Email, "FelixAndRover Registration", "<h1>Registration Successful</h1><p>You have successfully registered to Felix and Rover App..</p>"); } catch { } } return user; }