I create a sellingPlan and apply to my product .Now I want to get sellingPlan info by graph QL,the query like this,if i want get the planType as in the plan like ‘PAY_AS_YOU_GO’,’ADVANCED_PREPAID’,’PREPAID’,how to do ?
Query example:
{
“query”: “query { sellingPlanGroups(first: 50,query:\“app_id:ALL\”) { edges { node { id name options summary sellingPlans(first: 10){ edges{node{description id name options billingPolicy{__typename } pricingPolicies {__typename}}}} } } pageInfo { hasNextPage } } }”
}
Hey @invokertc! There isn’t a planType field on the SellingPlan object. The terms like PAY_AS_YOU_GO, PREPAID, etc. aren’t API values but more so conceptual descriptions of how the billing and delivery policies are configured.
What you can query is the category field, which returns one of: SUBSCRIPTION, PRE_ORDER, TRY_BEFORE_YOU_BUY, or OTHER.
To determine if a subscription is “pay-as-you-go” vs “prepaid”, you need to compare the billing and delivery policy intervals:
{
sellingPlanGroups(first: 50, query: "app_id:ALL") {
edges {
node {
id
name
sellingPlans(first: 10) {
edges {
node {
id
name
category
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
}
}
}
}
}
}
}
}
}
The logic:
-
If billing interval equals delivery interval → Pay-as-you-go (e.g., billed weekly, delivered weekly)
-
If billing interval is greater than delivery interval → Prepaid (e.g., billed every 12 weeks, delivered weekly)
The SellingPlanCategory enum and Build a selling plan docs have more details on how these policies work together.