本文整理汇总了C#中Braintree.SubscriptionSearchRequest类的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionSearchRequest类的具体用法?C# SubscriptionSearchRequest怎么用?C# SubscriptionSearchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubscriptionSearchRequest类属于Braintree命名空间,在下文中一共展示了SubscriptionSearchRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
// GET: Subscriptions
public ActionResult Index()
{
var request = new SubscriptionSearchRequest();
ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
return View(collection);
}
示例2: ToXML_EscapesGeneratedXMLForArrayElements
public void ToXML_EscapesGeneratedXMLForArrayElements()
{
SubscriptionSearchRequest request = new SubscriptionSearchRequest().
Ids.IncludedIn("<active");
TestHelper.AssertIncludes("<ids type=\"array\"><item><active</item></ids>", request.ToXml());
}
示例3: Search
/// <summary>
/// Search for subscriptions based on PlanId, DaysPastDue and Status
/// </summary>
/// <example>
/// Quick Start Example:
/// </example>
/// <code>
/// BraintreeGateway gateway = new BraintreeGateway(...);
/// gateway.Subscription.Search(delegate(SubscriptionSearchRequest search) {
/// search.PlanId().StartsWith("abc");
/// search.DaysPastDue().Is("30");
/// search.Status().IncludedIn(Subscription.Status.ACTIVE, Subscription.Status.CANCELED);
/// });
/// </code>
public virtual ResourceCollection<Subscription> Search(SubscriptionSearchRequest query)
{
var response = new NodeWrapper(service.Post(service.MerchantPath() + "/subscriptions/advanced_search_ids", query));
return new ResourceCollection<Subscription>(response, delegate(string[] ids) {
return FetchSubscriptions(query, ids);
});
}
示例4: FetchSubscriptions
private List<Subscription> FetchSubscriptions(SubscriptionSearchRequest query, string[] ids)
{
query.Ids.IncludedIn(ids);
var response = new NodeWrapper(service.Post(service.MerchantPath() + "/subscriptions/advanced_search", query));
var subscriptions = new List<Subscription>();
foreach (var node in response.GetList("subscription"))
{
subscriptions.Add(new Subscription(node, gateway));
}
return subscriptions;
}
示例5: FetchSubscriptions
private List<Subscription> FetchSubscriptions(SubscriptionSearchRequest query, String[] ids)
{
query.Ids.IncludedIn(ids);
NodeWrapper response = new NodeWrapper(Service.Post("/subscriptions/advanced_search", query));
List<Subscription> subscriptions = new List<Subscription>();
foreach (NodeWrapper node in response.GetList("subscription"))
{
subscriptions.Add(new Subscription(node, Service));
}
return subscriptions;
}
示例6: Search_OnPlanIdIncludedIn
public void Search_OnPlanIdIncludedIn()
{
SubscriptionRequest request1 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 5M
};
SubscriptionRequest request2 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITHOUT_TRIAL.Id,
Price = 5M
};
SubscriptionRequest request3 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.ADD_ON_DISCOUNT_PLAN.Id,
Price = 5M
};
Subscription subscription1 = gateway.Subscription.Create(request1).Target;
Subscription subscription2 = gateway.Subscription.Create(request2).Target;
Subscription subscription3 = gateway.Subscription.Create(request3).Target;
SubscriptionSearchRequest request = new SubscriptionSearchRequest().
PlanId.IncludedIn(PlanFixture.ADD_ON_DISCOUNT_PLAN.Id, PlanFixture.PLAN_WITH_TRIAL.Id).
Price.Is(5M);
ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
Assert.IsTrue(TestHelper.IncludesSubscription(collection, subscription1));
Assert.IsFalse(TestHelper.IncludesSubscription(collection, subscription2));
Assert.IsTrue(TestHelper.IncludesSubscription(collection, subscription3));
}
示例7: Search_OnBillingCyclesRemainingIs
public void Search_OnBillingCyclesRemainingIs()
{
SubscriptionRequest request1 = new SubscriptionRequest
{
NumberOfBillingCycles = 5,
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 4M
};
SubscriptionRequest request2 = new SubscriptionRequest
{
NumberOfBillingCycles = 10,
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 4M
};
Subscription subscription1 = gateway.Subscription.Create(request1).Target;
Subscription subscription2 = gateway.Subscription.Create(request2).Target;
SubscriptionSearchRequest request = new SubscriptionSearchRequest().
BillingCyclesRemaining.Is(5).
Price.Is(4M);
ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
Assert.IsTrue(TestHelper.IncludesSubscription(collection, subscription1));
Assert.IsFalse(TestHelper.IncludesSubscription(collection, subscription2));
}
示例8: Search_OnPrice
public void Search_OnPrice()
{
SubscriptionRequest request10 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 10M
};
SubscriptionRequest request20 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 20M
};
SubscriptionRequest request30 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
Price = 30M
};
Subscription subscription10 = gateway.Subscription.Create(request10).Target;
Subscription subscription20 = gateway.Subscription.Create(request20).Target;
Subscription subscription30 = gateway.Subscription.Create(request30).Target;
SubscriptionSearchRequest request = new SubscriptionSearchRequest().
Price.Between(15M, 20M);
ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
Assert.IsFalse(TestHelper.IncludesSubscription(collection, subscription10));
Assert.IsTrue(TestHelper.IncludesSubscription(collection, subscription20));
Assert.IsFalse(TestHelper.IncludesSubscription(collection, subscription30));
}
示例9: Search_OnTransactionId
public void Search_OnTransactionId()
{
TestPlan triallessPlan = PlanFixture.PLAN_WITHOUT_TRIAL;
SubscriptionRequest request1 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = triallessPlan.Id,
Price = 7M
};
SubscriptionRequest request2 = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = triallessPlan.Id,
Price = 7M
};
Subscription matchingSubscription = gateway.Subscription.Create(request1).Target;
Subscription nonMatchingSubscription = gateway.Subscription.Create(request2).Target;
SubscriptionSearchRequest request = new SubscriptionSearchRequest().
TransactionId.Is(matchingSubscription.Transactions[0].Id);
ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
Assert.IsTrue(TestHelper.IncludesSubscription(collection, matchingSubscription));
Assert.IsFalse(TestHelper.IncludesSubscription(collection, nonMatchingSubscription));
}
示例10: Search_OnMerchantAccountIdWithBogusMerchantId
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);
}
示例11: ToXml_DaysPastDueLessThanOrEqualTo
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());
}
示例12: ToXml_IdIsNot
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());
}
示例13: Search_OnInTrialPeriodIs
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));
}
示例14: ToXml_PriceLessThanOrEqualTo
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());
}
示例15: ToXml_BillingCyclesRemainingLessThanOrEqualTo
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());
}