@final-commerce/command-frame 0.9.0-online.5 → 0.9.0-online.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,5 @@
4
4
  */
5
5
  import { commandFrameClient } from '../../client';
6
6
  export const getCheckoutStatus = async (params) => {
7
- return await commandFrameClient.call('getCheckoutStatus', params);
7
+ return await commandFrameClient.call('getCheckoutStatus', params ?? {});
8
8
  };
@@ -3,9 +3,9 @@ export const mockGetCheckoutStatus = async (params) => {
3
3
  console.log('[Mock] getCheckoutStatus called', params);
4
4
  return {
5
5
  success: true,
6
- status: params?.orderPassword ? 'paid' : null,
7
- paid: Boolean(params?.orderPassword),
8
- receiptId: params?.orderPassword ? 'ON-001-000001' : null,
6
+ status: 'paid',
7
+ paid: true,
8
+ receiptId: params?.receiptId ?? 'ON-001-000001',
9
9
  timestamp: new Date().toISOString(),
10
10
  };
11
11
  };
@@ -1,17 +1,15 @@
1
1
  /** The shopper-facing vocabulary: never the platform's payment / fulfilment states. */
2
2
  export type CheckoutOrderStatus = 'awaiting_payment' | 'confirming' | 'payment_failed' | 'paid' | 'fulfilled' | 'partially_refunded' | 'refunded' | 'cancelled';
3
3
  export interface GetCheckoutStatusParams {
4
- /** The order password from `startCheckout` or `resumeCheckout`. */
5
- orderPassword: string;
6
4
  /**
7
- * The provider's opaque `sessionResult` from the payment-completed event, when the page has it.
8
- * Lets the server verify the payment with the provider while the notification is still on its way.
5
+ * The receipt `startCheckout` returned, to name which order. Omitted: the checkout in flight,
6
+ * else the last one this tab finished.
9
7
  */
10
- sessionResult?: string;
8
+ receiptId?: string;
11
9
  }
12
10
  export interface GetCheckoutStatusResponse {
13
11
  success: boolean;
14
- /** `null` when the order is unknown or the password has expired. */
12
+ /** `null` when this tab placed no such order, or the server could not be asked. */
15
13
  status: CheckoutOrderStatus | null;
16
14
  /** True once the money is in: `paid`, `fulfilled`, or refunded since. */
17
15
  paid: boolean;
@@ -19,4 +17,4 @@ export interface GetCheckoutStatusResponse {
19
17
  timestamp: string;
20
18
  }
21
19
  /** Never throws for an unknown order: answers `status: null`. */
22
- export type GetCheckoutStatus = (params: GetCheckoutStatusParams) => Promise<GetCheckoutStatusResponse>;
20
+ export type GetCheckoutStatus = (params?: GetCheckoutStatusParams) => Promise<GetCheckoutStatusResponse>;
@@ -5,8 +5,8 @@
5
5
  // landed, which the browser alone can never know: it only ever sees that the provider ACCEPTED
6
6
  // a payment.
7
7
  //
8
- // Keyed by the one-time order password `startCheckout` (or `resumeCheckout`, after a redirect)
9
- // returned, so a page can only ever ask about an order it created.
8
+ // The runtime asks about a checkout THIS TAB placed (it keeps the checkout's key), so a page can
9
+ // only ever ask about its own order. No password: the server no longer issues one.
10
10
  //
11
11
  // Served ONLY by the storefront runtime (a published website). On a register it does not exist.
12
12
  export {};
@@ -13,18 +13,23 @@ export const mockGetProductModifierSelections = async (params) => {
13
13
  selections: [],
14
14
  rows: [],
15
15
  modifiersTotal: 0,
16
+ lineTotal: 0,
17
+ unitTotal: 0,
16
18
  timestamp: new Date().toISOString(),
17
19
  };
18
20
  }
19
21
  // The priced rows already sit on the line; extending them by the line quantity is
20
22
  // the host's job, not the flow's.
21
23
  const { rows, modifiersTotal } = buildModifierRows(line.modifiers, line.quantity);
24
+ const { modifiersTotal: unitModifiers } = buildModifierRows(line.modifiers, 1);
22
25
  return {
23
26
  success: true,
24
27
  internalId: line.internalId,
25
28
  selections: line.modifierSelections ?? [],
26
29
  rows,
27
30
  modifiersTotal,
31
+ lineTotal: line.price * line.quantity + modifiersTotal,
32
+ unitTotal: line.price + unitModifiers,
28
33
  timestamp: new Date().toISOString(),
29
34
  };
30
35
  };
@@ -18,6 +18,10 @@ export interface GetProductModifierSelectionsResponse {
18
18
  rows: CFProdModifierBreakdown[];
19
19
  /** Sum of `rows[].amount` for THIS line, in minor units. */
20
20
  modifiersTotal: number;
21
+ /** The whole line as the cart prices it (item, its discounts, fees and modifiers), in minor units. */
22
+ lineTotal: number;
23
+ /** The same for ONE unit, for an "each" price. */
24
+ unitTotal: number;
21
25
  timestamp: string;
22
26
  }
23
27
  export type GetProductModifierSelections = (params?: GetProductModifierSelectionsParams) => Promise<GetProductModifierSelectionsResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.9.0-online.5",
3
+ "version": "0.9.0-online.6",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",