@final-commerce/command-frame 0.1.57 → 0.1.58

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.
package/README.md CHANGED
@@ -75,7 +75,7 @@ const context = await client.getContext();
75
75
  The pub/sub system allows iframe extensions to subscribe to topics and receive real-time events published by the host (Render). Subscriptions are **page-scoped** -- they fire only while the iframe is mounted on the current page.
76
76
 
77
77
  - **[Pub/Sub Documentation](./src/pubsub/README.md)**
78
- - **Topics:** Cart (8), Customers (8), Orders (4), Payments (2), Products (4), Refunds (4), Print (3), Custom Tables (3), Outlet (2), Station (2), Session (2), Users (2).
78
+ - **Topics:** Cart (9), Customers (8), Orders (4), Payments (2), Products (4), Refunds (4), Print (3), Custom Tables (3), Outlet (2), Station (2), Session (2), Users (2).
79
79
 
80
80
  ```typescript
81
81
  import { topics } from '@final-commerce/command-frame';
@@ -117,7 +117,7 @@ hooks.unregister('my-extension:cart-log');
117
117
  ### What you should do
118
118
 
119
119
  1. **Recommended:** call **`installExtensionRefundListener`** once when your extension boots (e.g. next to your `RenderClient` setup). Pass an `async` handler that calls your provider (gift card API, wallet, etc.) and returns an **`ExtensionRefundResponse`** (`success`, optional `error`, optional `extensionTransactionId` for receipts / support).
120
- 2. The helper validates `event.source === window.parent`, parses params, and replies with the same **`PostMessageResponse`** envelope as the rest of Command Frame (`requestId`, `success`, `data` / `error`).
120
+ 2. The helper validates `event.source === window.top`, parses params, and replies with the same **`PostMessageResponse`** envelope as the rest of Command Frame (`requestId`, `success`, `data` / `error`).
121
121
  3. **Alternative:** implement a `window` `message` listener yourself using the same contract (action name: **`extensionRefundRequest`**, or import **`EXTENSION_REFUND_REQUEST_ACTION`** from this package).
122
122
 
123
123
  Exported APIs: `installExtensionRefundListener`, `EXTENSION_REFUND_REQUEST_ACTION`, types **`ExtensionRefundParams`** / **`ExtensionRefundResponse`**.
@@ -1,8 +1,9 @@
1
1
  import { createOrderFromCart, MOCK_CART } from "../../demo/database";
2
2
  export const mockTerminalPayment = async (params) => {
3
3
  console.log("[Mock] terminalPayment called", params);
4
+ const connectionType = params?.paymentType || "Cloud";
4
5
  // Simulate terminal interaction
5
- window.alert("Demo: Processing Terminal Payment...\n(Please tap, insert, or swipe card on terminal)");
6
+ window.alert(`Demo: Processing ${connectionType} Terminal Payment...\n(Please tap, insert, or swipe card on terminal)`);
6
7
  const amount = params?.amount || MOCK_CART.total;
7
8
  // Mocking terminal payment success immediately
8
9
  const order = createOrderFromCart("card", amount, "stripe_terminal");
@@ -2,6 +2,8 @@ import { CFOrder } from "../../CommonTypes";
2
2
  export interface TerminalPaymentParams {
3
3
  /** If not provided, uses the cart total. */
4
4
  amount?: number;
5
+ /** "Bluetooth" or "Cloud". Defaults to "Cloud". */
6
+ paymentType?: 'Bluetooth' | 'Cloud';
5
7
  }
6
8
  export interface TerminalPaymentResponse {
7
9
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",