I’m building a tool for analyzing our sales. For many months, I’ve been running certain queries to retrieve transactions and store them in our database. Today, I noticed errors and a strange record in the logs.
For pending payments I saw lines like this:
I dla QUERY w Partner API:
query getTransactions($after: String, $appId: ID!, $createdAtMin: DateTime) {
transactions(
appId: $appId
types: [APP_SUBSCRIPTION_SALE]
after: $after
createdAtMin: $createdAtMin
first: 100
) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
cursor
__typename
node {
id
__typename
... on AppSubscriptionSale {
billingInterval
chargeId
createdAt
grossAmount {
amount
currencyCode
}
netAmount {
amount
currencyCode
}
shopifyFee {
amount
currencyCode
}
}
}
}
}
}
I get this response:
{
"data": {
"transactions": {
"pageInfo": {
"hasNextPage": false,
"hasPreviousPage": false
},
"edges": [
{
"cursor": "eyJwYXJ0bmVyX3JlY2VpdmFibGVfY3JlYXRlZF9hdCI6MTcwNzY4MTIxNTAwMCwiaWQiOiIyOTIxMzYxMzQifQ",
"__typename": "TransactionEdge",
"node": {
"id": "gid://partners/AppSubscriptionSale/292136134",
"__typename": "AppSubscriptionSale",
"billingInterval": null,
"chargeId": null,
"createdAt": "2024-02-11T19:53:35.000000Z",
"grossAmount": {
"amount": "-1.67",
"currencyCode": "USD"
},
"netAmount": {
"amount": "-1.67",
"currencyCode": "USD"
},
"shopifyFee": {
"amount": "0.0",
"currencyCode": "USD"
}
}
}
]
}
}
}
I’m getting an error because transactions are associated with specific subscriptions (chargeId
), but as it appears in the response, the API returns a null value for the chargeId field.
In general, I can skip this record during data import if there is a null value there, but this raises a few questions:
- Is it correct that for queries of type APP_SUBSCRIPTION_SALE, it returns some negative amounts?
- Shouldn’t this type of transaction be of a different type? Shouldn’t it be categorized as APP_SALE_ADJUSTMENT (similar to refunds)?
- If the type is correct, is there a possibility to add a value for chargeId?