We are a Shopify Plus client and we have a custom storefront (nextjs app). As a business that is a combination of a service and a store it is very important that users do not change their email address during their checkout process as this will result in Shopify creating a new account for them.
See the following scenario:
1. User goes to our web app (https://app.OUR_DOMAIN.co.uk) and retrieves their checkout by logging in into Storefront API
2. When user is ready to make an order, we log them in into Shopify using Multipass
3. User then ends up on Shopify Checkout page on our primary domain (e.g. https://OUR_DOMAIN.co.uk/33977925764/checkouts/CHECKOUT_ID)
Notice user is shown as logged in on Checkout page
4. User selects PayPal Express and logs in using their PayPal credentials
5. User is then redirected back to Shopify Checkout, but they are now shown as NOT logged in any longer (url is https://OUR_HANDLE.myshopify.com/33977925764/checkouts/CHECKOUT_ID?refresh_count=1) -> notice the *.myshopify.com domain
Expected: user to be still shown as logged in.
In Shopify Admin we have the option to redirect user to Primary Domain selected
@Marcus_ , so this is the solution that Shopify support proposed and (that worked for us).
When you call Storefront API to create or amend users' checkouts, the URL must have your primary custom domain as the base, e.g.
// instead of
// change to
https://<MY_CUSTOM_DOMAIN>/api/2011-04/graphql.json (assuming your checkout url is `https://<MY_CUSTOM_DOMAIN>/checkout/...`
The fix will not resolve the issue retrospectively, so only new checkouts created with <MY_CUSTOM_DOMAIN> storefront URL will have user logged in automatically