Checking that order exists on Shopify before registering transaction

This commit is contained in:
rockstardev 2020-09-13 17:15:20 -05:00 committed by Kukks
parent 0af4be3d99
commit c3d8c8d4b0
2 changed files with 13 additions and 0 deletions

View file

@ -84,6 +84,14 @@ namespace BTCPayServer.Services.Shopify
return parsed.count;
}
public async Task<bool> OrderExists(string orderId)
{
var req = createRequest(_creds.ShopName, HttpMethod.Get, $"orders/{orderId}.json?fields=id");
var strResp = await sendRequest(req);
return strResp?.Contains(orderId, StringComparison.OrdinalIgnoreCase) == true;
}
}
public class ShopifyApiClientCredentials

View file

@ -48,6 +48,11 @@ namespace BTCPayServer.Services.Shopify
if (storeBlob.Shopify?.IntegratedAt.HasValue == true)
{
var client = createShopifyApiClient(storeBlob.Shopify);
if (!await client.OrderExists(shopifyOrderId))
{
// don't register transactions for orders that don't exist on shopify
return;
}
try
{