You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(pos-app): unify merchant API base URL, keep separate auth
Consolidate to single base URL (EXPO_PUBLIC_API_URL) for both Payment and
Merchant APIs, removing EXPO_PUBLIC_MERCHANT_API_URL. Delete redundant
merchant-client.ts and reuse apiClient. Extract getApiHeaders() to shared
client module for payment endpoints.
Merchant endpoints retain separate auth via EXPO_PUBLIC_MERCHANT_PORTAL_API_KEY
since the Merchants API has its own auth layer. Added TODOs for when APIs
unify auth. Fix incomplete test mock after module export migration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: dapps/pos-app/AGENTS.md
+16-23Lines changed: 16 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ Uses **Expo Router** with file-based routing:
129
129
- Filter tabs: All, Failed, Pending, Completed
130
130
- Transaction detail modal on tap
131
131
- Empty state when no transactions
132
-
- Uses Merchant Portal API for data fetching
132
+
- Uses unified API for data fetching
133
133
134
134
### 2. Receipt Printing
135
135
@@ -174,9 +174,10 @@ Uses **Expo Router** with file-based routing:
174
174
175
175
## Payment API Integration
176
176
177
-
### Payment API Client (`services/client.ts`)
177
+
### API Client (`services/client.ts`)
178
178
179
179
- Base URL from `EXPO_PUBLIC_API_URL` environment variable
180
+
- Shared `getApiHeaders()` helper for authenticated requests
180
181
- Request/response interceptors
181
182
- Error handling
182
183
@@ -204,33 +205,24 @@ All Payment API requests include:
204
205
-`Sdk-Version`: "1.0.0"
205
206
-`Sdk-Platform`: "react-native"
206
207
207
-
## Merchant Portal API Integration
208
-
209
-
The Merchant Portal API is a separate backend used for fetching transaction history (Activity screen).
210
-
211
-
### Merchant API Client (`services/merchant-client.ts`)
212
-
213
-
- Base URL from `EXPO_PUBLIC_MERCHANT_API_URL` environment variable
214
-
- Generic HTTP client (no credentials baked in)
215
-
- API key passed per-request via headers
216
-
- Used by native apps (iOS/Android) for direct API calls
217
-
218
-
### Server-Side Proxy (`api/transactions.ts`)
219
-
220
-
- Vercel serverless function that proxies requests to the Merchant Portal API (web only)
221
-
- API key read from server-side env (`EXPO_PUBLIC_MERCHANT_PORTAL_API_KEY`)
222
-
- Client only sends `x-merchant-id` header
223
-
- Avoids CORS issues by making requests server-side
224
-
225
208
### Transactions Service (`services/transactions.ts`)
226
209
210
+
> **Note:** The Merchants API currently has its own auth layer separate from the Payment API. Both share the same base URL (`EXPO_PUBLIC_API_URL`), but merchant endpoints authenticate via `EXPO_PUBLIC_MERCHANT_PORTAL_API_KEY` (sent as `x-api-key` header) rather than the partner API key used by payment endpoints. This will be unified in the future.
Fix any errors found. Pre-existing TypeScript errors in unrelated files can be ignored.
719
710
711
+
**When moving exports between modules**, update any `jest.mock()` calls in tests that mock the source or destination module. Mocks that use a manual factory (e.g., `jest.mock("@/services/client", () => ({ ... }))`) replace the entire module — any export not included in the factory becomes `undefined` at runtime, which silently breaks tests.
0 commit comments