public void ToXml_CreatedAtLessThanOrEqualTo() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().CreatedAt.LessThanOrEqualTo("1/1/2015"); var xml = "<search><created-at><max>1/1/2015</max></created-at></search>"; Assert.AreEqual(xml, request.ToXml()); }
// GET: Subscriptions public ActionResult Index() { var request = new SubscriptionSearchRequest(); ResourceCollection <Subscription> collection = gateway.Subscription.Search(request); return(View(collection)); }
public void ToXml_DaysPastDueIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().DaysPastDue.Is("30"); var xml = "<search><days-past-due><is>30</is></days-past-due></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_MerchantAccountIdIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().MerchantAccountId.Is("abc"); var xml = "<search><merchant-account-id type=\"array\"><item>abc</item></merchant-account-id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_DaysPastDueGreaterThanOrEqualTo() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().DaysPastDue.GreaterThanOrEqualTo(3); var xml = "<search><days-past-due><min>3</min></days-past-due></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_BillingCyclesRemainingBetween() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().BillingCyclesRemaining.Between(1, 2); var xml = "<search><billing-cycles-remaining><min>1</min><max>2</max></billing-cycles-remaining></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PlanIdStartsWith() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().PlanId.StartsWith("30"); var xml = "<search><plan-id><starts-with>30</starts-with></plan-id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PriceLessThanOrEqualTo() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Price.LessThanOrEqualTo(12.34M); var xml = "<search><price><max>12.34</max></price></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PriceBetween() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Price.Between(1M, 2M); var xml = "<search><price><min>1</min><max>2</max></price></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_IdIsNot() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Id.IsNot("30"); var xml = "<search><id><is-not>30</is-not></id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_BillingCyclesRemainingLessThanOrEqualTo() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().BillingCyclesRemaining.LessThanOrEqualTo(12.34); var xml = "<search><billing-cycles-remaining><max>12.34</max></billing-cycles-remaining></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_IdEndsWith() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Id.EndsWith("30"); var xml = "<search><id><ends-with>30</ends-with></id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_BillingCyclesRemainingIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().BillingCyclesRemaining.Is(1); var xml = "<search><billing-cycles-remaining><is>1</is></billing-cycles-remaining></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_IdContains() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Id.Contains("30"); var xml = "<search><id><contains>30</contains></id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_CreatedAtBetween() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().CreatedAt.Between("1/1/2015", "1/2/2015"); var xml = "<search><created-at><min>1/1/2015</min><max>1/2/2015</max></created-at></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXML_EscapesGeneratedXMLForArrayElements() { SubscriptionSearchRequest request = new SubscriptionSearchRequest(). Ids.IncludedIn("<active"); TestHelper.AssertIncludes("<ids type=\"array\"><item><active</item></ids>", request.ToXml()); }
public void ToXml_CreatedAtIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().CreatedAt.Is("1/1/2015"); var xml = "<search><created-at><is>1/1/2015</is></created-at></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PriceIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().Price.Is(1M); var xml = "<search><price><is>1</is></price></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PlanIdIncludedIn() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().PlanId.IncludedIn("abc", "def"); var xml = "<search><plan-id type=\"array\"><item>abc</item><item>def</item></plan-id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_DaysPastDueLessThanOrEqualTo() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().DaysPastDue.LessThanOrEqualTo(4); var xml = "<search><days-past-due><max>4</max></days-past-due></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_PlanIdIs() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().PlanId.Is("abc"); var xml = "<search><plan-id><is>abc</is></plan-id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXml_DaysPastDueBetween() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().DaysPastDue.Between(2, 3); var xml = "<search><days-past-due><min>2</min><max>3</max></days-past-due></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXML_DefaultsNullCriteriaToEmptyString() { SubscriptionSearchRequest request = new SubscriptionSearchRequest(). PlanId.Is(null); TestHelper.AssertIncludes("<plan-id><is></is></plan-id>", request.ToXml()); }
public void ToXml_MerchantAccountIdIncludedInWithExplicitArray() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().MerchantAccountId.IncludedIn(new string[] { "abc", "def" }); var xml = "<search><merchant-account-id type=\"array\"><item>abc</item><item>def</item></merchant-account-id></search>"; Assert.AreEqual(xml, request.ToXml()); }
public void ToXML_EscapesGeneratedXMLForSearchCriteria() { SubscriptionSearchRequest request = new SubscriptionSearchRequest(). PlanId.Is("<my-id"); TestHelper.AssertIncludes("<plan-id><is><my-id</is></plan-id>", request.ToXml()); }
public HttpResponseMessage Search(SubscriptionSearchRequest requestInfo) { try { int? orgid; DateTime?reviewEndDate; DateTime?reviewStartDate; List <SowWkflow> sows = new List <SowWkflow>(); orgid = requestInfo.OrgId != null ? requestInfo.OrgId : null; reviewEndDate = requestInfo.ReviewEndDate != null ? requestInfo.ReviewEndDate : null; reviewStartDate = requestInfo.ReviewStartDate != null ? requestInfo.ReviewStartDate : null; if (orgid != null && reviewEndDate != null && reviewStartDate != null) { // All Search Params Search sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid && p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList(); } else if (orgid != null) { // Search only by orgId sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid).ToList(); } else { sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId > 0).ToList(); } //if (requestInfo.OrgId != null) //{ // orgid = requestInfo.OrgId; // sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid && p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList(); //} //else //{ // sows = _ISowwkflowService.GetSowwkflows().Where(p => p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList(); //} var result = PlatformMappingHelper.Map <IList <SowWkflow>, IList <SOWDTO> >(sows.ToList()).ToList(); if (result == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <IEnumerable <SOWDTO> >(HttpStatusCode.OK, result)); } catch (Exception daExp) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public async Task <SubscriptionItemsResponse> Get(SubscriptionSearchRequest request) { var url = "subscriptions/"; url = url.AppendParameter("skip", request.skip); url = url.AppendParameter("limit", request.limit); url = url.AppendParameter("search", request.search); url = url.AppendParameter("sortkey", request.sortkey); url = url.AppendParameter("sortdirection", request.sortdirection); url = url.AppendParameter("customer_id", request.customer_id); url = url.AppendParameter("gateway_id", request.gateway_id); url = url.AppendParameter("status", request.status); return(await _serviceHelper.Get <SubscriptionItemsResponse>(url, overrideConfigSecretKey : _overrideConfigSecretKey)); }
public void GetSubscriptionsWithSearch(string overideSecretKey) { var subscription = CreateBasicSubscription(overideSecretKey); var request = new SubscriptionSearchRequest { customer_id = subscription.resource.data.customer.customer_id }; SubscriptionItemsResponse response; if (overideSecretKey != null) { response = new Subscriptions(overideSecretKey).Get(request); } else { response = new Subscriptions().Get(request); } Assert.IsTrue(response.IsSuccess); Assert.AreEqual(1, response.resource.data.Count()); }
public SubscriptionItemsResponse Get(SubscriptionSearchRequest request) { var url = "subscriptions/"; url = url.AppendParameter("skip", request.skip); url = url.AppendParameter("limit", request.limit); url = url.AppendParameter("search", request.search); url = url.AppendParameter("sortkey", request.sortkey); url = url.AppendParameter("sortdirection", request.sortdirection); url = url.AppendParameter("customer_id", request.customer_id); url = url.AppendParameter("gateway_id", request.gateway_id); url = url.AppendParameter("status", request.status); var responseJson = _serviceHelper.CallPaydock(url, HttpMethod.GET, "", overrideConfigSecretKey: _overrideConfigSecretKey); var response = SerializeHelper.Deserialize <SubscriptionItemsResponse>(responseJson); response.JsonResponse = responseJson; return(response); }
public void Search_OnInTrialPeriodIs() { SubscriptionRequest request1 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id }; SubscriptionRequest request2 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITHOUT_TRIAL.Id }; Subscription trial = gateway.Subscription.Create(request1).Target; Subscription noTrial = gateway.Subscription.Create(request2).Target; SubscriptionSearchRequest request = new SubscriptionSearchRequest(). InTrialPeriod.Is(true); ResourceCollection<Subscription> trialResults = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(trialResults, trial)); Assert.IsFalse(TestHelper.IncludesSubscription(trialResults, noTrial)); request = new SubscriptionSearchRequest(). InTrialPeriod.Is(false); ResourceCollection<Subscription> noTrialResults = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(noTrialResults, noTrial)); Assert.IsFalse(TestHelper.IncludesSubscription(noTrialResults, trial)); }
public void Search_OnMerchantAccountIdWithBogusMerchantId() { Random random = new Random(); string subscriptionId = random.Next(0, 100000).ToString(); var subscriptionRequest = new SubscriptionRequest { MerchantAccountId = MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID, PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id, Price = 2M, Id = subscriptionId }; gateway.Subscription.Create(subscriptionRequest); var searchRequest = new SubscriptionSearchRequest(). MerchantAccountId.Is(MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID). Id.Is(subscriptionId). Price.Is(2M); var collection = gateway.Subscription.Search(searchRequest); Assert.AreEqual(1, collection.MaximumCount); searchRequest = new SubscriptionSearchRequest(). MerchantAccountId.IncludedIn(MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID, "bogus_merchant_account_id"). Id.Is(subscriptionId). Price.Is(2M); collection = gateway.Subscription.Search(searchRequest); Assert.AreEqual(1, collection.MaximumCount); searchRequest = new SubscriptionSearchRequest(). MerchantAccountId.Is("bogus_merchant_account_id"). Id.Is(subscriptionId). Price.Is(2M); collection = gateway.Subscription.Search(searchRequest); Assert.AreEqual(0, collection.MaximumCount); }
public void Search_OnPlanIdIs() { TestPlan triallessPlan = PlanFixture.PLAN_WITHOUT_TRIAL; TestPlan trialPlan = PlanFixture.PLAN_WITH_TRIAL; SubscriptionRequest request1 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = trialPlan.Id, Price = 5M }; SubscriptionRequest request2 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = triallessPlan.Id, Price = 5M }; Subscription trialSubscription = gateway.Subscription.Create(request1).Target; Subscription triallessSubscription = gateway.Subscription.Create(request2).Target; SubscriptionSearchRequest request = new SubscriptionSearchRequest(). PlanId.Is(trialPlan.Id). Price.Is(5M); ResourceCollection<Subscription> collection = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(collection, trialSubscription)); Assert.IsFalse(TestHelper.IncludesSubscription(collection, triallessSubscription)); }
public void Search_OnNextBillingDate() { TestPlan triallessPlan = PlanFixture.PLAN_WITHOUT_TRIAL; TestPlan trialPlan = PlanFixture.PLAN_WITH_TRIAL; SubscriptionRequest request1 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = triallessPlan.Id, Price = 7M }; SubscriptionRequest request2 = new SubscriptionRequest { PaymentMethodToken = creditCard.Token, PlanId = trialPlan.Id, Price = 7M }; Subscription triallessSubscription = gateway.Subscription.Create(request1).Target; Subscription trialSubscription = gateway.Subscription.Create(request2).Target; SubscriptionSearchRequest request = new SubscriptionSearchRequest(). NextBillingDate.GreaterThanOrEqualTo(DateTime.Now.AddDays(5)); ResourceCollection<Subscription> collection = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(collection, triallessSubscription)); Assert.IsFalse(TestHelper.IncludesSubscription(collection, trialSubscription)); }
public void Search_OnMerchantAccountIdIs() { SubscriptionRequest request1 = new SubscriptionRequest { MerchantAccountId = MerchantAccountIDs.DEFAULT_MERCHANT_ACCOUNT_ID, PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id, Price = 2M }; SubscriptionRequest request2 = new SubscriptionRequest { MerchantAccountId = MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID, PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id, Price = 2M }; Subscription defaultMerchantAccountSubscription = gateway.Subscription.Create(request1).Target; Subscription nonDefaultMerchantAccountSubscription = gateway.Subscription.Create(request2).Target; SubscriptionSearchRequest request = new SubscriptionSearchRequest(). MerchantAccountId.Is(MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID). Price.Is(2M); ResourceCollection<Subscription> collection = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(collection, nonDefaultMerchantAccountSubscription)); Assert.IsFalse(TestHelper.IncludesSubscription(collection, defaultMerchantAccountSubscription)); }
public void Search_OnIdIs() { SubscriptionRequest request1 = new SubscriptionRequest { Id = string.Format("find_me{0}", new Random().Next(1000000)), PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id, Price = 3M }; SubscriptionRequest request2 = new SubscriptionRequest { Id = string.Format("do_not_find_me{0}", new Random().Next(1000000)), PaymentMethodToken = creditCard.Token, PlanId = PlanFixture.PLAN_WITH_TRIAL.Id, Price = 3M }; Subscription subscription1 = gateway.Subscription.Create(request1).Target; Subscription subscription2 = gateway.Subscription.Create(request2).Target; SubscriptionSearchRequest request = new SubscriptionSearchRequest(). Id.StartsWith("find_me"). Price.Is(3M); ResourceCollection<Subscription> collection = gateway.Subscription.Search(request); Assert.IsTrue(TestHelper.IncludesSubscription(collection, subscription1)); Assert.IsFalse(TestHelper.IncludesSubscription(collection, subscription2)); }
public void ToXml_MerchantAccountIdIncludedInWithExplicitArray() { SubscriptionSearchRequest request = new SubscriptionSearchRequest().MerchantAccountId.IncludedIn(new string[] {"abc", "def"}); var xml = "<search><merchant-account-id type=\"array\"><item>abc</item><item>def</item></merchant-account-id></search>"; Assert.AreEqual(xml, request.ToXml()); }