The official SDK @beyondplusmm/doehpos-sdk gives you a typed client for the DOEH POS
API — the same contract as the raw HTTP API, with typed requests, typed responses, and typed errors
you catch instead of string-matching. It runs in Node and React Native / Expo.
တရားဝင် SDK @beyondplusmm/doehpos-sdk သည် DOEH POS API အတွက် typed client ကို ပေးသည် —
raw HTTP API နှင့် contract တူ၊ typed request၊ typed response နှင့် string ကိုက်ညှိမည့်အစား သင် catch လုပ်နိုင်သော
typed error များ ပါသည်။ ၎င်းသည် Node နှင့် React Native / Expo တွင် အလုပ်လုပ်သည်။
sk_live_… key and environment: "production". See the
Orders reference and the Sandbox guide.sk_live_… key နှင့် environment: "production"
သို့ ပြောင်း၍ ကူးပြောင်းပါ။ Orders အကိုးအကား နှင့် Sandbox guide ကို ကြည့်ပါ။npm install @beyondplusmm/doehpos-sdk
Authenticate with a sandbox sk_test_… key — the key is the shop, so there is no
shop id to pass — then submit a basket of { sku, qty }. Pricing, tax and totals are resolved
server-side:
sandbox sk_test_… key ဖြင့် authenticate လုပ်ပါ — key သည် ဆိုင်ပင် ဖြစ်သဖြင့် shop id ပို့စရာ မလို —
ထို့နောက် { sku, qty } basket တစ်ခု တင်ပါ။ စျေးနှုန်း၊ အခွန်နှင့် စုစုပေါင်းကို server ဘက်တွင် တွက်ချက်သည် —
/**
* DOEH POS SDK — Quickstart: place your first order in three steps.
*
* 1. Install: npm install @beyondplusmm/doehpos-sdk
* 2. Authenticate with a sandbox key (the key IS the shop — no shopId anywhere).
* 3. Submit a basket of { sku, qty } and get back a fully resolved order.
*
* Run against the sandbox:
* export DOEH_API_KEY=sk_test_...
* npx tsx examples/quickstart/orders.ts
*
* Orders (sales submission) is @experimental and not yet live in production —
* build against the sandbox today; cut over later by swapping the key (sk_live_)
* and the environment. You send only { sku, qty }; the server resolves pricing,
* tax, discounts and inventory and is the source of truth for the order. Money is
* always an integer in minor units.
*
* This file is the canonical, CI-type-checked quickstart and the single source
* the developer portal's SDK page renders — keep it runnable and minimal.
*/
import { DoehClient, EmptyOrderError, UnknownSkuError } from "@beyondplusmm/doehpos-sdk";
// 1 + 2 · install, then authenticate. A test key only works against the sandbox.
const client = new DoehClient({
apiKey: process.env.DOEH_API_KEY!, // sk_test_...
environment: "sandbox", // -> "production" + a sk_live_ key to cut over
});
// 3 · submit a basket — prices, taxes and totals are computed server-side.
try {
const { order } = await client.orders.submit({
lines: [
{ sku: "BURGER001", qty: 2 },
{ sku: "COLA001", qty: 1 },
],
});
// A fully resolved order: server-priced totals in minor units.
console.log("order:", order.id, order.status);
console.log("total:", order.totals.grand_total_minor, order.totals.currency);
} catch (err) {
// Catch typed errors — never parse `code` strings off the wire.
if (err instanceof EmptyOrderError) {
console.error("submission had no line items");
} else if (err instanceof UnknownSkuError) {
console.error("a line referenced a sku this shop does not sell");
} else {
throw err;
}
}A fully resolved order: server-priced line items and totals in minor units, plus the
order id and status. Business failures arrive as typed errors you catch
(EmptyOrderError, UnknownSkuError) — never string-matched codes. See the
error reference.
ဖြေရှင်းပြီးသား order အပြည့်အစုံ — server တွက်ထားသော line item များနှင့် စုစုပေါင်းကို minor unit ဖြင့်၊
order id နှင့် status ပါ။ business ချို့ယွင်းချက်များသည် သင် catch လုပ်နိုင်သော typed error
(EmptyOrderError၊ UnknownSkuError) အဖြစ် ရောက်လာသည် — string ကိုက်ညှိသော code မဟုတ်ပါ။
error အကိုးအကား ကို ကြည့်ပါ။
The consumer sibling @beyondplusmm/doeh-consumer-sdk is a different plane:
it powers a shop's own customer-facing app, not a merchant integration. Two credentials — the
publishable pk_test_… key baked into the app (safe to ship; the shop is derived from it
server-side) plus the signed-in customer's bearer token per request. Same transport discipline: typed
errors, bounded retries, and redeem is never blind-retried. See the
Consumer Mobile API reference.
Consumer SDK @beyondplusmm/doeh-consumer-sdk သည် သီးခြား plane ဖြစ်သည် —
merchant integration မဟုတ်ဘဲ ဆိုင်၏ ကိုယ်ပိုင် customer-facing app အတွက် ဖြစ်သည်။ credential နှစ်ခု —
app ထဲ ထည့်ထားသော publishable pk_test_… key (ship လုပ်ရန် စိတ်ချရသည်။ ဆိုင်ကို server ဘက်တွင်
key မှ တွက်ယူသည်) နှင့် sign in ဝင်ထားသော customer ၏ bearer token။ transport စည်းကမ်း တူသည် — typed error များ၊
ကန့်သတ် retry များ၊ redeem ကို မျက်စိမှိတ် retry ဘယ်တော့မှ မလုပ်ပါ။
Consumer Mobile API အကိုးအကား ကို ကြည့်ပါ။
npm install @beyondplusmm/doeh-consumer-sdk
/**
* DOEH Consumer SDK — Quickstart: read a customer's loyalty state and redeem.
*
* 1. Install: npm install @beyondplusmm/doeh-consumer-sdk
* 2. Authenticate with TWO credentials: the shop's PUBLISHABLE key (baked into
* the app build — it grants nothing by itself, and the shop is derived from
* it server-side; there is no shopId anywhere) plus the logged-in customer's
* bearer token, supplied per request from your session store.
* 3. Read settings / balance / transactions, then spend points with redeem.
*
* Run against the sandbox:
* export DOEH_PUBLISHABLE_KEY=pk_test_...
* export DOEH_CUSTOMER_TOKEN=... # a signed-in customer's bearer
* npx tsx examples/quickstart/consumer.ts
*
* This is the CONSUMER plane (a shop's own customer-facing app) — the sibling of
* the merchant SDK, not a replacement for it. The production consumer plane is
* not yet enabled: build against the sandbox today and cut over later by
* swapping to a pk_live_ key and environment: "production".
*
* This file is the canonical, CI-type-checked consumer quickstart the developer
* portal renders — keep it runnable and minimal.
*/
import {
DoehConsumerClient,
CustomerTokenInvalidError,
DoehTransportError,
} from "@beyondplusmm/doeh-consumer-sdk";
// 1 + 2 · one client, two credentials. The publishable key pins the shop; the
// customer token names the end user and is fetched fresh on every request.
const client = new DoehConsumerClient({
publishableKey: process.env.DOEH_PUBLISHABLE_KEY!, // pk_test_...
getCustomerToken: async () => process.env.DOEH_CUSTOMER_TOKEN ?? null, // your session store
environment: "sandbox", // -> "production" + a pk_live_ key to cut over
userAgent: "DoehConsumerQuickstart/1.0", // identify your app in server logs
});
try {
// 3a · reads — all scoped to the key's shop and the token's customer.
const settings = await client.loyalty.settings();
console.log("program:", settings);
const balance = await client.loyalty.balance();
console.log("balance:", balance.points_balance, "· lifetime:", balance.lifetime_points);
const { transactions } = await client.loyalty.transactions({ limit: 5 });
console.log("recent ledger entries:", transactions.length);
// 3b · the consumer write. redeem carries NO idempotency promise yet: the SDK
// never retries it once it may have been sent — on a transport error,
// re-check the balance before trying again.
const coupon = await client.loyalty.redeem({ points: 10 });
console.log("redeemed:", coupon);
} catch (err) {
if (err instanceof CustomerTokenInvalidError) {
// The bearer was present but expired/invalid — send the customer to sign in.
console.error("customer session expired — re-authenticate");
} else if (err instanceof DoehTransportError) {
// Ambiguous for redeem (it may or may not have landed): re-read the
// balance to learn what happened before retrying.
console.error("network trouble:", err.message);
} else {
throw err;
}
}Source: examples/quickstart/orders.ts · consumer.ts @ 22f3cf122166 — CI-type-checked against the published SDKs; this page renders them verbatim.