mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Checking that order exists on Shopify before registering transaction
This commit is contained in:
parent
0af4be3d99
commit
c3d8c8d4b0
2 changed files with 13 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue