nozzlegear / ShopifySharp

ShopifySharp is a .NET library that helps developers easily authenticate with and manage Shopify stores.
https://nozzlegear.com/shopify-development-handbook
MIT License
764 stars 313 forks source link

Order Fee Information #1095

Closed TK20466 closed 2 months ago

TK20466 commented 2 months ago

Hey there,

I'm trying to gather information on the fees from orders as part of a bookkeeping app. For a real example from our shop:

I'm a bit confused as to how I can actually gather this information from the API. Through the Orders API we can see the $74.10 in the TotalPrice property, which gets us started.

However, looking through the Transactions api, it looks like all the fee information is covered in the Receipts sub property by the API which isn't covered by this project (if I understand correctly?).

Is there a way to gather this information through this API? I realize I could calculate it myself but I'd rather get the info from the API in what we were actually charged from the transaction rather than assuming myself.

Any advice?

nozzlegear commented 2 months ago

Hey! That's an excellent question. Just so I'm clear, you're trying to get a clear idea of the revenue and fees being paid per order from the point of view of a store owner, correct? The transactions api is probably the way to go; the only thing I'm not sure about is the fees Shopify itself takes out of your payout. I'm not entirely clear on whether those will show up in the transactions API, or if they'll show your payment processor's fees when you use someone other than Shopify.

I don't have a Shopify store myself, but I do use their special partner API to query how much my apps have made per charge and then subtract their processing fee from that for a rough idea of tax burden owed each quarter. I know this some partner API has data available for store payouts, but I don't think it breaks it down per order.

Anyway, I'll take a look at the ShopifySharp's transactions implementation and get the missing pieces put in!

TK20466 commented 2 months ago

@nozzlegear Thanks! I'll look at that. After digging a bit I was able to capture PayPal payment fees from the Receipts property by defining a type based on their structure and deserializing to that.

Unfortunately so far I'm still at a dead end for Shopify Fees from the transaction itself. It looks like the Payout Transactions API is the only way to do it. I can scrape that data and then tie it to an order on the back end of my own code... though it's a bigger pain in the neck to do it that way.

This isn't really a problem with ShopifySharp but their API itself, so feel free to close this issue if you want. This library has been extremely helpful!

clement911 commented 2 months ago

Have you looked into OrderTransaction.Fees?

TK20466 commented 2 months ago

Have you looked into OrderTransaction.Fees?

I have not! ShopifySharp uses the REST API only, not the GRAPHQL correct? Playing around in a Postman scratchpad this looks like it gets me exactly what I need.

clement911 commented 2 months ago

Yes ShopifySharp fully supports GraphQL, although I'm not sure if it's documented anywhere, you can use the GraphService. There are a few tests that should give you an idea on how to use it.

TK20466 commented 2 months ago

Yes ShopifySharp fully supports GraphQL, although I'm not sure if it's documented anywhere, you can use the GraphService. There are a few tests that should give you an idea on how to use it.

You're the best, thank you!!