How to Integrate POS with E-commerce for Omnichannel: A 2025 Technical Guide
N
Back to Blog

How to Integrate POS with E-commerce for Omnichannel: A 2025 Technical Guide

Tutorial
Nugroho Setiawan · Konsultan IT & Full Stack Developer 21 Oct 2026 6 min baca 1,243 kata 3 views
A technical guide to building POS integration with marketplaces and online stores: webhook architecture, message queues, stock reconciliation, plus ready-to-use Node.js code examples.

Many clinic, pharmacy, and operations managers in Yogyakarta and Magelang still run POS cashier and online stores as two separate systems. As a result, stock on Shopee or Tokopedia never matches the stock on warehouse shelves, marketplace orders are processed manually via WhatsApp, and sales reports must be recapped from two different dashboards. At one pharmaceutical retail client in Magelang, the monthly stock discrepancy reached 7.4% or equivalent to IDR 23 million in lost revenue due to overselling and unilaterally canceled orders. Integrating POS with e-commerce is not just connecting two applications, but building a single source of truth for stock, prices, and orders. This article discusses the technical steps to build a reliable omnichannel integration, from architecture design, webhook implementation, to data conflict reconciliation.

Mapping the Data Flow: POS as Stock Master

The first decision that determines the success of integration is determining who becomes the master data. For retail and pharmacy, the physical POS must be the stock master because the cashier is the point that most quickly knows the movement of real goods. Marketplaces such as Shopee, Tokopedia, TikTok Shop, and online stores based on WooCommerce 9.x are treated as sales channels, not data sources. The principle is simple: every transaction at the POS triggers an inventory.updated event containing SKU, quantity delta, and timestamp. This event is sent to a message broker to be processed asynchronously.

Use a message queue such as RabbitMQ 3.13 or Redis Streams on Redis 7.2. The presence of a queue is very important because marketplace APIs often experience downtime or rate limits. If you call the Shopee API directly from a POS transaction, one timeout can cancel the cashier transaction. With a queue, stock events enter the buffer first, workers process them with retry and exponential backoff (starting at 2 seconds, doubling each attempt, maximum 5 minutes).

For products, create an explicit mapping table between sku_internal in POS and product_id/variation_id in each marketplace. Marketplaces always have their own IDs, and one internal SKU can map to multiple listings. This mapping table also stores synchronization status (synced, pending, error) so you can audit when the stock was last updated.

Implementing Order Webhooks with Idempotency

The second side of integration is receiving orders from marketplaces. Almost all marketplaces (Shopee Open Platform v2, Tokopedia Partner API, WooCommerce REST API v3) support webhooks. However, webhooks can be sent repeatedly, i.e., duplicates. Therefore, every handler must be idempotent: use the marketplace order_id as a unique key and store it in the orders_pos table with a UNIQUE constraint. If the order_id already exists, simply return HTTP 200 without deducting stock again.

// webhook.js — Node 20 + Express 4.19
import express from 'express';
import crypto from 'node:crypto';
const app = express();
app.use(express.json());

app.post('/webhook/shopee/order', async (req, res) => {
  const sig = crypto.createHmac('sha256', process.env.SHOPEE_SECRET)
    .update(JSON.stringify(req.body)).digest('hex');
  if (sig !== req.headers['x-shopee-signature']) return res.status(401).end();
  const { order_id, items } = req.body;
  await db.tx(async t => {
    await t.none(`INSERT INTO orders_pos(order_id,source,status)
      VALUES($1,'shopee','paid') ON CONFLICT DO NOTHING`, [order_id]);
    for (const it of items) {
      await t.none(`UPDATE stok SET qty=qty-$1 WHERE sku=$2`, [it.qty, it.sku]);
    }
  });
  res.json({ ok: true });
});
app.listen(3000);

Note three things in the code above: HMAC-SHA256 signature verification to ensure the request is truly from Shopee, the db.tx block so that stock deduction and order recording are atomic, and ON CONFLICT DO NOTHING to handle duplicate webhooks. For high-load simulation, run a load test with k6 v0.50 at 500 requests/second before go-live.

