@final-commerce/command-frame 0.9.0-online.4 → 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.
- 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 +20 -0
- package/dist/actions/get-checkout-status/types.js +12 -0
- package/dist/actions/get-product-modifier-selections/mock.js +5 -0
- package/dist/actions/get-product-modifier-selections/types.d.ts +4 -0
- 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
|
@@ -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: 'paid',
|
|
7
|
+
paid: true,
|
|
8
|
+
receiptId: params?.receiptId ?? 'ON-001-000001',
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* The receipt `startCheckout` returned, to name which order. Omitted: the checkout in flight,
|
|
6
|
+
* else the last one this tab finished.
|
|
7
|
+
*/
|
|
8
|
+
receiptId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GetCheckoutStatusResponse {
|
|
11
|
+
success: boolean;
|
|
12
|
+
/** `null` when this tab placed no such order, or the server could not be asked. */
|
|
13
|
+
status: CheckoutOrderStatus | null;
|
|
14
|
+
/** True once the money is in: `paid`, `fulfilled`, or refunded since. */
|
|
15
|
+
paid: boolean;
|
|
16
|
+
receiptId: string | null;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
}
|
|
19
|
+
/** Never throws for an unknown order: answers `status: null`. */
|
|
20
|
+
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
|
+
// 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
|
+
//
|
|
11
|
+
// Served ONLY by the storefront runtime (a published website). On a register it does not exist.
|
|
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/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;
|