Issue creating test subscription

Hi All,

Busy Migrating the recurring charge rest api to graphQL and seem to be having trouble creating a test charge.

Here is my query value payload for the appSubscriptionCreate mutation

{
    "test": true,
    "name": "Basic",
    "returnUrl": "https://ecommercify.ngrok.io/?action=merchant.subscriptioncallback&plan=Basic&_token=CFC74B54F51CDCF42FDAA58EAB277F36",
    "lineItems": [
        {
            "plan": {
                "appRecurringPricingDetails": {
                    "price": {
                        "currencyCode": "USD",
                        "amount": 9
                    }
                }
            }
        },
        {
            "plan": {
                "appUsagePricingDetails": {
                    "cappedAmount": {
                        "currencyCode": "USD",
                        "amount": 1000
                    },
                    "terms": "0.1 per label"
                }
            }
        }
    ]
}

And here is the result:

"data": {
        "appSubscriptionCreate": {
            "userErrors": [],
            "appSubscription": {
                "id": "gid://shopify/AppSubscription/29848142078",
                "test": false,
                "lineItems": [
                    {
                        "id": "gid://shopify/AppSubscriptionLineItem/29848142078?v=1&index=0",
                        "plan": {
                            "pricingDetails": {
                                "__typename": "AppRecurringPricing"
                            }
                        }
                    },
                    {
                        "id": "gid://shopify/AppSubscriptionLineItem/29848142078?v=1&index=1",
                        "plan": {
                            "pricingDetails": {
                                "__typename": "AppUsagePricing"
                            }
                        }
                    }
                ]
            },
            "confirmationUrl": "https://devshopch.myshopify.com/admin/charges/147227443201/29848142078/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwj%2BgBbzBgA6EmF1dG9fYWN0aXZhdGVU--426cae8894ea2e21ae9f4654fa5f45670dbe3563"
        }
    }

The way I see it “test” should be true and not false.

x-request-id is:71918f27-f9fb-4968-82a0-fa5576d9323b-1736345103

Anyone see anything obviously wrong with my payload?

Cheers,
Gary

mutation {
  appSubscriptionCreate(
    name: "Basic",
    returnUrl: "https://xxx/monthly",
    test: true,
    
    lineItems: [
    {
      plan: {
        appRecurringPricingDetails: {
          price: { amount: 999, currencyCode: USD },
          interval: EVERY_30_DAYS
        }
      }
    },
        {
            plan: {
                appUsagePricingDetails: {
                    cappedAmount: {
                        currencyCode: USD,
                        amount: 1000
                    },
                    terms: "test"
                }
            }
        }
    
    ]
  ){
    userErrors {
      field
      message
    }
    confirmationUrl
    appSubscription {
      id
      test
      lineItems {
        id
        plan {
          pricingDetails {
            __typename
          }
        }
      }
    }
  }
}

this returns test: true for me. Your query also looks good. Have you tried with another API version? Can you post the exact payload in the request?

Hey thanks for posting your query, it lead me to find the mistake in mine. Here is my final query which now works as expected.

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

Cheers,
Gary

1 Like