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; }