Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Inquiry Regarding Strange Transaction Records in Partner API

Inquiry Regarding Strange Transaction Records in Partner API

sebastiandev
Shopify Partner
72 1 24

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: 

earning.png

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:


1. Is it correct that for queries of type APP_SUBSCRIPTION_SALE, it returns some negative amounts?
2. Shouldn't this type of transaction be of a different type? Shouldn't it be categorized as APP_SALE_ADJUSTMENT (similar to refunds)?
3. If the type is correct, is there a possibility to add a value for chargeId?

 

Replies 2 (2)

Liam
Community Manager
3108 344 895

Hi Sebastian,

 

It's possible that you might see negative amounts for transactions with a type of APP_SUBSCRIPTION_SALE  when a shop moves from a full-priced subscription to an inactive subscription. Are your plans set up in a way that could result in this?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sebastiandev
Shopify Partner
72 1 24

https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/appSubscriptionCreate
I understand that you think about replacementBehavior field? We use STANDARD value.

 

But our customer uninstalled and installed app again. 

 

And second - is correctly behaviour that chargeId is null?