From 1c510d45f0e84fff65be6f062328c8bdf349aa84 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Thu, 17 Sep 2020 00:29:33 -0500 Subject: [PATCH] Commenting code to elaborate on decisions made --- .../Services/Shopify/ShopifyOrderMarkerHostedService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Services/Shopify/ShopifyOrderMarkerHostedService.cs b/BTCPayServer/Services/Shopify/ShopifyOrderMarkerHostedService.cs index eb60a7d4e..36023ced3 100644 --- a/BTCPayServer/Services/Shopify/ShopifyOrderMarkerHostedService.cs +++ b/BTCPayServer/Services/Shopify/ShopifyOrderMarkerHostedService.cs @@ -41,14 +41,15 @@ namespace BTCPayServer.Services.Shopify { var invoice = b.Invoice; var shopifyOrderId = invoice.Metadata?.OrderId; - // TODO: Don't code on live webcast, take time offline with Kukks to verify all flows - // Lightning it can just be paid - if ((invoice.Status == Client.Models.InvoiceStatus.Complete || invoice.Status == Client.Models.InvoiceStatus.Confirmed) + // We're only registering transaction on confirmed or complete and if invoice has orderId + if ((invoice.Status == Client.Models.InvoiceStatus.Confirmed || invoice.Status == Client.Models.InvoiceStatus.Complete) && shopifyOrderId != null) { var storeData = await _storeRepository.FindStore(invoice.StoreId); var storeBlob = storeData.GetStoreBlob(); + // ensure that store in question has shopify integration turned on + // and that invoice's orderId has shopify specific prefix if (storeBlob.Shopify?.IntegratedAt.HasValue == true && shopifyOrderId.StartsWith(SHOPIFY_ORDER_ID_PREFIX, StringComparison.OrdinalIgnoreCase)) { @@ -63,6 +64,8 @@ namespace BTCPayServer.Services.Shopify return; } + // if we got this far, we likely need to register this invoice's payment on Shopify + // OrderTransactionRegisterLogic has check if transaction is already registered which is why we're passing invoice.Id try { await _shopifyEventsSemaphore.WaitAsync();