Skip to content

HandleAuthCallback redirectUrl fails when using AppSubscription Charge override #16

@melissadonohue

Description

@melissadonohue

Bug Description:

Shopify throws an "Invalid Signature" error on App Subscription Charge acceptance for the merchant and they are unable to continue forward.
Screen Shot 2022-01-13 at 1 14 54 PM

To Reproduce:

in pages/api/auth/callback.js:

Create a custom afterAuth function to create a subscription.
Retrieve the confirmationUrl from the appSubscriptionCreate response
return confirmationUrl from function

          //  const recurringApplicationCharge = ....                    

         //fetch confirmationURL
            const redirectUrl =
                recurringApplicationCharge.body.data.appSubscriptionCreate
                    .confirmationUrl;

            // Redirect to billing url
            return redirectUrl;

Upon returning control to handleAuthCallback.js, the following code block executes:

      res.redirect(
        `${redirectPath || process.env.HOME_PATH}?${querystring.stringify(
          req.query
        )}`

The resulting redirectURL is set to

https://neutrl-test.myshopify.com/admin/charges/6343291/22336962698/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwiKAGMzBQA6EmF1dG9fYWN0aXZhdGVU--f798ca9351ce0b009fb468ec84047546fe1bc748?code=574ffe545a8611d071742065c1ef679e&hmac=9092dcabfa0b802eb11bfc0cb40e834245ed466c407c20f0beee2636f6d1cec1&host=bmV1dHJsLXRlc3QubXlzaG9waWZ5LmNvbS9hZG1pbg&shop=neutrl-test.myshopify.com&state=f18b54560a470f7f76a03b426918db27&timestamp=1642099550

The issue is that the redirect string is adding in an additional ? whereas in the overridden scenario, it should append an & as there is already a query parameter present in the URL string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions