public async Task <IActionResult> SyncData(string StoreName, string AccessToken, int Duration, bool InventorySync, bool ProductSync, bool CustomerSync, bool OrderSync) { StoreName = "netabc"; string shopifyurl = $"https://{StoreName}.myshopify.com/"; AccessToken = "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"; InstallResponse response = new InstallResponse(); await CreateUninstallHook(shopifyurl, AccessToken); response.CustomerSync = await SyncCustomers(shopifyurl, AccessToken); response.ProductSync = await SyncProducts(shopifyurl, AccessToken); response.OrderSync = await SyncOrders(shopifyurl, AccessToken, Duration); //if (CustomerSync == true) //{ // response.CustomerSync = await SyncCustomers(shopifyurl, AccessToken); //} //if (ProductSync == true) //{ // response.ProductSync = await SyncProducts(shopifyurl, AccessToken); //} //if (OrderSync == true) //{ // response.OrderSync = await SyncOrders(shopifyurl, AccessToken, Duration); //} response.WebhookCreated = await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/uninstall", "app/uninstalled"); //await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addcustomer", "customers/create"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addcustomer", "customers/create"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addcustomer", "customers/update"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/deletecustomer", "customers/delete"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addproduct", "products/create"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addproduct", "products/update"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/deleteproduct", "products/delete"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addorder", "orders/create"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/addorder", "orders/updated"); await CreateWebHook(shopifyurl, AccessToken, $"{config.Value.RootUrl}/home/deleteorder", "orders/delete"); response.StoreLocations = await StoreLocations(shopifyurl, AccessToken); return(View()); }
public async Task <IActionResult> auth(string shop, string code, string hmac, string state) { string[] shosp = shop.Split("."); string shopname = shosp[0]; string accessToken = ""; shopnamer = shop; var requestHeaders = Request.Headers; var redirecttype = requestHeaders.FirstOrDefault(x => x.Key == "Sec-Fetch-Dest").Value.FirstOrDefault(); //var redirecttype1 = requestHeaders.FirstOrDefault(x => x.Key == "Sec-Fetch-Dest"); //redirecttype1.Value = "iframe"; if (!string.IsNullOrEmpty(shop) && !string.IsNullOrEmpty(code)) { InstallResponse response = new InstallResponse(); accessToken = await AuthorizationService.Authorize(code, shop, apiKey, apiPassword); token = accessToken; shopifyurl = shop; //await CreateUninstallHook(shopifyurl, token); } if (redirecttype == "iframe") { return(RedirectToAction("IntegrationStore")); //return RedirectToAction("Index"); } await StoreLocations(shop, accessToken); await InstallResponse(shopname, accessToken); //response.StoreLocations = await StoreLocations(); //return View(); IsAuth = true; var AbsoluteUri = $"https://{shop}/admin/apps/{apiKey}"; //return StatusCode(200); return(Redirect(AbsoluteUri)); }