ordertransaction documentation lacks non-deprecated receipt field

Solved
True_Primal_LLC
Excursionist
33 1 12

According to https://help.shopify.com/en/api/graphql-admin-api/reference/object/ordertransaction the only way to get the actual core information is from a deprecated field called "receipt". The documentation says instead to use "receiptJson". However "receiptJson" is not documented on that page, and does not appear to actually exist. Requesting "receiptJson" from the API errors out. (Requesting "receipt" works fine, although the field itself is bizarre - it appears to be sort of close to JSON, but not quite - and there's no documentation on how to parse it.)

 

Can someone correct the documentation on "receipt"? Or explain some trick to somehow get "receiptJson"?

Accepted Solution (1)

Accepted Solutions
True_Primal_LLC
Excursionist
33 1 12

This is an accepted solution.

3+ years later, as of 2022-04 this appears to be fixed. The /admin/api/2022-04/graphql.json now has a working API that returns the core information in `receiptJson`, a non-deprecated field.

View solution in original post

Replies 25 (25)
True_Primal_LLC
Excursionist
33 1 12

The "receipt" field returns a string like the following:

 

{"paid_amount"=>"54.99"}

 

Does anyone recognize that format?  It looks vaguely similar to JSON, but isn't.  Not sure what the parse rules could be.  (One would hope "receiptJson" is actual JSON, but since that field doesn't exist, who knows.)

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @True_Primal_LLC,

 

Thanks for reporting this, we're looking into it.

Scott | Developer Support @ 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

True_Primal_LLC
Excursionist
33 1 12

Any ideas what's going on with the missing "receiptJson", or what the "receipt" string is formatted in?

True_Primal_LLC
Excursionist
33 1 12

The "2020-01 release candidate" still has this issue. Any status update?

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @True_Primal_LLC,

 

No update yet.

Scott | Developer Support @ 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

True_Primal_LLC
Excursionist
33 1 12

This may have gotten even worse now. The latest version of the doc has removed any mention of the only field that had any real information to it: https://help.shopify.com/en/api/graphql-admin-api/reference/object/ordertransaction?api[version]=202...

 

With the receipt field gone - has that information on fees moved somewhere else?

True_Primal_LLC
Excursionist
33 1 12

Looks like maybe a transient web issue was preventing me from seeing the deprecated field list a few days ago.

 

But I see 2020-04 and 2020-01 (current) both still have the original problem. Any status update on that?

True_Primal_LLC
Excursionist
33 1 12

FWIW, this is still broken in the https://shopify.dev/docs/admin-api/graphql/reference/object/ordertransaction?api[version]=2020-04 latest. The real core of the information is all in "receipt" which is listed as a deprecated field.

True_Primal_LLC
Excursionist
33 1 12

Appears to be still broken on the ordertransaction call - any update on that information being available, perhaps in some other call?

True_Primal_LLC
Excursionist
33 1 12

Looks like another API revision was placed at https://shopify.dev/docs/admin-api/graphql/reference/object/ordertransaction?api[version]=2020-07 but seemingly no change to fix this. Any status?

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Thanks for your patience on this one. It should now be available on unstable:

 

/admin/api/unstable/graphql.json

{
  orders(first: 10) {
    edges {
      node {
        transactions {
          receiptJson
        }
      }
    }
  }
}

Given it's mentioned in earlier API versions I'll chase up why it's not available and either update the APIs or docs.

Scott | Developer Support @ 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

True_Primal_LLC
Excursionist
33 1 12

Thanks! It's a bit strange there, but at least it's parseable.  It's being returned not as JSON like all the other JSON in the API, but actually as a giant string which can then be double-parsed to get the actual information.

 

So to get the 'transaction_fee_total_amount' for example you have to do:

 

json.loads(response.json()['data']['orders']['edges'][0]['node']['transactions'][0]['receiptJson'])['charges']['data'][0]['metadata']['transaction_fee_total_amount']

 

That extra json.loads() is very strange in the context of a REST API. If that's really the intent, the documentation should say so. I wonder if it was a mistake though.

Jgoraya510
Tourist
7 0 1

I'm following up on this issue. 'ReceiptJSON' is erroring out on the current version although 'Receipt' works just fine it's returning an odd format that will require some parsing. It's highly likely this is a bug. When does Shopify plan to fix this and update its documentation?

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Thanks @Jgoraya510, are you able to access via unstable version? As in:

/admin/api/unstable/graphql.json

{
  orders(first: 10) {
    edges {
      node {
        transactions {
          receiptJson
        }
      }
    }
  }
}

@True_Primal_LLC - are you still getting weird formatting? Can you share an order ID?

Scott | Developer Support @ 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

True_Primal_LLC
Excursionist
33 1 12

The weird double-encoded JSON applies to all order IDs. Nothing has changed since my "05-29-2020 11:38 AM" comment. We're actually downloading from the "unstable" on a regular basis, as its the only place to get fee data on orders, and account for everything. If anything changed it would break accounting, so we'd know immediately. It should get fixed though because it's rather bizarre and inefficient.

Jgoraya510
Tourist
7 0 1

Scott,

Thank you for the prompt response! I tried RecieptJson on the unstable version and I get a similar response to using Receipt on the current version. The response has a weird structure - it's a long string with so many fields concatenated together which will require a lot of parsing to get it in a format that can be consumed. Below is a snip of the response - I've removed any private data so you won't see the returned values and only the fields. I don't need every field in the response and would like the ability to specify what I want. 

 

\"capture_method\":\"manual\",\"metadata\":{\"shop_id\":\"\",\"shop_name\":\\",\"manual_entry\":\"false\",\"order_id\":\" \",\"email\":\" \"},\"amount\":,\"currency\":\"usd\",\"description\":\" \",\"confirmation_method\":\"manual\",\"payment_method_types\":[\"card\"],\"payment_method_options\":{\"card\":{\"installments\":null,\"\":\"automatic\"}},\"shipping\":{\"address\":{\"city\":\"\\",\"country\":\" \",\"line1\":\" \",\"line2\":null,\"postal_code\":\"\",\"state\":

 

 

True_Primal_LLC
Excursionist
33 1 12

That's JSON. It's just double-encoded as mentioned above. Run it through json.loads() or something a second time.

Jgoraya510
Tourist
7 0 1

@True_Primal_LLC  - Thanks will do! I am actually working on a similar project to yours. I am building a script to automatically reoncile transactions between Shopify and our Payment Gateway.

I was hoping you could help answer some questions I have:

Did you go to the traditional GraphQl pagination route or are you running Bulk Operation? We have about ~6k orders each month so I am afraid I will run into throttle issues if I go the pagination route. 

How do you consider data in fields that are not static (ie; transaction moved from authorized to voided) - do you refresh the data by pulling from the beginning of the shops time each time the code is executed? Or is there a better way to think about this problem?

Thanks for your help in advance!