SquarePOS - Why isn't the sale appearing on dashboard ? - square

I'm trying to generate a sale from a HTTP POST request using the SquarePOS API
This is the request I fire in Postman
curl -X POST \
https://connect.squareup.com/v2/locations/*****/orders \
-H 'Authorization: Bearer ******' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: ******' \
-d '{
"idempotency_key": "123456AZD",
"reference_id": "my-order-006",
"line_items": [
{
"name": "Américain - Article de base",
"quantity": "1",
"base_price_money": {
"amount": 1599,
"currency": "EUR"
}
}
],
"taxes": [
],
"discounts": [
]
}'
The server answers with
{
"order": {
"id": "DQYutFAsu5hB8Xr56zBdmiilxd4F",
"location_id": "N7VH9XRBT57MP",
"line_items": [
{
"quantity": "1",
"name": "Américain - Article de base",
"base_price_money": {
"amount": 1599,
"currency": "EUR"
},
"gross_sales_money": {
"amount": 1599,
"currency": "EUR"
},
"total_tax_money": {
"amount": 0,
"currency": "EUR"
},
"total_discount_money": {
"amount": 0,
"currency": "EUR"
},
"total_money": {
"amount": 1599,
"currency": "EUR"
}
}
],
"created_at": "2018-04-30T12:44:47.816Z",
"updated_at": "2018-04-30T12:44:47.816Z",
"status": "OPEN",
"reference_id": "my-order-006",
"total_tax_money": {
"amount": 0,
"currency": "EUR"
},
"total_discount_money": {
"amount": 0,
"currency": "EUR"
},
"total_money": {
"amount": 1599,
"currency": "EUR"
}
}
}
Which seems to say that the order has been successfully created. However, when browsing the SquarePOS dashboard, I don't see the sale appearing in the sales list.
Is there something I'm missing when creating the order ?

The order is being created correctly, but I think you are missing something. The Orders API lets you create an order that you can then charge with the Charge endpoint.You cannot create an order via the APIs at this time and have them show up in the Dashboard or Point of Sale without charging them.

Related

BigQuery - UNNEST with a multidimensional array

I am needing to unnest a multidimensional array with multiple items.
My data looks like this (two rows):
Each order in this table has a fulfillments column which is a multidimensional array.
fulfilments has multiple line_items. Some orders only have 1 line_items, some orders have multiple line_items.
My goal is to get each product name and the quantity from each line_items and do a running sum/tally.
Here's a JSON export of the fulfillments column data:
"{
"fulfillments": [{
"value": {
"id": "6575674745",
"tracking_number": null,
"line_items": [{
"value": {
"properties": [{
"value": {
"name": "shipping_interval_unit_type",
"value": "Months"
}
}, {
"value": {
"name": "shipping_interval_frequency",
"value": "1"
}
}, {
"value": {
"name": "ch_item_id",
"value": "77321530"
}
}],
"product_id": "4790985097351",
"total_discount_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"sku": “10101”,
"name": “Product1”,
"variant_id": "33433213108359",
"quantity": "1",
"taxable": "true",
"total_discount": "0",
"title": "Product1 Title",
"price_set": {
"shop_money": {
"amount": "12.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "12.00",
"currency_code": "USD"
}
},
"product_exists": "true"
}
}],
"service": "manual",
"tracking_urls": []
}
}, {
"value": {
"tracking_url": null,
"id": "3555531128967",
"tracking_company": null,
"tracking_number": null,
"name": "#3129472402.2",
"tracking_numbers": [],
"line_items": [{
"value": {
"properties": [{
"value": {
"name": "shipping_interval_frequency",
"value": "1"
}
}, {
"value": {
"name": "shipping_interval_unit_type",
"value": "Months"
}
}, {
"value": {
"name": "ch_item_id",
"value": "77321529"
}
}],
"product_id": "5216409780359",
"total_discount_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"sku": "9005",
"name": “Product2”,
"quantity": "1",
"title": “Product2 Title”,
"price_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"product_exists": "true"
}
}],
"service": "manual",
"tracking_urls": []
}
}]
}"
SELECT
fulfillments[ safe_OFFSET (0)].value.line_items[ safe_OFFSET (0)].value.name AS name,
fulfillments[ safe_OFFSET (0)].value.line_items[ safe_OFFSET (0)].value.quantity AS quantity
FROM
`mydatabase`
isn't ideal in the event the order has more than one array in line_items
How can I unnest a multidimensional array when I don't know how large each array is?
SELECT
*
FROM
`mydatabase`,
UNNEST(fulfillments) as a
Only gives me another array to flatten
Given your scenario, you may try to use this query to unnest line_items with product name and the quantity:
SELECT
line_items.value.name,
line_items.value.quantity,
line_items.value.product_id
from `mydatabase`,
unnest(fulfillments) fulfillments,
unnest(fulfillments.value.line_items) line_items
Output:

