Subscription: Search
Note
        Results are limited according to the PayPal Data Protection Addendum For Card Processing Products policy.
    
- 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);
}Subscription: Find
    instead.
    ;Parameters
The number of billing cycles remaining in the subscription.
CreatedAtrangeThe date/time the subscription was created.
DaysPastDuerangeThe number of days past due the subscription is.
IdtextThe ID of the subscription.
IdsmultipleA list of subscription IDs to search for.
InTrialPeriodmultipleWhether the subscription is in a trial period. Can be true or false. This parameter must be used in conjunction with Status.
MerchantAccountIdmultipleA list of merchant account IDs to search for.
A fragment of the merchant account ID to search for.
ContainstextA part of the merchant account ID to search for.
EndsWithtextA postfix for the merchant account ID to search for.
IstextAn exact merchant account ID to search for.
IsNottextA merchant account ID to be excluded from the search.
StartsWithtextA prefix for the merchant account ID to search for.
NextBillingDaterangeThe date the subscription will next be billed.
PlanIdmultipleA list of plan IDs to search for.
PricerangeThe price of the subscription.
StatusmultipleThe status of the subscription. Possible values:
- ACTIVE
- CANCELED
- PAST_DUE
- PENDING
- EXPIRED
TransactionIdtextThe transaction ID associated with the subscription.
Examples
Searching by price
    Searching on price uses a range field.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .Price.Between(1M, 2M)
);Searching by plan ID
    Searching on plan ID uses a multiple value field.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .PlanId.Is("gold_plan")
);Searching by status
    Searching on status uses a multiple value field.
    - 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
        )
);- 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 due
    Searching on days past due uses a range field.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .DaysPastDue.Between(1, 10)
);Searching by merchant account ID
    Searching on merchant account ID acts like a multiple value
    field.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .MerchantAccountId.IncludedIn("usd_account", "another")
);Searching by billing cycles remaining
    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.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .BillingCyclesRemaining.GreaterThanOrEqualTo(12.34)
);Searching by next billing date
    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.
    - C#
ResourceCollection<subscription> collection = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .NextBillingDate.LessThanOrEqualTo(DateTime.Now.AddDays(5)
);Searching by created-at date/time
    Searching on created-at date/time will return subscriptions that were created during the range you
    have given.
    - C#
var searchRequest = new SubscriptionSearchRequest()
    .CreatedAt.Between(
        DateTime.Now.AddDays(-1),
        DateTime.Now
    );
ResourceCollection<subscription> collection = gateway.Subscription.Search(searchRequest);Searching a combination
    You can combine any of the search fields into a single search.
    - C#
ResourceCollection<subscription> results = gateway.Subscription.Search(
    new SubscriptionSearchRequest()
        .PlanId.Is("gold_plan")
        .Status.Is(SubscriptionStatus.ACTIVE)
);