diff --git a/src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al b/src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al index 081b40ecda..acee119c7a 100644 --- a/src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al +++ b/src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al @@ -862,7 +862,7 @@ table 30102 "Shpfy Shop" begin Store := GetStoreName(); if Store <> '' then - AuthenticationMgt.InstallShopifyApp(Store); + AuthenticationMgt.InstallShopifyApp(Store, Rec); end; internal procedure HasAccessToken(): Boolean @@ -892,6 +892,11 @@ table 30102 "Shpfy Shop" Store := Store.TrimStart('/').TrimEnd('/'); end; + internal procedure SetStoreName(Store: Text) + begin + Rec.Validate("Shopify URL", Store); + end; + /// /// Calc Shop Id. /// diff --git a/src/Apps/W1/Shopify/App/src/Integration/Codeunits/ShpfyAuthenticationMgt.Codeunit.al b/src/Apps/W1/Shopify/App/src/Integration/Codeunits/ShpfyAuthenticationMgt.Codeunit.al index 80fb88e8ed..6bf47168d1 100644 --- a/src/Apps/W1/Shopify/App/src/Integration/Codeunits/ShpfyAuthenticationMgt.Codeunit.al +++ b/src/Apps/W1/Shopify/App/src/Integration/Codeunits/ShpfyAuthenticationMgt.Codeunit.al @@ -65,7 +65,7 @@ codeunit 30199 "Shpfy Authentication Mgt." end; [NonDebuggable] - internal procedure InstallShopifyApp(InstalllToStore: Text) + internal procedure InstallShopifyApp(InstallToStore: Text; var Shop: Record "Shpfy Shop") var OAuth2: Codeunit "OAuth2"; ShopifyAuthentication: Page "Shpfy Authentication"; @@ -79,15 +79,23 @@ codeunit 30199 "Shpfy Authentication Mgt." InstallURLTxt: Label 'https://%1/admin/oauth/authorize?scope=%2&redirect_uri=%3&state=%4&grant_options[]=%5', Comment = '%1 = Store, %2 = Scope, %3 = RedirectUrl, %4 = State, %5 = GrantOptions', Locked = true; InstallURLWithClientIdParamTok: Label '%1&client_id=%2', Comment = '%1 = InstallURLTxt, %2 = ClientId', Locked = true; NotMatchingStateErr: Label 'The state parameter value does not match.'; + StoreMismatchLbl: Label 'The store URL returned from Shopify differs from the URL you entered. You can find your store''s internal URL in Shopify Admin under Domains settings. Do you want to update the store URL to match?'; begin OAuth2.GetDefaultRedirectURL(RedirectUrl); State := Random(999); - Url := StrSubstNo(InstallURLTxt, InstalllToStore, GetScope(), RedirectUrl, State, GrandOptionsTxt); + Url := StrSubstNo(InstallURLTxt, InstallToStore, GetScope(), RedirectUrl, State, GrandOptionsTxt); FullUrl := StrSubstNo(InstallURLWithClientIdParamTok, Url, GetClientId()); ShopifyAuthentication.SetOAuth2Properties(FullUrl); Commit(); ShopifyAuthentication.RunModal(); Store := ShopifyAuthentication.Store(); + + if Store <> InstallToStore then + if Confirm(StoreMismatchLbl) then + Shop.SetStoreName(Store) + else + Error(''); + AuthorizationCode := ShopifyAuthentication.GetAuthorizationCode(); if AuthorizationCode.IsEmpty() then if ShopifyAuthentication.GetAuthError() <> '' then