Can I perform a GraphQL mutation without query fields?

I have to move products from one Shopify store to another. To do this I am using the Shopify GraphQL admin API. I am transforming the data before moving it so I can't have Shopify help me.
Anyway, I take the products from Shopify's API and they're store in a JSON file. Each product is around 3,000 lines long and contains all variant types.
Do I have to define the query fields and variables? I was hoping to just pass in the entire JSON object that Shopify returns and feed that to GraphQL. Currently I'm having to do define the fields manually (NodeJS):
const addProduct = (product) => axios.post(apiPath, {
query: `
mutation productCreate($input: ProductInput!) {
productCreate(input: $input) {
userErrors {
field
message
}
product {
title
handle
descriptionHtml
...
}
}
}
`,
variables: {
input: {...product}
}
})
But having to define the query fields in this way is going to a very long process, is there any way to do without having to define the query?
Here's an example from the product object from Shopify. I've had to limit the lines:
{
"body_html": " The Air Jordan 3 Retro 'UNC' arrives in March 2020 as an homage to Michael Jordan's alma mater. The special edition presents university-inspired colors on its dual-textured leather upper and eyestays, with elephant print panels granting an iconic touch. Valor Blue hits both Jumpman logos on the tongue and heel while the visible Air unit in the midsole and rubber outsole wrap up the styling. ",
"price_min_usd": 0,
"compare_at_price_max_usd": null,
"available": false,
"review_count": 0,
"percent_sale_min_aud": 0,
"variants": [
{
"merged_options": [
"size:3 UK"
],
"price_cad": "0.00",
"price_usd": "0.00",
"presentment_prices": [
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AED"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AUD"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "CAD"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "DKK"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "EUR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "GBP"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "ILS"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0",
"currency_code": "JPY"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "QAR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "SAR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "USD"
}
}
],
"inventory_management": "shopify",
"available": false,
"title": "UK 3 | EU 35.5 | US 3.5",
"price": "0.00",
"price_aed": "0.00",
"id": 40807884062909,
"sku": "CT8532-104.3UK",
"price_eur": "0.00",
"barcode": null,
"price_dkk": "0.00",
"inventory_quantity": 0,
"image": null,
"compare_at_price": null,
"fulfillment_service": "manual",
"price_aud": "0.00",
"price_ils": "0.00",
"price_jpy": "0",
"inventory_policy": "deny",
"price_gbp": "0.00",
"price_qar": "0.00",
"price_sar": "0.00"
},
{
"merged_options": [
"size:3.5 UK"
],
"price_cad": "0.00",
"price_usd": "0.00",
"presentment_prices": [
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AED"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AUD"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "CAD"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "DKK"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "EUR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "GBP"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "ILS"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0",
"currency_code": "JPY"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "QAR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "SAR"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "USD"
}
}
],
"inventory_management": "shopify",
"available": false,
"title": "UK 3.5 | EU 36 | US 4",
"price": "0.00",
"price_aed": "0.00",
"id": 40807884095677,
"sku": "CT8532-104.3.5UK",
"price_eur": "0.00",
"barcode": null,
"price_dkk": "0.00",
"inventory_quantity": 0,
"image": null,
"compare_at_price": null,
"fulfillment_service": "manual",
"price_aud": "0.00",
"price_ils": "0.00",
"price_jpy": "0",
"inventory_policy": "deny",
"price_gbp": "0.00",
"price_qar": "0.00",
"price_sar": "0.00"
},
{
"merged_options": [
"size:4 UK"
],
"price_cad": "0.00",
"price_usd": "0.00",
"presentment_prices": [
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AED"
}
},
{
"compare_at_price": null,
"price": {
"amount": "0.00",
"currency_code": "AUD"
}
},
{
An easy recipe is to download a product where you get valid Shopify Product JSON. Now remove all the id keys. Send that object to the Product Create in the new store. Repeat in a loop.
You could also bulk download the products, giving you JSON, and iterate that, and build products that way, and call create.
Either way, the code to do this task is short, sweet and not hard.
#BugHunterUK - As per my understanding you're moving products data from one store to another with JSON file but you don't have do it. You can ask Shopify Support to do that. They will move all of your products from store A to B.

Square API: Object version does not match latest database version

I'm trying to use the following Square API endpoint to update an item, but I'm getting some errors. Here is the item that I'm trying to update.
{
"type": "ITEM",
"id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"updated_at": "2020-08-08T21:43:41.849Z",
"version": 1596923021849,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_data": {
"name": "Hummus Plate",
"description": "Olives, feta, tomatoes, tzatziki and warm pita.",
"visibility": "PRIVATE",
"category_id": "ARB5LTTDUSER6T66ZWYO65FL",
"variations": [
{
"type": "ITEM_VARIATION",
"id": "HBIHPLROOJUUNUSW3BZUDQ5J",
"updated_at": "2020-08-08T21:40:14.581Z",
"version": 1596922814581,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_variation_data": {
"item_id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"name": "Regular",
"ordinal": 0,
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1000,
"currency": "USD"
}
}
}
],
"product_type": "REGULAR",
"skip_modifier_screen": true,
"ecom_available": false,
"ecom_visibility": "UNINDEXED"
}
}
Here the body content.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}
Here is the error I'm getting:
**{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "VERSION_MISMATCH",
"detail": "Object version does not match latest database version.",
"field": "version"
}
]
}**
I'm not sure what I'm doing wrong, but I appreciate any help I can get. Thank you in advance!
When updating a catalog object in Square, you need to provide the latest version number in the request.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"version": "12345",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}

