# Connect order lookup: BigCommerce and WooCommerce

One Lambda handler, two adapters, one flat string-map response for an Amazon Connect "Invoke AWS Lambda function" block (response validation: STRING_MAP).

Context: Node 24, no npm dependencies, global `fetch`. Companion to the post `/blog/amazon-connect-bigcommerce-woocommerce-integration-2026/`.

## Files
- `handler.mjs` - validates input, picks the adapter, enforces a time budget (`LOOKUP_BUDGET_MS`, default 5500 ms, under the flow block's 8 s maximum), never throws.
- `bigcommerce.mjs` - REST V2 orders + V3 customers (phone lookup).
- `woocommerce.mjs` - REST API v3 orders over HTTPS with basic auth.
- `sample-event.json` - Connect event shape (`Details.ContactData`, `Details.Parameters`).
- `lookup.test.mjs` - 6 tests, fetch mocked.

## Run
```
node --test
```

## Config (environment; use Secrets Manager in a real deployment)
`BC_STORE_HASH`, `BC_TOKEN` (scopes `store_v2_orders_read_only`, `store_v2_customers_read_only`), `WC_SITE_URL`, `WC_KEY`, `WC_SECRET` (read-only key), optional `PLATFORM`, optional `WC_PHONE_ENDPOINT=true` once the [phone-lookup plugin](../woocommerce-phone-lookup/README.md) is installed and backfilled (phone lookups then match normalised digits instead of the stored text).

## Response
`lookupStatus` is one of `found`, `not_found`, `ambiguous`, `timeout`, `throttled`, `auth`, `error`, `not_configured`, `bad_request`. When found: `orderId`, `orderStatus`, `orderTotalCents` (`"59.00"` becomes `"5900"`), `currency`, `placedOn` (`YYYY-MM-DD`), `itemCount`. Always: `platform`, `elapsedMs`. All values are strings limited to letters, digits, dash and underscore, the character set Connect documents for Lambda responses. One JSON log line per call carries the status, duration and HTTP code on failure, never the phone or email. No address, name or email is returned.

## Known limits
- WooCommerce `search` is a free-text match. The adapter confirms email or the last 10 phone digits client-side. A phone stored in a format that does not contain your search string will not match.
- Not tested against live BigCommerce or WooCommerce stores. Mocks only. No latency benchmark was run.
