From 30d0410b49f6a070a9b8a51594d4e5b544329934 Mon Sep 17 00:00:00 2001 From: Kukks Date: Fri, 25 Feb 2022 10:31:37 +0100 Subject: [PATCH] fix shopify settings --- .../Controllers/UIServerController.Storage.cs | 4 - .../Plugins/Shopify/Models/ShopifySettings.cs | 4 + .../Plugins/Shopify/UIShopifyController.cs | 25 +--- .../UIShopify/EditShopifyIntegration.cshtml | 136 +++++++++--------- 4 files changed, 76 insertions(+), 93 deletions(-) diff --git a/BTCPayServer/Controllers/UIServerController.Storage.cs b/BTCPayServer/Controllers/UIServerController.Storage.cs index 42770710b..abd07dcf4 100644 --- a/BTCPayServer/Controllers/UIServerController.Storage.cs +++ b/BTCPayServer/Controllers/UIServerController.Storage.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; -using BTCPayServer.Models; using BTCPayServer.Models.ServerViewModels; using BTCPayServer.Storage.Models; using BTCPayServer.Storage.Services.Providers.AmazonS3Storage; @@ -17,12 +16,9 @@ using BTCPayServer.Storage.Services.Providers.GoogleCloudStorage; using BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration; using BTCPayServer.Storage.Services.Providers.Models; using BTCPayServer.Storage.ViewModels; -using BTCPayServer.Views; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace BTCPayServer.Controllers diff --git a/BTCPayServer/Plugins/Shopify/Models/ShopifySettings.cs b/BTCPayServer/Plugins/Shopify/Models/ShopifySettings.cs index 9f2e0e0e6..728d5af6c 100644 --- a/BTCPayServer/Plugins/Shopify/Models/ShopifySettings.cs +++ b/BTCPayServer/Plugins/Shopify/Models/ShopifySettings.cs @@ -8,7 +8,11 @@ namespace BTCPayServer.Plugins.Shopify.Models { [Display(Name = "Shop Name")] public string ShopName { get; set; } + + [Display(Name = "Api Key (Apps->Develop Apps-> Create app)")] public string ApiKey { get; set; } + + [Display(Name = "Api Secret Key")] public string Password { get; set; } public bool CredentialsPopulated() diff --git a/BTCPayServer/Plugins/Shopify/UIShopifyController.cs b/BTCPayServer/Plugins/Shopify/UIShopifyController.cs index 20a2e2996..0d8af3f0a 100644 --- a/BTCPayServer/Plugins/Shopify/UIShopifyController.cs +++ b/BTCPayServer/Plugins/Shopify/UIShopifyController.cs @@ -214,31 +214,8 @@ namespace BTCPayServer.Plugins.Shopify [HttpPost("stores/{storeId}/integrations/shopify")] public async Task EditShopifyIntegration(string storeId, - ShopifySettings vm, string command = "", string exampleUrl = "") + ShopifySettings vm, string command = "") { - if (!string.IsNullOrEmpty(exampleUrl)) - { - try - { - //https://{apikey}:{password}@{hostname}/admin/api/{version}/{resource}.json - var parsedUrl = new Uri(exampleUrl); - var userInfo = parsedUrl.UserInfo.Split(":"); - vm = new ShopifySettings() - { - ApiKey = userInfo[0], - Password = userInfo[1], - ShopName = parsedUrl.Host.Replace(".myshopify.com", "", - StringComparison.InvariantCultureIgnoreCase) - }; - command = "ShopifySaveCredentials"; - } - catch (Exception) - { - TempData[WellKnownTempData.ErrorMessage] = "The provided Example Url was invalid."; - return View(vm); - } - } - switch (command) { case "ShopifySaveCredentials": diff --git a/BTCPayServer/Views/UIShopify/EditShopifyIntegration.cshtml b/BTCPayServer/Views/UIShopify/EditShopifyIntegration.cshtml index 69c133e6d..51e32c3a9 100644 --- a/BTCPayServer/Views/UIShopify/EditShopifyIntegration.cshtml +++ b/BTCPayServer/Views/UIShopify/EditShopifyIntegration.cshtml @@ -10,76 +10,82 @@ -

- @ViewData["Title"] - - - - - -

-
- @if (!shopifyCredsSet) - { -

Create a Shopify Private App with the permissions "Orders - Read and write"

-
- - -
+
+
+

+ @ViewData["Title"] + + + + + +

+

Connect BTCPay Server to your Shopify checkout experience to accept Bitcoin.

- - } - else - { -
- -
- @if (!Model?.ShopName?.Contains(".") is true) - { - https:// - } - + @if (!ViewContext.ModelState.IsValid) + { +
+ } - @if (!Model?.ShopName?.Contains(".") is true) - { - .myshopify.com - } + +
+ +
+ @if (!Model?.ShopName?.Contains(".") is true) + { + https:// + } + + + @if (!shopifyCredsSet || !Model?.ShopName?.Contains(".") is true) + { + .myshopify.com + } +
+
- -
-
- - - -
+
+ + + +
-
- - - -
-
-

- In Shopify please paste following script at Settings > Checkout > Order Processing > Additional Scripts -

- - @($"") - -
-

- In Shopify please add a payment method at Settings > Payments > Manual Payment Methods with the name Bitcoin with BTCPay Server -

+
+ + + +
-

- Orders on @Model.ShopName.myshopify.com will be marked as paid on successful invoice payment. - Started: @Model.IntegratedAt.Value.ToBrowserDate() -

+ @if (shopifyCredsSet) + { +
+

+ In Shopify please paste following script at Settings > Checkout > Order Processing > Additional Scripts +

+ + @($"") + +
+

+ In Shopify please add a payment method at Settings > Payments > Manual Payment Methods with the name Bitcoin with BTCPay Server +

+

+ Orders on @Model.ShopName.myshopify.com will be marked as paid on successful invoice payment. + Started: @Model.IntegratedAt.Value.ToBrowserDate() +

- - } - - + + } + else + { + + } + +
+