reactjsshopify-appshopify-apishopify-api-node

How to redirect to shopify payment page on choose of any pricing plan in React standlone app


I am writing a non-embeeded standlone shopify app in react and node.

I am having 3 pricing plans in my app, now I want on select of any plan it should redirect to payment page of shopify

I am able to create a recurring pricing charge by this graphQL Query

const response = await client.query({
    data: `mutation CreateSubscription{
    appSubscriptionCreate(
      name: "${planName}"
      returnUrl: "${returnUrl}"
      test: true
      lineItems: [
        {
          plan: {
            appRecurringPricingDetails: {
              price: { amount: ${planPrice}, currencyCode: USD }
            }
          }
        }
      ]
    ) {
      userErrors {
        field
        message
      }
      confirmationUrl
      appSubscription {
        id
        status
      }
    }
  }
`,
  });

By this my charge is getting created but user is not redirected to the payment page


Solution

  • I got the solution, this api returning a key confirmation_url which is payment url. Frontend can simply redirect to this page for payment gateway