Square API - The payment total does not match the order total. It does

First off, I created an order and doing an order search, the string below shows the order details from the response.
Next, I used the API Explorers for Payments->CreatePayment:
https://developer.squareup.com/reference/square/payments-api/create-payment/explorer
I put in my sandbox Access Token at the top.
As for the other info I entered, please refer to the Request String:
curl https://connect.squareup.com/v2/payments \
-X POST \
-H 'Content-Type: application/json' \
-H 'Square-Version: 2020-01-22' \
-H 'Authorization: Bearer {{access_token}}' \
-d '{
"source_id": "cnon:CBASEBbXLsTfPIy04J18kMjfbRo",
"idempotency_key": "5e42534d06257",
"location_id": "DWK1VQ391ZARF",
"order_id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"amount_money": {
"amount": 3649,
"currency": "USD"
}
}'
Here is the Order Details:
{
"id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"location_id": "DWK1VQ391ZARF",
"line_items": [
{
"uid": "iLVwmNInonSV2Twc9G84fD",
"catalog_object_id": "B57CGCIAGUTLBQMAMEEI5WBC",
"quantity": "1",
"name": "Athletic Heather Pullover Hooded Sweatshirt",
"variation_name": "X-Large",
"base_price_money": {
"amount": 2699,
"currency": "USD"
},
"taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 2699,
"currency": "USD"
},
"total_tax_money": {
"amount": 243,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 2942,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 2699,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"tax_uid": "f9euLpXOOEWKd2bV7AgOdD",
"applied_money": {
"amount": 243,
"currency": "USD"
}
}
]
},
{
"uid": "dQS0tXEW46ERhQlLdPAxgC",
"catalog_object_id": "PY7V64HVFKSE6O7SW6RBQZ7U",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Small Print",
"base_price_money": {
"amount": 300,
"currency": "USD"
},
"taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 300,
"currency": "USD"
},
"total_tax_money": {
"amount": 27,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 327,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 300,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"tax_uid": "RAD93NhnUa9E6XBy7NYWG",
"applied_money": {
"amount": 27,
"currency": "USD"
}
}
]
},
{
"uid": "mIae9M46tMvTCpzgNvyNW",
"catalog_object_id": "Q4OPKIJ2BMG5LY35SUMHFG7S",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Large",
"base_price_money": {
"amount": 0,
"currency": "USD"
},
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 0,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 0,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 0,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"tax_uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"applied_money": {
"amount": 0,
"currency": "USD"
}
}
]
},
{
"uid": "w3HK68X6MEpXHIxQDyTZ5",
"quantity": "1",
"name": "Shipping",
"base_price_money": {
"amount": 380,
"currency": "USD"
},
"gross_sales_money": {
"amount": 380,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 380,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 380,
"currency": "USD"
}
}
],
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"created_at": "2020-02-11T07:46:54.962Z",
"updated_at": "2020-02-11T07:46:54.962Z",
"state": "OPEN",
"version": 1,
"total_tax_money": {
"amount": 270,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 3649,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
},
"net_amounts": {
"total_money": {
"amount": 3649,
"currency": "USD"
},
"tax_money": {
"amount": 270,
"currency": "USD"
},
"discount_money": {
"amount": 0,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"source": {
"name": "Sandbox for sq0idp-0WcmbRcdTbsMGg5UjGvifQ"
}
}
Please note the order_id and location_id both match what's in the order details. What also matches is the amount entered in the create payment request and the total_money in the order details: 3649.
So then why do I get the following response for the Create Payment request?
cache-control: no-cache
content-length: 136
content-type: application/json
date: Tue, 11 Feb 2020 07:48:48 GMT
square-version: 2020-01-22
{
"errors": [
{
"code": "BAD_REQUEST",
"detail": "The payment total does not match the order total.",
"category": "INVALID_REQUEST_ERROR"
}
]
}
Using Square API v2.

How to make a payment with square from Dart code in flutter?

I need make payments with square, I used square_in_app_payments plugin but it only give me a nonce string that seems I have to send it to checkout api with items information inside JSON in http request, but I don't understand how to make it.
I only tried from postman make some samples fo square.
POST /v2/locations/{{location_id}}/checkouts HTTP/1.1
Host: connect.squareup.com
Authorization: Bearer {{access_token}}
Content-Type: application/json
cache-control: no-cache
Postman-Token: 5d2c05ae-11d6-42bd-bd1e-47fa44621a98
{
"idempotency_key": "60f919ba-2042-4402-bc66-e6455ec32349",
"order": {
"reference_id": "reference_id",
"line_items": [
{
"name": "Printed T Shirt",
"quantity": "2",
"base_price_money": {
"amount": 1500,
"currency": "USD"
},
"discounts": [
{
"name": "7% off previous season item",
"percentage": "7"
},
{
"name": "$3 off Customer Discount",
"amount_money": {
"amount": 300,
"currency": "USD"
}
}
]
},
{
"name": "Slim Jeans",
"quantity": "1",
"base_price_money": {
"amount": 2500,
"currency": "USD"
}
},
{
"name": "Woven Sweater",
"quantity": "3",
"base_price_money": {
"amount": 3500,
"currency": "USD"
},
"discounts": [
{
"name": "$11 off Customer Discount",
"amount_money": {
"amount": 1100,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Fair Trade Tax",
"percentage": "5"
}
]
}
],
"discounts": [
{
"name": "Father's day 12% OFF",
"percentage": "12"
},
{
"name": "Global Sales $55 OFF",
"amount_money": {
"amount": 5500,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Sales Tax",
"percentage": "8.5"
}
]
},
"ask_for_shipping_address": true,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "example#email.com",
"pre_populate_shipping_address": {
"address_line_1": "1455 Market St.",
"address_line_2": "Suite 600",
"locality": "San Francisco",
"administrative_district_level_1": "CA",
"postal_code": "94103",
"country": "US",
"first_name": "Jane",
"last_name": "Doe"
}
}
I need to know how to take the nonce string from card form of square_in_app_payments plugin and send it in http request for complete the payment.