How to get all orders that don't have gateways?

I am trying to run a query for all orders that don’t have any paymentGatewayNames associated with them, I have the following query,

{
    orders(first: 100,  query: "NOT gateway:*") 
    {
        nodes
        {
            id
            paymentGatewayNames
            transactions{
                id
            }
        }
    }
}

And it does return some orders, but not all. When I add an id of one of the missing orders like so

orders(first: 100,  query: "id:******** AND NOT gateway:*") 
    {
        nodes
        {
            id
            paymentGatewayNames
            transactions{
                id
            }
        }
    }

It does not return the order. Modifying the query like so

{
    orders(first: 100,  query: "id:*********** AND gateway:*") 
    {
        nodes
        {
            id
            paymentGatewayNames
            transactions{
                id
            }
        }
    }
}

does return the order. However there is no payment gateway name for this particular order, the payment gateway names array is empty.

Here is the response for that query

{
    "data": {
        "orders": {
            "nodes": [
                {
                    "id": "gid://shopify/Order/********",
                    "paymentGatewayNames": [],
                    "transactions": []
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 20,
            "actualQueryCost": 2,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1998,
                "restoreRate": 100.0
            }
        },
        "search": [
            {
                "path": [
                    "orders"
                ],
                "query": "id:*********** AND gateway:*",
                "parsed": {
                    "and": [
                        {
                            "field": "id",
                            "match_all": "***********"
                        },
                        {
                            "field": "gateway",
                            "exists": true
                        }
                    ]
                }
            }
        ]
    }
}

Both payment gateway names and transactions are empty arrays, so it should have the gateway exists resolve to false, and not return in this query. Rather is should have returned in the other query, where NOT gateway:* is specified.

In short:
Expected: Queries with NOT gateway:* should return ALL orders without gateways
Actual: Some orders are missing

Expected: Queries with gateway:* should NOT retrun ANY orders without gateways
Actual: Some orders are returned

x-request-id for debugging: 0b02f405-8b74-4458-9912-e2f4cada7001-1765398282

I tried using
gateway:'' OR NOT gateway:* & it helped a bit, but still some orders were wrong.

Is there a way to check for any whitespace? Basically what I want is an equivalent to .NET’s IsNullOrWhiteSpace for any gateway, I think that would do what I want. Is this possible to do with Shopify’s query syntax?

Hi @SRCB,

Thank you for this context, I’ve looked into this a bit with the x-request-id provided, and I’m also able to replicate this behaviour with the same order from that example request, even when including gateway:'' OR NOT gateway:* in the query.

This does look like unexpected behaviour with this particular order, and I am currently discussing this with our developers at this time.

I will keep you updated here as soon as I have any more information to share on why this order is not being returned with NOT gateway:*, or if it is an actual issue that we will be investigating further.

Hi @SRCB,

I’m following up after discussing this with our developers further, with some more information to share on what is occurring here.

The NOT gateway:* filter is actually working as expected, the issue here is with the order. paymentGatewayNames field not returning manual for orders created via the POS with a Manual Payment Method.

WIth the example that you provided, it is correct that the order was NOT returned with NOT gateway:* as the order did technically have the manual payment gateway used at the time of purchase, but the paymentGatewayNames field is only returning gateways from the order transactions, which isn’t including Manual POS Transactions that don’t use Shopify Payments or any alternative payment gateways on the store.

We are currently looking into this behaviour further internally, to confirm the expected behaviour with what order.paymentGatewayNames is returning, and if it’s expected for POS orders with manual payments to create an order transaction or not.

Again I will keep you updated once we have looked into this further, or when we have released a fix for any determined unexpected behaviour.

Here’s some Help Center Documentation with more info on Manual Payment Methods with the POS for reference:

changing my query to " gateway:'' OR gateway:'manual' OR NOT gateway:*" seems to bring up these orders.

I can as a workaround use this, and add a code check to remove any orders that have a gateway set, although this results in overfetching, (which GraphQL tries to avoid).

I understand this workaround may not be ideal, though I’m glad it will work in the meantime. I can confirm that our developers are aware of this behaviour now and are actively investigating and working on a fix further at this time. While we can’t provide any estimated timeframes for a resolution, we will be keeping an eye on this work done by our developers and keep you updated here when the issue is resolved or if we have any further information to share.

1 Like

I think this issue happens when the order is fully refunded without any payment, since this is a full refund, there really is no money to be paid. When the seller then marks the order as paid, no OrderTransaction (or TenderTransaction) is created, since no money needs to be exchanged.

(all of the orders I checked had balances of less than 5 cents)

Hi @SRCB,

Thanks for providing this extra content to aid our investigation.

I’ve looked into this a bit further on my own test store and I can confirm that this is not necessarily correct, with the following details specifically.

Orders without any order transactions will not be able to create any refunds, as there are no transactions to refund.

Additionally orders that are marked as paid by the merchant do actually create an OrderTransaction on the order.

If you have any specific examples that goes against what I’ve experienced on my test store and mentioned above, please do let us know with an x-request-id from an order that’s been manually marked as paid with no order transactions, and we can absolutely look into that further.