[commerce] stub endpoint

This commit is contained in:
Devin Zuczek
2026-08-26 10:28:48 -04:00
parent 4ca0e42cef
commit b848e34b71
2 changed files with 30 additions and 0 deletions
+20
View File
@@ -114,6 +114,26 @@ const app = new Hono<App>()
(c) => c.json(catalog) (c) => c.json(catalog)
) )
// Pending purchases the client asks the server to reconcile — platform transactions
// it started but never saw finish. Nothing is ever recorded here, so there is never
// anything pending and the answer is always an empty list. Accepts GET or POST since
// the client may use either.
.on(
['GET', 'POST'],
'/purchase/v1/cleanuppending',
describeRoute({
tags: ['Purchase'],
summary: 'Reconcile pending purchases (no-op)',
description: [
'Always `[]` — no purchase is ever recorded, so nothing can be left pending. A 404',
'here makes the client treat the call as an error, so the empty list is served',
'instead. Accepts GET or POST.',
].join(' '),
responses: { 200: json(JsonArray, 'Always empty (nothing pending)') },
}),
(c) => c.json([])
)
// Current purchase campaigns (limited-time offers/promos). None exist, and // Current purchase campaigns (limited-time offers/promos). None exist, and
// an empty list is the client's "no active campaigns" state. // an empty list is the client's "no active campaigns" state.
.get( .get(
@@ -43,6 +43,14 @@ describe('commerce endpoints', () => {
expect(skus[0]).toHaveProperty('skuId') expect(skus[0]).toHaveProperty('skuId')
}) })
it('GET|POST /purchase/v1/cleanuppending returns []', async () => {
for (const method of ['GET', 'POST']) {
const res = await SELF.fetch(`${ORIGIN}/purchase/v1/cleanuppending`, { method })
expect(res.status).toBe(200)
expect(await res.json()).toEqual([])
}
})
it('GET /purchasecampaign/allcurrent/v2 returns []', async () => { it('GET /purchasecampaign/allcurrent/v2 returns []', async () => {
const res = await SELF.fetch(`${ORIGIN}/purchasecampaign/allcurrent/v2`) const res = await SELF.fetch(`${ORIGIN}/purchasecampaign/allcurrent/v2`)
expect(res.status).toBe(200) expect(res.status).toBe(200)
@@ -78,9 +86,11 @@ describe('commerce endpoints', () => {
expect([...documented].sort()).toEqual([ expect([...documented].sort()).toEqual([
'GET /', 'GET /',
'GET /api/catalog/v1/all', 'GET /api/catalog/v1/all',
'GET /purchase/v1/cleanuppending',
'GET /purchase/v1/hasspentmoney', 'GET /purchase/v1/hasspentmoney',
'GET /purchasecampaign/allcurrent/v2', 'GET /purchasecampaign/allcurrent/v2',
'GET /reminder/currentTokenBundles/v2', 'GET /reminder/currentTokenBundles/v2',
'POST /purchase/v1/cleanuppending',
'POST /purchase/v1/initiatepurchase', 'POST /purchase/v1/initiatepurchase',
]) ])