@final-commerce/command-frame 0.9.0-online.3 → 0.9.0-online.5
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/dist/CommonTypes.d.ts +1 -0
- package/dist/actions/get-checkout-status/action.d.ts +6 -0
- package/dist/actions/get-checkout-status/action.js +8 -0
- package/dist/actions/get-checkout-status/mock.d.ts +3 -0
- package/dist/actions/get-checkout-status/mock.js +11 -0
- package/dist/actions/get-checkout-status/types.d.ts +22 -0
- package/dist/actions/get-checkout-status/types.js +12 -0
- package/dist/actions/get-refund-plan/mockRows.js +1 -1
- package/dist/actions/get-refund-plan/types.d.ts +9 -6
- package/dist/actions/get-remaining-refundable-quantities/mock.js +1 -0
- package/dist/actions/get-remaining-refundable-quantities/types.d.ts +5 -0
- package/dist/actions/process-partial-refund/types.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/projects/render/mocks.js +2 -0
- package/dist/projects/render/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/CommonTypes.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ export interface CFActiveRefundDetails {
|
|
|
116
116
|
buttonsDisabled?: Record<string, boolean>;
|
|
117
117
|
isRefund?: boolean;
|
|
118
118
|
customSalesQuantities?: Record<string, number>;
|
|
119
|
+
/** Keyed by cart-fee id, plus the reserved key `'shipping'` for the order's shipping. 0/1 each. */
|
|
119
120
|
cartFeesRefunds?: Record<string, number>;
|
|
120
121
|
tipsRefunds?: Record<string, number>;
|
|
121
122
|
refundProcessingStatus?: CFRefundProcessingStatus | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get Checkout Status action
|
|
3
|
+
* Calls the getCheckoutStatus action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from '../../client';
|
|
6
|
+
export const getCheckoutStatus = async (params) => {
|
|
7
|
+
return await commandFrameClient.call('getCheckoutStatus', params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Standalone mock: every order the preview knows about is already paid. */
|
|
2
|
+
export const mockGetCheckoutStatus = async (params) => {
|
|
3
|
+
console.log('[Mock] getCheckoutStatus called', params);
|
|
4
|
+
return {
|
|
5
|
+
success: true,
|
|
6
|
+
status: params?.orderPassword ? 'paid' : null,
|
|
7
|
+
paid: Boolean(params?.orderPassword),
|
|
8
|
+
receiptId: params?.orderPassword ? 'ON-001-000001' : null,
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The shopper-facing vocabulary: never the platform's payment / fulfilment states. */
|
|
2
|
+
export type CheckoutOrderStatus = 'awaiting_payment' | 'confirming' | 'payment_failed' | 'paid' | 'fulfilled' | 'partially_refunded' | 'refunded' | 'cancelled';
|
|
3
|
+
export interface GetCheckoutStatusParams {
|
|
4
|
+
/** The order password from `startCheckout` or `resumeCheckout`. */
|
|
5
|
+
orderPassword: string;
|
|
6
|
+
/**
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
sessionResult?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GetCheckoutStatusResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
/** `null` when the order is unknown or the password has expired. */
|
|
15
|
+
status: CheckoutOrderStatus | null;
|
|
16
|
+
/** True once the money is in: `paid`, `fulfilled`, or refunded since. */
|
|
17
|
+
paid: boolean;
|
|
18
|
+
receiptId: string | null;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
}
|
|
21
|
+
/** Never throws for an unknown order: answers `status: null`. */
|
|
22
|
+
export type GetCheckoutStatus = (params: GetCheckoutStatusParams) => Promise<GetCheckoutStatusResponse>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Get Checkout Status Types
|
|
2
|
+
//
|
|
3
|
+
// Where an online order stands NOW, as the server holds it. A confirmation page uses it to move
|
|
4
|
+
// from "we're confirming your payment" to "paid" once the payment provider's notification has
|
|
5
|
+
// landed, which the browser alone can never know: it only ever sees that the provider ACCEPTED
|
|
6
|
+
// a payment.
|
|
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.
|
|
10
|
+
//
|
|
11
|
+
// Served ONLY by the storefront runtime (a published website). On a register it does not exist.
|
|
12
|
+
export {};
|
|
@@ -96,7 +96,7 @@ export function mockRefundBreakdown(rows, items) {
|
|
|
96
96
|
return { type: row.type, itemKey: row.itemKey, quantity, amounts: scale(row.amounts, quantity / row.quantity) };
|
|
97
97
|
})
|
|
98
98
|
.filter((r) => r.quantity > 0);
|
|
99
|
-
const totals = { items: 0, discounts: 0, fees: 0, tax: 0, tip: 0, total: 0 };
|
|
99
|
+
const totals = { items: 0, discounts: 0, fees: 0, shipping: 0, tax: 0, tip: 0, total: 0 };
|
|
100
100
|
for (const r of selected) {
|
|
101
101
|
const a = r.amounts;
|
|
102
102
|
if (r.type === 'fee')
|
|
@@ -20,12 +20,13 @@ export interface GetRefundPlanParams {
|
|
|
20
20
|
items?: {
|
|
21
21
|
/**
|
|
22
22
|
* `internalId` / `variantId` for a product, `customSaleId`, cart-fee id, tip
|
|
23
|
-
* `transactionId`,
|
|
23
|
+
* `transactionId`, a booking's own `internalId` on `order.reservations[]`, or
|
|
24
|
+
* `'shipping'` for the order's shipping (all or nothing, like a fee).
|
|
24
25
|
*/
|
|
25
26
|
itemKey: string;
|
|
26
27
|
quantity: number;
|
|
27
28
|
/** Optional hint; inferred from the order when omitted. */
|
|
28
|
-
type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation';
|
|
29
|
+
type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation' | 'shipping';
|
|
29
30
|
}[];
|
|
30
31
|
}
|
|
31
32
|
export interface RefundPlanSource {
|
|
@@ -79,7 +80,7 @@ export interface RefundPlanLeg {
|
|
|
79
80
|
rounding: number;
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
export type RefundPlanRowType = 'product' | 'customSale' | 'fee' | 'tip';
|
|
83
|
+
export type RefundPlanRowType = 'product' | 'customSale' | 'fee' | 'tip' | 'shipping';
|
|
83
84
|
/** One tax rate's share of a row's refund (minor units). */
|
|
84
85
|
export interface RefundPlanTaxLine {
|
|
85
86
|
name: string;
|
|
@@ -107,7 +108,7 @@ export interface RefundPlanAmounts {
|
|
|
107
108
|
total: number;
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
* One refundable row of the order — a line item, custom sale, cart fee or tip —
|
|
111
|
+
* One refundable row of the order — a line item, custom sale, cart fee, shipping or tip —
|
|
111
112
|
* served ready to render. Rows with nothing left to refund are not listed.
|
|
112
113
|
*/
|
|
113
114
|
export interface RefundPlanRow {
|
|
@@ -121,7 +122,7 @@ export interface RefundPlanRow {
|
|
|
121
122
|
attributes?: string;
|
|
122
123
|
/** Tip rows only: the tender that took the tip (`card`, `cash`, …). */
|
|
123
124
|
paymentType?: string;
|
|
124
|
-
/** Quantity originally sold. Fees and tips are `1` — all or nothing. */
|
|
125
|
+
/** Quantity originally sold. Fees, shipping and tips are `1` — all or nothing. */
|
|
125
126
|
quantity: number;
|
|
126
127
|
/** Quantity still refundable — the stepper's max. */
|
|
127
128
|
refundableQuantity: number;
|
|
@@ -137,7 +138,7 @@ export interface RefundPlanSelectedRow {
|
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
139
140
|
* The selection's goods value broken down for display. Minor units;
|
|
140
|
-
* `items − discounts + fees + tax + tip === total === allocation.itemTotal`.
|
|
141
|
+
* `items − discounts + fees + shipping + tax + tip === total === allocation.itemTotal`.
|
|
141
142
|
*/
|
|
142
143
|
export interface RefundPlanTotals {
|
|
143
144
|
/** Σ selected line subtotals (before discounts, tax excluded). */
|
|
@@ -146,6 +147,8 @@ export interface RefundPlanTotals {
|
|
|
146
147
|
discounts: number;
|
|
147
148
|
/** Σ selected cart fees, tax excluded. */
|
|
148
149
|
fees: number;
|
|
150
|
+
/** The order's shipping when selected, tax excluded; 0 otherwise. */
|
|
151
|
+
shipping: number;
|
|
149
152
|
tax: number;
|
|
150
153
|
tip: number;
|
|
151
154
|
total: number;
|
|
@@ -11,6 +11,11 @@ export interface GetRemainingRefundableQuantitiesResponse {
|
|
|
11
11
|
* 0/1 semantics: `1` = still refundable, `0` = already refunded.
|
|
12
12
|
*/
|
|
13
13
|
cartFees: Record<string, number>;
|
|
14
|
+
/**
|
|
15
|
+
* The order's shipping: `1` = still refundable, `0` = already refunded or the order has none.
|
|
16
|
+
* Refunded with `itemKey: 'shipping'`, all or nothing.
|
|
17
|
+
*/
|
|
18
|
+
shipping: number;
|
|
14
19
|
/**
|
|
15
20
|
* Remaining refundable tips, keyed by the paying method's
|
|
16
21
|
* `transactionId` — the same key `processPartialRefund` takes for
|
|
@@ -134,7 +134,7 @@ export interface ProcessPartialRefundParams {
|
|
|
134
134
|
/** internalId or variantId, customSaleId, or a booking's own internalId. */
|
|
135
135
|
itemKey: string;
|
|
136
136
|
quantity: number;
|
|
137
|
-
type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation';
|
|
137
|
+
type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation' | 'shipping';
|
|
138
138
|
/**
|
|
139
139
|
* Per-item stock disposition for a refunded **product** line — the
|
|
140
140
|
* headless equivalent of the old refund popup's per-row restock/damaged
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare const command: {
|
|
|
61
61
|
readonly selectShippingOption: import(".").SelectShippingOption;
|
|
62
62
|
readonly setOutlet: import(".").SetOutlet;
|
|
63
63
|
readonly resumeCheckout: import(".").ResumeCheckout;
|
|
64
|
+
readonly getCheckoutStatus: import(".").GetCheckoutStatus;
|
|
64
65
|
readonly addCustomerNote: import(".").AddCustomerNote;
|
|
65
66
|
readonly removeCustomerNote: import(".").RemoveCustomerNote;
|
|
66
67
|
readonly removeCustomerFromCart: import(".").RemoveCustomerFromCart;
|
|
@@ -214,6 +215,7 @@ export type { GetShippingOptions, GetShippingOptionsResponse, ShippingOptionView
|
|
|
214
215
|
export type { SelectShippingOption, SelectShippingOptionParams, SelectShippingOptionResponse, } from './actions/select-shipping-option/types';
|
|
215
216
|
export type { SetOutlet, SetOutletParams, SetOutletResponse } from './actions/set-outlet/types';
|
|
216
217
|
export type { ResumeCheckout, ResumeCheckoutParams, ResumeCheckoutResponse, ResumeCheckoutResult, } from './actions/resume-checkout/types';
|
|
218
|
+
export type { GetCheckoutStatus, GetCheckoutStatusParams, GetCheckoutStatusResponse, CheckoutOrderStatus, } from './actions/get-checkout-status/types';
|
|
217
219
|
export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse, } from './actions/add-customer-note/types';
|
|
218
220
|
export type { RemoveCustomerNote, RemoveCustomerNoteParams, RemoveCustomerNoteResponse, } from './actions/remove-customer-note/types';
|
|
219
221
|
export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from './actions/remove-customer-from-cart/types';
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import { getShippingOptions } from './actions/get-shipping-options/action';
|
|
|
61
61
|
import { selectShippingOption } from './actions/select-shipping-option/action';
|
|
62
62
|
import { setOutlet } from './actions/set-outlet/action';
|
|
63
63
|
import { resumeCheckout } from './actions/resume-checkout/action';
|
|
64
|
+
import { getCheckoutStatus } from './actions/get-checkout-status/action';
|
|
64
65
|
// Customer Actions
|
|
65
66
|
import { addCustomerNote } from './actions/add-customer-note/action';
|
|
66
67
|
import { removeCustomerNote } from './actions/remove-customer-note/action';
|
|
@@ -216,6 +217,7 @@ export const command = {
|
|
|
216
217
|
selectShippingOption,
|
|
217
218
|
setOutlet,
|
|
218
219
|
resumeCheckout,
|
|
220
|
+
getCheckoutStatus,
|
|
219
221
|
// Customer Actions
|
|
220
222
|
addCustomerNote,
|
|
221
223
|
removeCustomerNote,
|
|
@@ -43,6 +43,7 @@ import { mockSelectShippingOption } from '../../actions/select-shipping-option/m
|
|
|
43
43
|
import { mockGetOutlets } from '../../actions/get-outlets/mock';
|
|
44
44
|
import { mockSetOutlet } from '../../actions/set-outlet/mock';
|
|
45
45
|
import { mockResumeCheckout } from '../../actions/resume-checkout/mock';
|
|
46
|
+
import { mockGetCheckoutStatus } from '../../actions/get-checkout-status/mock';
|
|
46
47
|
import { mockGetTimeClockStatus } from '../../actions/get-time-clock-status/mock';
|
|
47
48
|
import { mockClearCart } from '../../actions/clear-cart/mock';
|
|
48
49
|
import { mockDeleteParkedOrder } from '../../actions/delete-parked-order/mock';
|
|
@@ -159,6 +160,7 @@ export const RENDER_MOCKS = {
|
|
|
159
160
|
getOutlets: mockGetOutlets,
|
|
160
161
|
setOutlet: mockSetOutlet,
|
|
161
162
|
resumeCheckout: mockResumeCheckout,
|
|
163
|
+
getCheckoutStatus: mockGetCheckoutStatus,
|
|
162
164
|
clearCart: mockClearCart,
|
|
163
165
|
deleteParkedOrder: mockDeleteParkedOrder,
|
|
164
166
|
voidOrder: mockVoidOrder,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, GetCustomStockActions, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, GetProductModifierSelections, SetProductModifierSelections, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, GetBookingResources, GetBookingAvailability, GetBookings, HoldBooking, AddBookingToCart, RemoveBookingFromCart, CancelBooking, CreatePaymentLink, ChargeMoto, StartCheckout, AttachCheckoutContact, GetAddressOptions, SetOrderAddress, GetShippingOptions, SelectShippingOption, GetOutlets, SetOutlet, ResumeCheckout, GetTimeClockStatus } from '../../index';
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, GetCustomStockActions, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, GetProductModifierSelections, SetProductModifierSelections, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, GetBookingResources, GetBookingAvailability, GetBookings, HoldBooking, AddBookingToCart, RemoveBookingFromCart, CancelBooking, CreatePaymentLink, ChargeMoto, StartCheckout, AttachCheckoutContact, GetAddressOptions, SetOrderAddress, GetShippingOptions, SelectShippingOption, GetOutlets, SetOutlet, ResumeCheckout, GetCheckoutStatus, GetTimeClockStatus } from '../../index';
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -73,6 +73,8 @@ export interface RenderProviderActions {
|
|
|
73
73
|
* `startCheckout`, and safe to call on every page load.
|
|
74
74
|
*/
|
|
75
75
|
resumeCheckout: ResumeCheckout;
|
|
76
|
+
/** Where an online order stands now, by its order password. Storefront-only. */
|
|
77
|
+
getCheckoutStatus: GetCheckoutStatus;
|
|
76
78
|
addNonRevenueItem: AddNonRevenueItem;
|
|
77
79
|
addCustomerNote: AddCustomerNote;
|
|
78
80
|
removeCustomerNote: RemoveCustomerNote;
|