Re: Graphql Billing API: Error During Redirection to confirmationUrl

Graphql Billing API: Error During Redirection to confirmationUrl

SMSol
Shopify Partner
2 0 0

In my shopify app I utilised the  following code, standard shopify code, in the loader function to handle the billing process:

   const response = await admin.graphql(
      `#graphql
      mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $test: Boolean, $returnUrl: URL!,
      $trialDays: Int
      ) {
        appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, test: $test, trialDays: $trialDays) {
          userErrors {
            field
            message
          }
          appSubscription {
            id
          }
          confirmationUrl
        }
      }`,
      {
        variables: {
          "name": "desiredName",
         
          "returnUrl": desiredURL,
          "test": true,
          "lineItems": [
            {
              "plan": {
                "appRecurringPricingDetails": {
                  "price": {
                    "amount": 20.0,
                    "currencyCode": "EUR"
                  },
                  "interval": "EVERY_30_DAYS"
                }
              }
            }
          ],
          "trialDays": 14
        },
      },
    );

    const billing_data = await response.json();

    const confirmationUrl = billing_data.data.appSubscriptionCreate.confirmationUrl;

    redirect(confirmationUrl, { target: "_parent" });


But during transition to the payment page (confirmationUrl) for some seconds I see a code "200" on my page:

0.png

 

Meanwhile in the browser's console some errors show up. But , after some seconds it redirects to the correct payment page. Any idea what is the problem and how can I resolve it?




Replies 2 (2)

gojiberry-des
Shopify Partner
29 7 5

I am unsure about Shopify's redirect function, but maybe you can try "window.open(confirmationUrl, '_parent')" instead and see if that has the same issue.

If you like my suggestion please give it a LIKE or mark it as a solution! ★★★★★

Gojiberry - Best post-purchase survey and feedback app for Shopify | Install on App Store for free
Shopify Community is helpful, BUT... why not start asking your customers for feedback instead?

SMSol
Shopify Partner
2 0 0

Thank you for your suggestion. But, unfortunately it ends up at the same issue.