After the order is recorded, create a shipping label and send the tracking number back to the marketplace via the /logistics/ship_order endpoint. This automation cuts processing time from an average of 8 minutes per order to under 30 seconds, as we implemented at one retail client in Yogyakarta.

Stock Reconciliation and Conflict Handling

Conflicts will still occur: stock on the marketplace becomes negative due to overselling, or stock at the POS changes while a marketplace order is being processed. The standard solution is a stock reservation mechanism. When an order comes in, instead of directly deducting stock, create a reservation for 15 minutes (for payment) or 3x24 hours (for COD). If payment succeeds, the reservation is converted to a permanent deduction; if it fails, the stock is automatically returned. Reservation prevents one unit of goods from being sold twice in different channels.

Perform full reconciliation twice a day using a cron job (for example, run via node-cron 3.0.3 at 02:00 and 14:00 WIB). The cron will pull the stock list from each marketplace API, compare it with POS stock, and then write the difference to the reconciliation_log table. Differences above a certain threshold (e.g., 3 units) trigger a Telegram notification to the operations team. This practice reduced stock accuracy from 92% to 99.6% within two months.

For monitoring, install a lag indicator: if the oldest event in the queue is older than 5 minutes, send an alert. Use Grafana 11.x that reads Prometheus metrics. This way you know there is an integration problem before customers complain.

Best Practices

  1. Set POS as the stock master and treat marketplaces only as sales channels—never do full two-way sync without reservations.
  2. Always use a message queue (RabbitMQ 3.13 or Redis Streams 7.2) so cashier transactions are not blocked by marketplace API downtime.
  3. Require HMAC signature verification on every webhook and store the event id to ensure idempotency.
  4. Schedule automatic reconciliation at least twice a day and set up alerts for discrepancies above the threshold.
  5. Do load testing with k6 before go-live, targeting at least 3x your daily peak traffic.

FAQ

Does POS and e-commerce integration have to be real-time?

Not always. Stock synchronization should ideally be near real-time (under 60 seconds) because it prevents overselling, but price, description, and image synchronization is enough once a day. Prioritize bandwidth and effort on stock and orders.

Which marketplace is easiest to integrate?

For MSME scale, WooCommerce REST API v3 and Shopee Open Platform v2 are the best documented. TikTok Shop API is relatively new and its rate limit is stricter, so prepare a more aggressive retry strategy.

How much does it cost to build this integration?

For one marketplace and one POS with webhook features, stock reservation, and reconciliation, development needs generally take 4-6 weeks. If your POS does not have an open API, add 1-2 weeks to build a middleware adapter.

Can integration be done without changing a POS that is already running?

Yes, as long as the POS provides database access or REST endpoints. The safest approach is to insert an integrator middleware that reads events from the POS and forwards them to the marketplace, without touching the POS core logic.

POS and e-commerce integration is not a one-time project, but a system that needs continuous monitoring, reconciliation, and optimization. Start with one channel, measure stock lag and accuracy, then expand to the next channel. If you run a clinic, pharmacy, retail, or restaurant in the Yogyakarta, DIY, and Magelang areas, our team provides IT consulting services and development of SIMRS, SIM Klinik, ERP, POS, and website applications that are ready to connect to your omnichannel ecosystem. Contact Nugroho Setiawan for an initial consultation session and an audit of the integration architecture you are currently running.

This article is part of the knowledge base of Nugroho Setiawan, an IT consultant in Jogja (Yogyakarta). Related solutions: PilarPOS SIMRS (Hospital Information System) Clinic Management System. Need a free consultation?

Terakhir diperbarui 21 Oct 2026

Komentar

Komentar ditinjau sebelum tampil.

Belum ada komentar. Jadilah yang pertama!

Butuh bantuan implementasi?

Saya membantu konsultasi IT & pengembangan aplikasi untuk rumah sakit, klinik, dan bisnis di Yogyakarta (DIY), Magelang, dan sekitarnya.

Produk & Solusi SIMRS ERP Portfolio Konsultasi Gratis