@final-commerce/command-frame 0.11.1-preprod.2 → 0.11.1-preprod.3

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.
@@ -19,11 +19,16 @@ export const mockRecordExternalPayment = async (params) => {
19
19
  if (amount > balanceDue) {
20
20
  throw new Error(`recordExternalPayment: amount ${amount} exceeds the balance due ${balanceDue}`);
21
21
  }
22
+ const tip = params.tip?.amount ?? 0;
23
+ if (params.tip !== undefined && (!Number.isInteger(tip) || tip <= 0)) {
24
+ throw new Error('recordExternalPayment: tip.amount must be a positive integer (minor units)');
25
+ }
22
26
  const order = applyMockPayment(amount, 'external', label);
23
27
  const remainingBalance = MOCK_CART.remainingBalance ?? 0;
24
28
  return {
25
29
  success: true,
26
30
  amount,
31
+ tip,
27
32
  label,
28
33
  paymentType: 'external',
29
34
  change: 0,
@@ -1,4 +1,11 @@
1
1
  import { CFOrder } from '../../CommonTypes';
2
+ /** A tip the customer already paid wherever the money was taken (the website, a delivery app). */
3
+ export interface RecordExternalPaymentTip {
4
+ /** Tip in integer MINOR currency units. Must be positive. */
5
+ amount: number;
6
+ /** User id the tip belongs to. Defaults to the cashier recording the payment. */
7
+ tipTo?: string;
8
+ }
2
9
  export interface RecordExternalPaymentParams {
3
10
  /**
4
11
  * What the payment was — shown on the order and in reports, e.g. 'Paid online',
@@ -12,13 +19,21 @@ export interface RecordExternalPaymentParams {
12
19
  * the rest can be taken with any other tender. Above the balance due is an error.
13
20
  */
14
21
  amount?: number;
22
+ /**
23
+ * Tip paid along with it. Recorded ON TOP of `amount` — it never counts toward the
24
+ * balance due — and stored on the payment like a card tip, so reports and tip-outs
25
+ * see it. Omit for no tip.
26
+ */
27
+ tip?: RecordExternalPaymentTip;
15
28
  /** Fulfillment state to land on after full payment, e.g. 'pending' to keep the order going to the kitchen. */
16
29
  checkoutFulfillmentTarget?: string;
17
30
  }
18
31
  export interface RecordExternalPaymentResponse {
19
32
  success: boolean;
20
- /** The amount recorded, in integer MINOR currency units. */
33
+ /** The amount recorded against the balance, in integer MINOR currency units. Excludes the tip. */
21
34
  amount: number;
35
+ /** The tip recorded on top of `amount`, in integer MINOR currency units; 0 when none. */
36
+ tip: number;
22
37
  /** The label, as recorded. */
23
38
  label: string;
24
39
  paymentType: 'external';
package/dist/index.d.ts CHANGED
@@ -223,7 +223,7 @@ export type { GetOrderStatuses, GetOrderStatusesResponse } from './actions/get-o
223
223
  export type { DeleteParkedOrder, DeleteParkedOrderParams, DeleteParkedOrderResponse, } from './actions/delete-parked-order/types';
224
224
  export type { VoidOrder, VoidOrderParams, VoidOrderResponse, VoidOrderOutcome } from './actions/void-order/types';
225
225
  export type { CashPayment, CashPaymentParams, CashPaymentResponse } from './actions/cash-payment/types';
226
- export type { RecordExternalPayment, RecordExternalPaymentParams, RecordExternalPaymentResponse, } from './actions/record-external-payment/types';
226
+ export type { RecordExternalPayment, RecordExternalPaymentParams, RecordExternalPaymentResponse, RecordExternalPaymentTip, } from './actions/record-external-payment/types';
227
227
  export type { GetCashRoundingAmount, GetCashRoundingAmountParams, GetCashRoundingAmountResponse, } from './actions/get-cash-rounding-amount/types';
228
228
  export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse, } from './actions/tap-to-pay-payment/types';
229
229
  export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from './actions/terminal-payment/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.11.1-preprod.2",
3
+ "version": "0.11.1-preprod.3",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",