Files
shop/utils/captureResponse.ts
T
libretech fccff147ba
build / test (push) Successful in 10s
build / build (push) Successful in 1m5s
v0.1.2: checkout fixes for CMS v0.2.0 (#18)
Co-authored-by: Michael Czechowski <mail@librete.ch>
2026-10-15 10:23:27 +02:00

13 lines
776 B
TypeScript

// The answer of POST /api/orders/:uuid/capture/:paypalOrderId: the paid order, or, when the order is already paid with this
// PayPal order (a repeated capture), { success: true, alreadyCaptured: true } (libreshop/cms src/api/order/controllers/order.ts).
// Pure: no Nuxt or Vue imports, tested in tests/unit/captureResponse.test.ts.
/** The CMS's answer to a repeated capture: the payment went through before, and the order is paid. */
export type AlreadyCaptured = { success: true; alreadyCaptured: true };
export const isAlreadyCaptured = (response: unknown): response is AlreadyCaptured =>
typeof response === "object" &&
response !== null &&
(response as Record<string, unknown>).success === true &&
(response as Record<string, unknown>).alreadyCaptured === true;