@final-commerce/command-frame 0.9.0-online.4 → 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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get Checkout Status action
3
+ * Calls the getCheckoutStatus action on the parent window
4
+ */
5
+ import type { GetCheckoutStatus } from './types';
6
+ export declare const getCheckoutStatus: GetCheckoutStatus;
@@ -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,3 @@
1
+ import { GetCheckoutStatus } from './types';
2
+ /** Standalone mock: every order the preview knows about is already paid. */
3
+ export declare const mockGetCheckoutStatus: GetCheckoutStatus;
@@ -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 {};
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.9.0-online.4",
3
+ "version": "0.9.0-online.5",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",