Subscription

Subscription: Search

Returns a collection of Subscription response objects.

You can search for subscriptions using a variety of criteria. For operators available on search fields, see the search fields page.
  1. C#
var request = new SubscriptionSearchRequest()
    .PlanId.Is("the_plan_id");
ResourceCollection<subscription> collection = gateway.Subscription.Search(request);
foreach (Subscription subscription in collection) {
    Console.WriteLine(subscription.BillingDayOfMonth);
}
If you want to look up a single subscription using its ID, use Subscription: Find instead.
Parameters
The number of billing cycles remaining in the subscription.
The date/time the subscription was created.
The number of days past due the subscription is.
Idtext
The ID of the subscription.
Idsmultiple
A list of subscription IDs to search for.

Whether the subscription is in a trial period. Can be true or false. This parameter must be used in conjunction with Status.

A list of merchant account IDs to search for.

A fragment of the merchant account ID to search for.

A part of the merchant account ID to search for.
A postfix for the merchant account ID to search for.
Istext
An exact merchant account ID to search for.
IsNottext
A merchant account ID to be excluded from the search.
A prefix for the merchant account ID to search for.
The date the subscription will next be billed.
PlanIdmultiple
A list of plan IDs to search for.
Pricerange
The price of the subscription.
Statusmultiple

The status of the subscription. Possible values:

  • ACTIVE
  • CANCELED
  • PAST_DUE
  • PENDING
  • EXPIRED
The transaction ID associated with the subscription.

ExamplesAnchorIcon

Searching by priceAnchorIcon

Searching on price uses a range field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Price.Between(1M, 2M)
);

Searching by plan IDAnchorIcon

Searching on plan ID uses a multiple value field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .PlanId.Is("gold_plan")
);

Searching by statusAnchorIcon

Searching on status uses a multiple value field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Status.Is(SubscriptionStatus.ACTIVE)
);
results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Status.IncludedIn(
            SubscriptionStatus.ACTIVE,
            SubscriptionStatus.CANCELED,
            SubscriptionStatus.EXPIRED,
            SubscriptionStatus.PAST_DUE,
            SubscriptionStatus.PENDING
        )
);
When searching for subscriptions that are active, you have the ability to search for all active subscriptions (with or without a trial period), subscriptions with a trial period, or subscriptions without a trial period.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Status.Is(SubscriptionStatus.ACTIVE)
);
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Status.Is(SubscriptionStatus.ACTIVE)
        .InTrialPeriod.Is(true)
);
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Status.Is(SubscriptionStatus.ACTIVE)
        .InTrialPeriod.Is(false)
);

Searching by days past dueAnchorIcon

Searching on days past due uses a range field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .DaysPastDue.Between(1, 10)
);

Searching by merchant account IDAnchorIcon

Searching on merchant account ID acts like a multiple value field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .MerchantAccountId.IncludedIn("usd_account", "another")
);

Searching by billing cycles remainingAnchorIcon

Searching on billing cycles remaining will find subscriptions which have a set limit to the number of times they will recur. It uses a range field.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .BillingCyclesRemaining.GreaterThanOrEqualTo(12.34)
);

Searching by next billing dateAnchorIcon

Searching on next billing date will return subscriptions that will bill again during the date range you have given it. The example below will return any subscriptions that will be billed in the next five days.
  1. C#
ResourceCollection<subscription> collection = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .NextBillingDate.LessThanOrEqualTo(DateTime.Now.AddDays(5)
);

Searching by created-at date/timeAnchorIcon

Searching on created-at date/time will return subscriptions that were created during the range you have given.
  1. C#
var searchRequest = new SubscriptionSearchRequest()
    .CreatedAt.Between(
        DateTime.Now.AddDays(-1),
        DateTime.Now
    );
ResourceCollection<subscription> collection = gateway.Subscription.Search(searchRequest);

Searching a combinationAnchorIcon

You can combine any of the search fields into a single search.
  1. C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .PlanId.Is("gold_plan")
        .Status.Is(SubscriptionStatus.ACTIVE)
);

See AlsoAnchorIcon

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more