How to retrieve Square orderIds for Call to BatchRetrieveORders - square

I want to retrieve a list of orders using the Square API. The call to retrieve orders is a POST call with a String array of order_ids however I'm not sure where I can get this information. In the docs they said I can use the ListTransactions endpoint to get this information but I'm not able to find the order_id within the response.
The documentation to retrieve Orders located at: https://docs.connect.squareup.com/api/connect/v2#endpoint-batchretrieveorders
see sample response of ListTransactions: https://docs.connect.squareup.com/api/connect/v2#endpoint-listtransactions
The Orders API does not support listing of orders. To access order
details, you will need to fetch the order's ID by querying
transactions using the ListTransactions and RetrieveTransaction
endpoints, and then fetching the order using the BatchRetrieveOrders
endpoint
Reference: https://docs.connect.squareup.com/articles/orders-api-overview
The goal is to get a list of recent transactions/orders that list out exactly what was purchased. The Transactions model doesn't contain Items whereas the Orders model does.

The Transaction object will include an order_id field if you included it during the Charge request. If you did not pass the order_id to the Charge request, then it will not show up.
Furthermore - just for clarity's sake, if you use Square Point of Sale, or if you haven't included the order_id previously but still would like to view itemizations for transactions, please look at V1 ListPayments which will include it even if there's no order_id.
References:
https://docs.connect.squareup.com/api/connect/v2#type-transaction
https://docs.connect.squareup.com/api/connect/v1#get-payments

Related

Is there an API call to list all available product id's (ID's alone) in Shopify?

I use POSTMAN GUI for retrieving a list of items from Shopify API.
I would like to know if there exists a way to get available product id's alone, preferably as a list of values over a single api GET call. The one I know of is
/admin/api/2022-04/products.json
It returns a list of all product information, and looping over them/traversing the json is not very efficient. I hope there must be an easy way to fetch all ID's alone in one go. Should there be not?
You can add /admin/api/2022-04/products.json?fields=id to the end of your request to limit the output only for a single field or multiply.
Please note that if you have more than 250 products you will need to make more than one request, since the request is limited to 250 products.
You can make one call to the Admin API for all your product IDs using the Bulk Query. That will result in you receiving a URL where you download a file in JSONL format with every single product ID in your store, without the paging or limits of other approaches.

Retrieve customer related to payment

Anyone know if it's possible to retrieve the customer name related to a transaction from the API?
I see it under "Paid by" if I follow the "payment_url" in the connect v1 https://connect.squareup.com/v1/{{location_id}}/payments/{{payment_id}} endpoint but can't see to find it anywhere else
Background: I'm working on a ticketing system that breaks out items by item_category so a kitchen gets only food items and the bar gets only drink items.
I have queues and itemized tickets by category BUT I can't seem to find the customer's name anywhere
You'll need to utilize the V2 Transactions API. When you call ListTransactions or RetrieveTransaction (ListTransactions), the Transaction object will have an array of Tenders, tenders, which has a field called customer_id. With this id, you will be able to pass it to RetrieveCustomer (RetrieveCustomer) to find out their name. Note that if you're not explicitly filling out their name, the name might not be available (an "instant profile" (Instant Profiles) will be created with whatever information can be retrieve from the card used to pay).
Update: Alternatively, as suggested by #Dan, would be to strip the payment_url from a V1 RetrievePayment (RetrievePayment) which includes the transaction_id at the end of the URL: https://squareup.com/dashboard/sales/transactions/TRANSACTION_ID. This is more efficient as you won't need to loop through transactions, and allow you to send it straight to RetrieveTransaction.

How do I access all the information for a Square transaction?

I am a student (so I am pretty new to all of this stuff) trying to create a database for a coffee shop that uses Square for their register and website. I want the database to update with all the information from a transaction every time one is completed.
I have a webhook that gets me the IDs every time a transaction completes, I can send the transaction ID to the Square API with an http request and get back information about the payment, but I still cannot figure out how to get the rest of the transaction information. We want to query the database about what kinds of items are being sold when and with what modifiers, but so far the only way I can get that is through downloading a csv file with the item line information from the Square Dashboard.
If there is a way to get the line item information in some kind of way that can be automatically added to the database, I would really appreciate the help. I have been looking for a solution and cannot find it on my own.
For in-person payments the only way to see itemizations is to use V1 ListPayments (or RetrievePayment).
In order to see itemizations for online payments, you must utilize Square's Orders API. The workflow would be:
Create an order (CreateOrder) with line_items (can be ad-hoc, or use Catalog ids). Save the order_id for the next step.
When calling Charge, pass in the order_id from the previous step.
Once you are successfully attaching the order_id's, when you retrieve a transaction you will be able to call the BatchRetrieveOrders endpoint with the order_id to see the itemizations.
References:
V1 Payments
Orders Overview
Orders Reference

Square Connect API - API - order

I am developing an application to integrate with square, and I can create orders, but when I consult them with:
https://connect.squareup.com/v2/locations/xxxxxxxxxxxxxx/orders/batch-retrieve
it brings me null
From the docs: Retrieves a set of Orders by their IDs. Only orders that have been successfully charged are included in the response. I'm betting that either you haven't charged the orders yet, or aren't providing the right ids to retrieve.
https://docs.connect.squareup.com/api/connect/v2#endpoint-batchretrieveorders

How to get /admin/products.json in a chronological order?

I need to be able to poll more than 250 products from the Shopify API. In order to do so, I need to retrieve the products from the API in a chronological order, with the oldest products first. Once I have the first 250 items, I retrieve another 250 items filtered by max_created_at.
I noticed that: GET /admin/products.json returns the products in a random order, but GET /admin/products.json?since_id=0 returns the products in a chronological order. Is this the intended behaviour? Or is there a flag that I can send with GET /admin/products.json to specify the sorting order?
Edit: I guess my question boils down to this: Is there a field that I can set that the results returned by the Shopify API will be ordered by?
Maybe the API has been updated since the last post but now you can do that like that :
https://yourshop.myshopift.com/admin/products.json?limit=50&fields=id,images,title&order=created_at+desc
Just add the query string parameter order=created_at+asc
This is an undocumented feature but it seems to work for most fields.
This is unintended behaviour, reliable sort orders for Product are limited to title and total, and then filtering options are as listed in the API docs.