public void OnPostListProduct() { var res = PlanResponse.PlansList(prodId, 20, 1, true); ListStatus = res.StatusCode.ToString(); ListResult = res.Content; }
public GeneralAnswerData updatePlan(GeneralParameterData toUpdate) { Console.WriteLine("updatePlan"); GeneralAnswerData generalAnswerData = new GeneralAnswerData(toUpdate); Stream dataStream; WebRequest request; string datastr; UTF8Encoding encoding = new UTF8Encoding(); string url = HostName + "?q=webservice/planitem_edit&sessionid=" + SessionId; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Timeout = 10000; datastr = "planitemid=" + toUpdate.Plan.Id + "&amount=" + toUpdate.Plan.Amount + "&description=" + toUpdate.Plan.Description + "&categoryid=" + toUpdate.Plan.CategoryId; using (dataStream = request.GetRequestStream()) { string urlencoded = Uri.EscapeUriString(datastr); byte[] data = encoding.GetBytes(urlencoded); dataStream.Write(data, 0, data.Length); } using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PlanResponse)); using (dataStream = response.GetResponseStream()) { PlanResponse resp = (PlanResponse)serializer.ReadObject(dataStream); } } return(generalAnswerData); }
public void OnPost() { PlanId = id; var res = PlanResponse.PlanGet(PlanId); GetStatus = res.StatusCode.ToString(); GetResult = res.Content; }
public void OnPostPlan() { var res = PlanResponse.PlanCreate(InputModel.CreatePlan(InputModel.ProductId), "representation", "PLAN-my-testing16"); if (res.IsSuccessful) { InputModel.PlanId = JsonConvert.DeserializeObject <Plan>(res.Content).Id; InputModel.PlanStatus = res.StatusCode.ToString(); InputModel.PlanResult = res.Content; } }
public void OnPostUpdatePlan() { PlanId = id; var res = PatchPlan(PlanId); UpdateStatus = res.StatusCode.ToString(); if (res.StatusCode.ToString() == "NoContent") { var res1 = PlanResponse.PlanGet(PlanId); UpdateResult = res1.Content; } }
public void FromResponse(PlanResponse planResponse) { this.plan_id = planResponse.id; this.user_id = planResponse.user_id; this.plan_name = planResponse.name; details = new List <PlanDetails>(); //isSaved = false; foreach (PlanDetails item in details) { Debug.Log("Details dance = "); } //FillDetails(planResponse.plan_details); }
private IRestResponse PatchPlan(string planId) { var patches = new List <PatchObject>() { new PatchObject() { Op = "replace", Path = "/payment_preferences/payment_failure_threshold", Value = 7 // original Value = 3 } }; return(PlanResponse.PlanPatch(planId, patches)); }
public void DetailsToPlan(string json) { PlanResponse response = JsonConvert.DeserializeObject <PlanResponse>(json); ItemData[] details = response.plan_details; List <ItemData> itemdata = new List <ItemData>(); foreach (ItemData item in response.plan_details) { itemdata.Add(item); } InitializeGameObjects(itemdata); }
public void Setup() { _client = new StripeClient(Constants.ApiKey); var id = Guid.NewGuid().ToString(); var card = new CreditCardRequest { Number = "4111111111111111", ExpMonth = 3, ExpYear = 2015 }; _plan = _client.CreatePlan(id, 400M, "usd", PlanFrequency.Month, id); _customer = _client.CreateCustomer(card); }
public async Task <PlanResponse> criarPlano(string code, string name, string description, int amount) { Wirecard.WirecardClient WC = null; WC = await SetAmbiente(WC); try { var newPlan = new PlanRequest() { Code = code, Name = name, Description = description, Amount = amount, Interval = new Interval() { Unit = (code.Contains("year") ? "YEAR":"MONTH"), Length = 1 }, Payment_Method = "CREDIT_CARD" }; var plan = await WC.Signature.CreatePlan(newPlan); var planNew = new PlanResponse() { Code = code, Name = name, Description = description, Amount = amount, Payment_Method = "CREDIT_CARD" }; var repMongo = new Repository.MongoRep("", _settings, ""); await repMongo.GravarOne <PlanResponse>(planNew); return(plan); } catch (Exception ex) { return(null); } }
public static IRestResponse CreatePlan() { // specify the product ID var productId = "PROD-2XJ74819Y3199382R"; // construct a Plan object: var plan = BuildPlanBody(productId); // call API using the static method PlanCreate() of the SDK and get a response for your call var response = PlanResponse.PlanCreate(plan); var result = JsonConvert.DeserializeObject <Plan>(response.Content); Console.WriteLine("Status: {0}", response.StatusCode); Console.WriteLine("Pan Id: {0}", result.Id); Console.WriteLine("Links:"); foreach (LinkDescriptionObject link in result.Links) { Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method); } return(response); }
public async Task SaveAsyncWhenSaveReturnsSaved() { //Arrange var mockPlanRepository = GetDefaultIPlanRepositoryInstance(); var mockPlanUserRepository = GetDefaultIUserPlanRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Plan plan = new Plan { Name = "Free", Price = 20 }; mockPlanRepository.Setup(r => r.AddAsync(plan)) .Returns(Task.FromResult <Plan>(plan)); var service = new PlanService(mockPlanRepository.Object, mockPlanUserRepository.Object, mockUnitOfWork.Object); //Act PlanResponse result = await service.SaveAsync(plan); //Assert result.Resource.Should().Be(plan); }
public async Task GetByIdAsyncWhenNoPlanFoundReturnsPlanNotFoundResponse() { //Arrange var mockPlanRepository = GetDefaultIPlanRepositoryInstance(); var mockPlanUserRepository = GetDefaultIUserPlanRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var planId = 1; mockPlanRepository.Setup(r => r.FindById(planId)) .Returns(Task.FromResult <Plan>(null)); var service = new PlanService(mockPlanRepository.Object, mockPlanUserRepository.Object, mockUnitOfWork.Object); //Act PlanResponse result = await service.GetByIdAsync(planId); var message = result.Message; //Assert message.Should().Be("Plan not found"); }
public void OnGet() { var res = PlanResponse.PlanGet(planId); Status = JsonConvert.DeserializeObject <Plan>(res.Content).Status.ToString(); }
private IRestResponse CreatePlan(string productId) //private Plan CreatePlan(string productId) { var plan = new Plan() { ProductId = productId, Name = "Video Streaming Service Plan", Description = "Video Streaming Service basic plan", Status = PlanStatusEnum.ACTIVE, BillingCycles = new List <BillingCycle>() { new BillingCycle() { Frequency = new Frequency() { IntervalUnit = "MONTH", IntervalCount = 1 }, TenureType = BillingCycleTenureTypeEnum.TRIAL, Sequence = 1, TotalCycles = 1, PricingScheme = new PricingScheme() { FixedPrice = new Currency() { Value = "10", CurrencyCode = "USD" } } }, new BillingCycle() { Frequency = new Frequency() { IntervalUnit = "MONTH", IntervalCount = 1 }, TenureType = BillingCycleTenureTypeEnum.REGULAR, Sequence = 2, TotalCycles = 12, PricingScheme = new PricingScheme() { FixedPrice = new Currency() { Value = "100", CurrencyCode = "USD" } } } }, PaymentPreferences = new PaymentPreferences() { AutoBillOutstanding = true, SetupFee = new Currency() { Value = "10", CurrencyCode = "USD" }, SetupFeeFailureAction = PaymentPreferencesSetupFeeFailureActionEnum.CONTINUE, PaymentFailureThreshold = 3 }, Taxes = new Taxes() { Percentage = "10", Inclusive = false } }; return(PlanResponse.PlanCreate(plan, "representation", "PLAN-1my-testing10")); //return plan; }
public SubscriptionBodyResponse Create(PlanResponse <PlanResponseData> planResponse, SubscriptionBody items) => Create(planResponse.Data.PlanId, items);