Graphql Billing API: trialDays and test fields not processed!

Solved

Graphql Billing API: trialDays and test fields not processed!

vanley
Shopify Partner
4 1 0

In Graphql Billing API when making the request to create a subscription mutation
appSubscriptionCreate 
fields of:

 

test, trialDays

are not processed:

Example:
Request:

GRAPHQL {{shopify_API_shop_admin_domain}}{{shopify_API_version}}{{shopify_API_graphQL_entrypoint}}
Content-Type: application/json
X-Shopify-Access-Token: {{shopify-access-token}}

mutation appSubscriptionCreate($lineItems: [AppSubscriptionLineItemInput!]!, $name: String!, $returnUrl: URL!) {
  appSubscriptionCreate(lineItems: $lineItems, name: $name, returnUrl: $returnUrl) {
    appSubscription {
      id
      name
      test
      trialDays
      returnUrl
    }
    confirmationUrl
    userErrors {
      field
      message
    }
  }
}

{
  "test": true,
  "trialDays": 14,
  "lineItems": {
    "plan": {
      "appRecurringPricingDetails": {
        "interval": "EVERY_30_DAYS",
        "price": {
          "amount": 8.00,
          "currencyCode": "USD"
        }
      }
    }
  },
  "name": "MY AWESOME PLAN",
  "returnUrl": "https://shop-domain.myshopify.com/admin/apps/my-app"
}

Response:

{
  "data": {
    "appSubscriptionCreate": {
      "appSubscription": {
        "id": "gid:\/\/shopify\/AppSubscription\/25893175455",
        "name": "MY AWESOME PLAN",
        "test": false,
        "trialDays": 0,
        "returnUrl": "https:\/\/shop-domain.myshopify.com\/admin\/apps\/my-app"
      },
      "confirmationUrl": "https:\/\/theoptishop.myshopify.com\/admin\/charges\/6702869\/25893175455\/RecurringApplicationCharge\/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwifgFoHBgA6EmF1dG9fYWN0aXZhdGVU--24baf5d062ada47f14da4d1c1d161bc0803c5a9b",
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 990,
        "restoreRate": 50.0
      }
    }
  }
}



 

Accepted Solution (1)

vanley
Shopify Partner
4 1 0

This is an accepted solution.

Not a bug, just make sure that mutation is defined correctly:


mutation appSubscriptionCreate($test: Boolean, $trialDays: Int, $lineItems: [AppSubscriptionLineItemInput!]!, $name: String!, $returnUrl: URL!) {
appSubscriptionCreate(test: $test, trialDays: $trialDays, lineItems: $lineItems, name: $name, returnUrl: $returnUrl) {
appSubscription {
id
name
test
trialDays
returnUrl
}
confirmationUrl
userErrors {
field
message
}
}
}

{
"lineItems": {
"plan": {
"appRecurringPricingDetails": {
"discount": {
"durationLimitInIntervals": 3,
"value": {
"amount": 3.00
}
},
"interval": "EVERY_30_DAYS",
"price": {
"amount": 9.00,
"currencyCode": "USD"
}
}
}
},
"name": "MY AWESOME PLAN 2",
"replacementBehavior": "APPLY_IMMEDIATELY",
"returnUrl": "http://super-duper.shopifyapps.com/",
"test": true,
"trialDays": 14
}

 

View solution in original post

Reply 1 (1)

vanley
Shopify Partner
4 1 0

This is an accepted solution.

Not a bug, just make sure that mutation is defined correctly:


mutation appSubscriptionCreate($test: Boolean, $trialDays: Int, $lineItems: [AppSubscriptionLineItemInput!]!, $name: String!, $returnUrl: URL!) {
appSubscriptionCreate(test: $test, trialDays: $trialDays, lineItems: $lineItems, name: $name, returnUrl: $returnUrl) {
appSubscription {
id
name
test
trialDays
returnUrl
}
confirmationUrl
userErrors {
field
message
}
}
}

{
"lineItems": {
"plan": {
"appRecurringPricingDetails": {
"discount": {
"durationLimitInIntervals": 3,
"value": {
"amount": 3.00
}
},
"interval": "EVERY_30_DAYS",
"price": {
"amount": 9.00,
"currencyCode": "USD"
}
}
}
},
"name": "MY AWESOME PLAN 2",
"replacementBehavior": "APPLY_IMMEDIATELY",
"returnUrl": "http://super-duper.shopifyapps.com/",
"test": true,
"trialDays": 14
}