Apps on the point of sale
Put your embedded app on the Tanqory point of sale as a home screen tile, a menu item or a button after the sale, read and change the cart through App Bridge, and test it on a development store.
The point of sale (POS) runs in the Tanqory apps for iPhone, iPad and Android. Your embedded app can show there too. You do not build a second app: you name the places in POS where staff open it, and each place opens a page of your embedded app, full screen, inside the Tanqory app. Your page is the whole interface. Tanqory draws only the frame around it, with your app's title and a close button.
On POS your page uses the same App Bridge as in the store dashboard (Embedded apps and App Bridge), plus a few requests that read and change the sale being made. Charging the customer always stays with POS.
Places in POS
An app can show once in each place, so at most six times in all.
Place (target) | Where staff find it | What your page is told when it opens |
|---|---|---|
pos.home.tile | A tile in the Apps group of the POS home screen | the location |
pos.cart.action | An item in the cart's More menu | the location (read the cart through App Bridge) |
pos.line-item.action | An item on a cart line's detail sheet | the location and line_item, the cart line |
pos.customer.action | An item on a customer's page in POS | the location and customer |
pos.order.action | An item on an order in POS Orders | the location and order |
pos.sale-complete.block | A button under the receipt choices once a sale is done | the location and order, the sale just made |
Declare the places
Each place is a POS extension of your app:
| Field | Rule |
|---|---|
handle | 1 to 64 lower-case letters, digits or hyphens, unique in the app. Merchants' show and hide choices are kept by it, so keep it when you change the rest. |
target | One of the six places above. |
title | What staff see on the tile or menu item: 1 to 40 characters of plain text on one line. |
description | Optional, at most 120 characters, shown under the title. |
path | The page of your app to open, starting with / (at most 512 characters). It stays inside your app URL: no // at the start, no \, no scheme, no . or .. segment. |
Only an embedded app can have POS extensions, because each place opens your page inside Tanqory.
Declare them in one of three ways. Each one sends the whole list: an empty list removes them all.
Partner dashboard. Open your app, then Extensions, card Point of sale. Add a place, choose where it shows, give it a title and a path, then save it.
Partner CLI. Add
posExtensionstotanqory.extensions.jsonnext to your app's code, check it, then send it:JSON{ "app": "<your app id>", "posExtensions": [ { "handle": "points", "target": "pos.home.tile", "title": "Points", "description": "Look up and spend points", "path": "/pos/points" }, { "handle": "redeem", "target": "pos.cart.action", "title": "Redeem points", "path": "/pos/redeem" } ] }Shelltanqory-partner app extensions check tanqory-partner app extensions pushThe CLI checks the same rules as the platform before it sends anything, and names every problem.
Partner API.
partnerAppUpdate(id, input: { posExtensions: [...] }). LeavingposExtensionsout keeps the list as it is.
Saving records a new app version. For a published app the version goes to app review first, like a change of scopes, and stores keep the released version until you release the approved one. The Versions page shows each place added, removed or changed against the live version.
What the merchant sees
The install page lists the places under Shows on the point of sale, with each title, next to the scopes your app asks for. Once installed, every place shows on every location and device of the store. The merchant can hide any one of them in Settings > Apps > your app, card Point of sale; the choice is kept by the extension's handle. Uninstalling removes the choices, so installing again shows everything.
Staff who can use POS can open your app from POS, even when they cannot manage apps. Your app's access is still limited by its scopes on every request.
When your page opens
The address of your page gets the usual launch parameters (store, host, locale, embedded=1, id_token) and these POS ones. The host sets them; a query string in your path cannot replace them.
| Parameter | Value |
|---|---|
surface | pos |
pos_target | the place it was opened from, such as pos.cart.action |
pos_extension | your extension's handle |
location | the location the POS is selling at: gid://tanqory/Location/<id> |
customer | on pos.customer.action only: gid://tanqory/Customer/<id> |
order | on pos.order.action and pos.sale-complete.block: gid://tanqory/Order/<id> |
line_item | on pos.line-item.action only: the cart line's id, which is local to the device |
The session token is the one described in Embedded apps and App Bridge, with two more claims: surface is pos and location_id is the location's gid. It never carries the staff member's name or email.
Your page has a phone-size screen: design it for 375 px wide first. Close it with app.close when the job is done, so staff are back where they were.
Read and change the cart
The cart on POS is the sale being made on the device. Your page can read it, add to it, discount it and set its customer. Every change shows to staff at once, and nothing is charged: staff take the payment in POS as usual. Tell staff on your page what each button will change before they press it.
const info = await bridge('ready', { clientVersion: 'my-pos-app-1.0' });
const can = (type) => info.features.includes(type);
if (can('pos.cart.get')) {
const cart = await bridge('pos.cart.get');
showTotal(cart.total, cart.currencyCode);
}
if (can('pos.cart.addCustomSale')) {
await bridge('pos.cart.addCustomSale', { title: 'Gift wrap', price: '25', quantity: 1, taxable: true });
}
await bridge('app.close');ready lists in features exactly the POS requests your app may make now, worked out from the scopes the store granted it. Show a button only when its request is in the list.
Cart changes from apps can be switched off on Tanqory while partner apps on the point of sale are introduced. While they are off, the change requests are left out of features, pos.cart.get still works, and a change request is answered UNSUPPORTED with the message "Apps may not change the point of sale cart on Tanqory for now."
Custom sales can be off on their own. Then only pos.cart.addCustomSale is left out of features, and it is answered UNSUPPORTED with the message "This store has turned custom sales off at the point of sale."
App Bridge reference: pos.*
These requests exist only on POS. Payloads are checked by the host: a payload that does not match answers INVALID_MESSAGE.
| Request | Payload | Answer | Needs |
|---|---|---|---|
pos.cart.get | {} | the cart | read_orders |
pos.cart.addLineItem | { variantId, quantity }: a gid://tanqory/ProductVariant/<id> and 1 to 999 | the cart after | write_orders, cart changes on |
pos.cart.addCustomSale | { title, price, quantity, taxable, note? }: title 1 to 255 characters, price per unit in the store's currency, quantity 1 to 999, an optional note of at most 500 characters kept on the order line | the cart after | write_orders, cart changes on, custom sales on |
pos.cart.applyDiscount | { kind, value, description }: kind is percentage or fixed, value above 0 (at most 100 for a percentage), description 1 to 255 characters | the cart after | write_orders, cart changes on, and the staff member may give discounts |
pos.cart.setCustomer | { customerId }: a gid://tanqory/Customer/<id>, or null to take the customer off | the cart after | read_customers and write_orders, cart changes on |
pos.cart.removeLineItem | { lineId }: a line's id from the cart | the cart after | write_orders, cart changes on |
app.close | {} | {}, then the page closes and POS returns to where it was | nothing |
| Event (the host to your page) | Payload | When |
|---|---|---|
pos.cart.changed | the cart | The cart changed while your page is open. Sent only when pos.cart.get is in features. |
The cart, in every answer and in the event:
{
"currencyCode": "USD",
"lines": [
{ "id": "l1", "variantId": "gid://tanqory/ProductVariant/0190a1b2-0000-7000-8000-000000000001", "title": "Linen shirt", "quantity": 2, "price": "35.00", "total": "70.00" },
{ "id": "l2", "title": "Gift wrap", "quantity": 1, "price": "25", "total": "25" }
],
"subtotal": "95.00",
"discounts": [{ "description": "Points", "amount": "5.00" }],
"total": "90.00",
"customerId": "gid://tanqory/Customer/0190a1b2-0000-7000-8000-000000000002"
}- Every amount, and the
priceandvalueyou send, is a decimal string: digits, then at most four decimals after a point, no sign and no exponent, such as"25"or"12.5". variantIdis missing on a custom sale.customerIdis missing when the cart has no customer, or when your app does not haveread_customers.- A cart holds at most 500 lines and 50 discounts.
Refusals, with the true reason in the message:
| Code | When |
|---|---|
NOT_PERMITTED | Your app lacks a scope the request needs ("The app needs the access scope write_orders for pos.cart.addCustomSale."), or the staff member may not give the discount. |
UNSUPPORTED | Cart changes from apps are switched off, or the request makes no sense on POS, such as redirect.admin. |
INVALID_MESSAGE | The payload does not match the table above. |
The other App Bridge requests work on POS as in the dashboard, among them sessionToken.get, toast.show, modal.open, loading.set, titleBar.set, context.get (which also answers locationId and deviceName on POS), resourcePicker.open, scanner.capture, files.pick and print.open. redirect.remote opens the device's browser.
No request takes a payment, gives a refund, opens the cash drawer or uses the card reader or receipt printer. Those stay with POS.
Offline
POS keeps selling without a connection; your page lives on your server and needs one. POS remembers your app's places, so they keep their spots. Offline they are greyed out, and a tap says that your app needs an internet connection and the sale is not affected. Nothing is queued. If the connection drops while your page is open, the page stays; your own requests fail as your code handles them, while the cart requests keep working because the cart is on the device.
Test on a development store
- Create a development store in the partner dashboard. Development stores can use POS and POS apps like any store.
- Declare your places as above. A development app needs no review on its own development store.
- Install the app from its install link:
/admin/store/<store id>/oauth/install?client_id=<your API key>on the store dashboard. - Sign in to the Tanqory app on a phone or tablet with a staff account of the development store and open POS. Your tile and menu items show in their places.
- While you build, your page can run on your own machine. An
httploopback address works in the iPhone simulator and the Android emulator only.
Before you submit for review, open your page from every place you declared, on a phone-size screen, and check that closing returns staff to where they were. Review checks the same things, and that your app never tries to take a payment.