How to enable Test Mode in Billing using Graphql?

Solved

How to enable Test Mode in Billing using Graphql?

tyuzu
Shopify Partner
33 1 0

Hello I'm building Billing plans for my App. But I can't test it since the created charge is not for for test which I can't proceed on confirmationUrl since it needs real credit card.

 

Already added test: true on the variable but still it return test: false on response.

 

// Request GrapQL
const response: Response = await admin.graphql(
    `#graphql
    mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
        appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {
          userErrors {
            field
            message
          }
          appSubscription {
            id
            name
            status
            test
          }
          confirmationUrl
        }
    }`,
    {
        variables: {
            "name": "Super Duper Recurring Plan",
            "returnUrl": "http://super-duper.shopifyapps.com/",
            "lineItems": [
              {
                "plan": {
                  "appRecurringPricingDetails": {
                    "price": {
                      "amount": 10,
                      "currencyCode": "USD"
                    },
                    "interval": "EVERY_30_DAYS"
                  }
                }
              },
            ],
            "test": true
          }
          ,
    }
);

const responseJson = await response.json();

return responseJson;

// Response
05:58:58 │                     remix │ appSubscriptionCreateResponse:  {
05:58:58 │                     remix │   userErrors: [],
05:58:58 │                     remix │   appSubscription: {
05:58:58 │                     remix │     id: 'gid://shopify/AppSubscription/xxxxxx',
05:58:58 │                     remix │     name: 'Super Duper Recurring Plan',
05:58:58 │                     remix │     status: 'PENDING',
05:58:58 │                     remix │     test: false
05:58:58 │                     remix │   },
05:58:58 │                     remix │   confirmationUrl: 'https://xxxxx.myshopify.com/admin/charges/84537933825/35213082904/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh
7BzoHaWRsKwgYAd0yCAA6EmF1dG9fYWN0aXZhdGVU--xxxxxxxxx'
05:58:58 │                     remix │ }

tyuzu_0-1739512893427.png

Also click cancel button return this error:

tyuzu_2-1739513144531.png

 

 

 

While using Remix billing does redirect to test charged billing.

tyuzu_1-1739513063266.png

 

Can you help me guys?

Accepted Solution (1)

tyuzu
Shopify Partner
33 1 0

This is an accepted solution.

mutation error test was not defined. Sorry, I just realized now.

 

    mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
        appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {

View solution in original post

Reply 1 (1)

tyuzu
Shopify Partner
33 1 0

This is an accepted solution.

mutation error test was not defined. Sorry, I just realized now.

 

    mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
        appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {