@payloadcms/plugin-ecommerce 3.84.0-canary.1 → 3.84.0-internal.d5d6e43

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.
Files changed (44) hide show
  1. package/dist/collections/orders/createOrdersCollection.d.ts +6 -0
  2. package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -1
  3. package/dist/collections/orders/createOrdersCollection.js +7 -1
  4. package/dist/collections/orders/createOrdersCollection.js.map +1 -1
  5. package/dist/collections/transactions/createTransactionsCollection.d.ts +6 -0
  6. package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -1
  7. package/dist/collections/transactions/createTransactionsCollection.js +7 -1
  8. package/dist/collections/transactions/createTransactionsCollection.js.map +1 -1
  9. package/dist/endpoints/confirmOrder.d.ts +11 -1
  10. package/dist/endpoints/confirmOrder.d.ts.map +1 -1
  11. package/dist/endpoints/confirmOrder.js +74 -2
  12. package/dist/endpoints/confirmOrder.js.map +1 -1
  13. package/dist/endpoints/initiatePayment.d.ts +11 -1
  14. package/dist/endpoints/initiatePayment.d.ts.map +1 -1
  15. package/dist/endpoints/initiatePayment.js +74 -3
  16. package/dist/endpoints/initiatePayment.js.map +1 -1
  17. package/dist/exports/types.d.ts +1 -1
  18. package/dist/exports/types.d.ts.map +1 -1
  19. package/dist/exports/types.js.map +1 -1
  20. package/dist/fields/summaryField.d.ts +14 -0
  21. package/dist/fields/summaryField.d.ts.map +1 -0
  22. package/dist/fields/summaryField.js +83 -0
  23. package/dist/fields/summaryField.js.map +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +11 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/payments/adapters/stripe/index.d.ts +2 -1
  28. package/dist/payments/adapters/stripe/index.d.ts.map +1 -1
  29. package/dist/payments/adapters/stripe/index.js.map +1 -1
  30. package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -1
  31. package/dist/payments/adapters/stripe/initiatePayment.js +6 -3
  32. package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -1
  33. package/dist/types/index.d.ts +200 -0
  34. package/dist/types/index.d.ts.map +1 -1
  35. package/dist/types/index.js.map +1 -1
  36. package/dist/utilities/runPaymentHooks.d.ts +28 -0
  37. package/dist/utilities/runPaymentHooks.d.ts.map +1 -0
  38. package/dist/utilities/runPaymentHooks.js +68 -0
  39. package/dist/utilities/runPaymentHooks.js.map +1 -0
  40. package/dist/utilities/runPaymentHooks.spec.js +324 -0
  41. package/dist/utilities/runPaymentHooks.spec.js.map +1 -0
  42. package/dist/utilities/sanitizePluginConfig.spec.js +35 -0
  43. package/dist/utilities/sanitizePluginConfig.spec.js.map +1 -1
  44. package/package.json +7 -7
@@ -25,12 +25,174 @@ type DefaultCartType = {
25
25
  subtotal?: number;
26
26
  };
27
27
  export type Cart = DefaultCartType;
28
+ export type LineType = 'custom' | 'discount' | 'gift_card' | 'shipping' | 'subtotal' | 'tax';
29
+ /**
30
+ * A single line item making up a payment summary — items, tax, shipping, discount, etc.
31
+ */
32
+ export type Line = {
33
+ /**
34
+ * The signed amount of the line in the smallest currency unit (e.g. cents for USD).
35
+ * Positive values increase the total (tax, shipping).
36
+ * Negative values decrease the total (discount, gift card).
37
+ */
38
+ amount: number;
39
+ /**
40
+ * Human-readable label for display (e.g., "CA Sales Tax", "Standard Shipping").
41
+ */
42
+ label: string;
43
+ /**
44
+ * Optional metadata for adapter-specific or user-specific data. A common pattern
45
+ * is to stash a `taxable` flag here so later hooks know whether to include this line,
46
+ * or an external identifier for idempotency with a tax/shipping provider.
47
+ */
48
+ metadata?: Record<string, unknown>;
49
+ /**
50
+ * The type of line.
51
+ */
52
+ type: LineType;
53
+ };
54
+ /**
55
+ * Full breakdown of the payment amount. Passed through the beforeInitiatePayment hook
56
+ * pipeline and returned in the `/payments/{provider}/initiate` response.
57
+ *
58
+ * The plugin recomputes `total` from `lines` after every hook, so you never need to
59
+ * update `total` yourself inside a hook — just return the updated `lines`. The first
60
+ * line is always the cart subtotal and is managed by the plugin; removing it or changing
61
+ * its amount will throw.
62
+ */
63
+ export type Summary = {
64
+ /**
65
+ * The ISO currency code used for all line amounts.
66
+ */
67
+ currency: string;
68
+ /**
69
+ * Ordered list of line items contributing to the total.
70
+ * `lines[0]` is always the cart subtotal and is managed by the plugin.
71
+ */
72
+ lines: Line[];
73
+ /**
74
+ * The final amount charged. Always equal to `sum(lines[].amount)`. This value is
75
+ * recomputed by the plugin after each hook — any value a hook sets is ignored.
76
+ */
77
+ total: number;
78
+ };
79
+ /**
80
+ * Context provided to payment hooks during the initiate payment flow.
81
+ */
82
+ export type PaymentHookContext = {
83
+ /**
84
+ * Billing address, if provided.
85
+ */
86
+ billingAddress?: TypedCollection['addresses'];
87
+ /**
88
+ * The validated cart with items.
89
+ */
90
+ cart: Cart;
91
+ /**
92
+ * The currencies configuration.
93
+ */
94
+ currenciesConfig: CurrenciesConfig;
95
+ /**
96
+ * The resolved currency code.
97
+ */
98
+ currency: string;
99
+ /**
100
+ * Customer email address.
101
+ */
102
+ customerEmail: string;
103
+ /**
104
+ * The Payload request object.
105
+ */
106
+ req: PayloadRequest;
107
+ /**
108
+ * Shipping address, if provided.
109
+ */
110
+ shippingAddress?: TypedCollection['addresses'];
111
+ };
112
+ /**
113
+ * Hook that runs before payment initiation, after validation.
114
+ *
115
+ * Receives the current `Summary` (total, currency, lines) and must return an updated
116
+ * `Summary`. Typically you'll spread the incoming summary and append your line:
117
+ *
118
+ * ```ts
119
+ * return {
120
+ * ...summary,
121
+ * lines: [...summary.lines, { type: 'tax', label: 'Sales Tax', amount: 1500 }],
122
+ * }
123
+ * ```
124
+ *
125
+ * The plugin recomputes `summary.total` from `summary.lines` after this hook runs,
126
+ * so you never need to update `total` yourself.
127
+ *
128
+ * Throwing an error aborts the payment.
129
+ */
130
+ export type BeforeInitiatePaymentHook = (args: {
131
+ /**
132
+ * The running summary — the cart subtotal plus any lines contributed by prior hooks.
133
+ * Return a new summary with your line appended (or existing lines modified).
134
+ */
135
+ summary: Summary;
136
+ } & PaymentHookContext) => Promise<Summary> | Summary;
137
+ /**
138
+ * Hook that runs before order confirmation.
139
+ * Can inspect data before the adapter confirms. Throwing an error aborts the confirmation.
140
+ */
141
+ export type BeforeConfirmOrderHook = (args: {
142
+ /**
143
+ * Customer email.
144
+ */
145
+ customerEmail: string;
146
+ /**
147
+ * All data passed to the confirm-order endpoint.
148
+ */
149
+ data: Record<string, unknown>;
150
+ /**
151
+ * The Payload request object.
152
+ */
153
+ req: PayloadRequest;
154
+ }) => Promise<void> | void;
155
+ /**
156
+ * Hook that runs after order confirmation succeeds.
157
+ * For side effects only (sending emails, updating external systems, redeeming gift cards).
158
+ * Return value is ignored. Errors are logged but do not fail the response.
159
+ */
160
+ export type AfterConfirmOrderHook = (args: {
161
+ /**
162
+ * The created order ID.
163
+ */
164
+ orderID: DefaultDocumentIDType;
165
+ /**
166
+ * The Payload request object.
167
+ */
168
+ req: PayloadRequest;
169
+ /**
170
+ * The transaction ID.
171
+ */
172
+ transactionID: DefaultDocumentIDType;
173
+ }) => Promise<void> | void;
174
+ /**
175
+ * Hook configuration for the payment flow. Used at both the plugin level
176
+ * (runs for all payment methods) and the adapter level (runs for that adapter only).
177
+ */
178
+ export type PaymentHooks = {
179
+ afterConfirmOrder?: AfterConfirmOrderHook[];
180
+ beforeConfirmOrder?: BeforeConfirmOrderHook[];
181
+ beforeInitiatePayment?: BeforeInitiatePaymentHook[];
182
+ };
28
183
  type InitiatePaymentReturnType = {
29
184
  /**
30
185
  * Allows for additional data to be returned, such as payment method specific data
31
186
  */
32
187
  [key: string]: any;
33
188
  message: string;
189
+ /**
190
+ * Optional ID of the transaction record created during initiation. When returned,
191
+ * the plugin will write the computed `summary` onto this transaction — so the
192
+ * breakdown (subtotal, tax, shipping, etc.) is available on the record alongside
193
+ * the total.
194
+ */
195
+ transactionID?: DefaultDocumentIDType;
34
196
  };
35
197
  type InitiatePayment = (args: {
36
198
  /**
@@ -55,6 +217,12 @@ type InitiatePayment = (args: {
55
217
  * Shipping address for the payment.
56
218
  */
57
219
  shippingAddress?: TypedCollection['addresses'];
220
+ /**
221
+ * The final payment summary after all beforeInitiatePayment hooks have run.
222
+ * Use `summary.total` as the amount to charge and store `summary.lines` if you
223
+ * need to persist the breakdown (e.g. in provider metadata).
224
+ */
225
+ summary: Summary;
58
226
  };
59
227
  req: PayloadRequest;
60
228
  /**
@@ -166,6 +334,21 @@ export type PaymentAdapter = {
166
334
  * ```
167
335
  */
168
336
  group: GroupField;
337
+ /**
338
+ * Hooks specific to this payment adapter. These run after plugin-level hooks.
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * hooks: {
343
+ * beforeInitiatePayment: [
344
+ * async ({ subtotal }) => {
345
+ * return [{ type: 'tax', label: 'Stripe Tax', amount: calculatedTax }]
346
+ * },
347
+ * ],
348
+ * }
349
+ * ```
350
+ */
351
+ hooks?: PaymentHooks;
169
352
  /**
170
353
  * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.
171
354
  *
@@ -406,6 +589,22 @@ export type CustomQuery = {
406
589
  where?: Where;
407
590
  };
408
591
  export type PaymentsConfig = {
592
+ /**
593
+ * Hooks that run for all payment methods. Plugin-level hooks execute before adapter-level hooks.
594
+ *
595
+ * @example
596
+ * ```ts
597
+ * hooks: {
598
+ * beforeInitiatePayment: [
599
+ * async ({ subtotal, shippingAddress }) => {
600
+ * const taxRate = await fetchTaxRate(shippingAddress)
601
+ * return [{ type: 'tax', label: 'Sales Tax', amount: Math.round(subtotal * taxRate) }]
602
+ * },
603
+ * ],
604
+ * }
605
+ * ```
606
+ */
607
+ hooks?: PaymentHooks;
409
608
  paymentMethods?: PaymentAdapter[];
410
609
  productsQuery?: CustomQuery;
411
610
  variantsQuery?: CustomQuery;
@@ -741,6 +940,7 @@ export type SanitizedEcommercePluginConfig = {
741
940
  currencies: Required<CurrenciesConfig>;
742
941
  inventory?: InventoryConfig;
743
942
  payments: {
943
+ hooks?: PaymentHooks;
744
944
  paymentMethods: [] | PaymentAdapter[];
745
945
  };
746
946
  } & Omit<Required<EcommercePluginConfig>, 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE;IACtC,iBAAiB,EAAE,gBAAgB,CAAA;CACpC,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;CAC9D,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IAC/D,EAAE,EAAE,qBAAqB,CAAA;IACzB,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,QAAQ,CAAC,EAAE,MAA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;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACrC;;;OAGG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC;;OAEG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACjG;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAo5BA,WAwIC"}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\nexport type LineType = 'custom' | 'discount' | 'gift_card' | 'shipping' | 'subtotal' | 'tax'\n\n/**\n * A single line item making up a payment summary — items, tax, shipping, discount, etc.\n */\nexport type Line = {\n /**\n * The signed amount of the line in the smallest currency unit (e.g. cents for USD).\n * Positive values increase the total (tax, shipping).\n * Negative values decrease the total (discount, gift card).\n */\n amount: number\n /**\n * Human-readable label for display (e.g., \"CA Sales Tax\", \"Standard Shipping\").\n */\n label: string\n /**\n * Optional metadata for adapter-specific or user-specific data. A common pattern\n * is to stash a `taxable` flag here so later hooks know whether to include this line,\n * or an external identifier for idempotency with a tax/shipping provider.\n */\n metadata?: Record<string, unknown>\n /**\n * The type of line.\n */\n type: LineType\n}\n\n/**\n * Full breakdown of the payment amount. Passed through the beforeInitiatePayment hook\n * pipeline and returned in the `/payments/{provider}/initiate` response.\n *\n * The plugin recomputes `total` from `lines` after every hook, so you never need to\n * update `total` yourself inside a hook — just return the updated `lines`. The first\n * line is always the cart subtotal and is managed by the plugin; removing it or changing\n * its amount will throw.\n */\nexport type Summary = {\n /**\n * The ISO currency code used for all line amounts.\n */\n currency: string\n /**\n * Ordered list of line items contributing to the total.\n * `lines[0]` is always the cart subtotal and is managed by the plugin.\n */\n lines: Line[]\n /**\n * The final amount charged. Always equal to `sum(lines[].amount)`. This value is\n * recomputed by the plugin after each hook — any value a hook sets is ignored.\n */\n total: number\n}\n\n/**\n * Context provided to payment hooks during the initiate payment flow.\n */\nexport type PaymentHookContext = {\n /**\n * Billing address, if provided.\n */\n billingAddress?: TypedCollection['addresses']\n /**\n * The validated cart with items.\n */\n cart: Cart\n /**\n * The currencies configuration.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The resolved currency code.\n */\n currency: string\n /**\n * Customer email address.\n */\n customerEmail: string\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n /**\n * Shipping address, if provided.\n */\n shippingAddress?: TypedCollection['addresses']\n}\n\n/**\n * Hook that runs before payment initiation, after validation.\n *\n * Receives the current `Summary` (total, currency, lines) and must return an updated\n * `Summary`. Typically you'll spread the incoming summary and append your line:\n *\n * ```ts\n * return {\n * ...summary,\n * lines: [...summary.lines, { type: 'tax', label: 'Sales Tax', amount: 1500 }],\n * }\n * ```\n *\n * The plugin recomputes `summary.total` from `summary.lines` after this hook runs,\n * so you never need to update `total` yourself.\n *\n * Throwing an error aborts the payment.\n */\nexport type BeforeInitiatePaymentHook = (\n args: {\n /**\n * The running summary — the cart subtotal plus any lines contributed by prior hooks.\n * Return a new summary with your line appended (or existing lines modified).\n */\n summary: Summary\n } & PaymentHookContext,\n) => Promise<Summary> | Summary\n\n/**\n * Hook that runs before order confirmation.\n * Can inspect data before the adapter confirms. Throwing an error aborts the confirmation.\n */\nexport type BeforeConfirmOrderHook = (args: {\n /**\n * Customer email.\n */\n customerEmail: string\n /**\n * All data passed to the confirm-order endpoint.\n */\n data: Record<string, unknown>\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n}) => Promise<void> | void\n\n/**\n * Hook that runs after order confirmation succeeds.\n * For side effects only (sending emails, updating external systems, redeeming gift cards).\n * Return value is ignored. Errors are logged but do not fail the response.\n */\nexport type AfterConfirmOrderHook = (args: {\n /**\n * The created order ID.\n */\n orderID: DefaultDocumentIDType\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n /**\n * The transaction ID.\n */\n transactionID: DefaultDocumentIDType\n}) => Promise<void> | void\n\n/**\n * Hook configuration for the payment flow. Used at both the plugin level\n * (runs for all payment methods) and the adapter level (runs for that adapter only).\n */\nexport type PaymentHooks = {\n afterConfirmOrder?: AfterConfirmOrderHook[]\n beforeConfirmOrder?: BeforeConfirmOrderHook[]\n beforeInitiatePayment?: BeforeInitiatePaymentHook[]\n}\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n /**\n * Optional ID of the transaction record created during initiation. When returned,\n * the plugin will write the computed `summary` onto this transaction — so the\n * breakdown (subtotal, tax, shipping, etc.) is available on the record alongside\n * the total.\n */\n transactionID?: DefaultDocumentIDType\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n /**\n * The final payment summary after all beforeInitiatePayment hooks have run.\n * Use `summary.total` as the amount to charge and store `summary.lines` if you\n * need to persist the breakdown (e.g. in provider metadata).\n */\n summary: Summary\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * Hooks specific to this payment adapter. These run after plugin-level hooks.\n *\n * @example\n * ```ts\n * hooks: {\n * beforeInitiatePayment: [\n * async ({ subtotal }) => {\n * return [{ type: 'tax', label: 'Stripe Tax', amount: calculatedTax }]\n * },\n * ],\n * }\n * ```\n */\n hooks?: PaymentHooks\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n /**\n * Hooks that run for all payment methods. Plugin-level hooks execute before adapter-level hooks.\n *\n * @example\n * ```ts\n * hooks: {\n * beforeInitiatePayment: [\n * async ({ subtotal, shippingAddress }) => {\n * const taxRate = await fetchTaxRate(shippingAddress)\n * return [{ type: 'tax', label: 'Sales Tax', amount: Math.round(subtotal * taxRate) }]\n * },\n * ],\n * }\n * ```\n */\n hooks?: PaymentHooks\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n hooks?: PaymentHooks\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAsmCA,WAwIC"}
@@ -0,0 +1,28 @@
1
+ import type { AfterConfirmOrderHook, BeforeConfirmOrderHook, BeforeInitiatePaymentHook, Summary } from '../types/index.js';
2
+ /**
3
+ * Runs beforeInitiatePayment hooks sequentially, piping the Summary through each.
4
+ *
5
+ * After every hook, the plugin:
6
+ * 1. Recomputes `total` from `sum(lines[].amount)` — any total the hook sets is ignored.
7
+ * 2. Validates `lines[0]` is still the subtotal line with the original cart subtotal.
8
+ * 3. Validates `currency` has not changed.
9
+ *
10
+ * Throws (aborting the payment) if a hook throws or breaks an invariant.
11
+ */
12
+ export declare function runBeforeInitiatePaymentHooks(hooks: BeforeInitiatePaymentHook[], context: {
13
+ summary: Summary;
14
+ } & Omit<Parameters<BeforeInitiatePaymentHook>[0], 'summary'>): Promise<Summary>;
15
+ /**
16
+ * Runs beforeConfirmOrder hooks sequentially.
17
+ * Throws if any hook throws, aborting the confirmation.
18
+ */
19
+ export declare function runBeforeConfirmOrderHooks(hooks: BeforeConfirmOrderHook[], context: Parameters<BeforeConfirmOrderHook>[0]): Promise<void>;
20
+ /**
21
+ * Runs afterConfirmOrder hooks sequentially.
22
+ * Errors are caught and logged but do not fail the response.
23
+ * All hooks execute even if some fail.
24
+ */
25
+ export declare function runAfterConfirmOrderHooks(hooks: AfterConfirmOrderHook[], context: Parameters<AfterConfirmOrderHook>[0], logger: {
26
+ error: (...args: unknown[]) => void;
27
+ }): Promise<void>;
28
+ //# sourceMappingURL=runPaymentHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runPaymentHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/runPaymentHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,OAAO,EACR,MAAM,mBAAmB,CAAA;AAuC1B;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,yBAAyB,EAAE,EAClC,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GACxF,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,sBAAsB,EAAE,EAC/B,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,qBAAqB,EAAE,EAC9B,OAAO,EAAE,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,EAAE;IAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CAAE,GAC9C,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1,68 @@
1
+ const recomputeTotal = (summary)=>({
2
+ ...summary,
3
+ total: summary.lines.reduce((sum, line)=>sum + line.amount, 0)
4
+ });
5
+ const assertSummaryInvariants = (summary, expected, hookIndex)=>{
6
+ if (!summary || !Array.isArray(summary.lines)) {
7
+ throw new Error(`beforeInitiatePayment hook ${hookIndex} returned an invalid summary (missing lines).`);
8
+ }
9
+ const subtotalLine = summary.lines[0];
10
+ if (!subtotalLine || subtotalLine.type !== 'subtotal') {
11
+ throw new Error(`beforeInitiatePayment hook ${hookIndex} removed or reordered the subtotal line. lines[0] must always be the cart subtotal.`);
12
+ }
13
+ if (subtotalLine.amount !== expected.subtotal) {
14
+ throw new Error(`beforeInitiatePayment hook ${hookIndex} changed the subtotal amount from ${expected.subtotal} to ${subtotalLine.amount}. Subtotal is managed by the plugin and must not be mutated.`);
15
+ }
16
+ if (summary.currency !== expected.currency) {
17
+ throw new Error(`beforeInitiatePayment hook ${hookIndex} changed summary.currency — currency must remain "${expected.currency}".`);
18
+ }
19
+ };
20
+ /**
21
+ * Runs beforeInitiatePayment hooks sequentially, piping the Summary through each.
22
+ *
23
+ * After every hook, the plugin:
24
+ * 1. Recomputes `total` from `sum(lines[].amount)` — any total the hook sets is ignored.
25
+ * 2. Validates `lines[0]` is still the subtotal line with the original cart subtotal.
26
+ * 3. Validates `currency` has not changed.
27
+ *
28
+ * Throws (aborting the payment) if a hook throws or breaks an invariant.
29
+ */ export async function runBeforeInitiatePaymentHooks(hooks, context) {
30
+ let summary = recomputeTotal(context.summary);
31
+ const expected = {
32
+ currency: summary.currency,
33
+ subtotal: summary.lines[0]?.amount ?? 0
34
+ };
35
+ for(let i = 0; i < hooks.length; i++){
36
+ const hook = hooks[i];
37
+ const next = await hook({
38
+ ...context,
39
+ summary
40
+ });
41
+ assertSummaryInvariants(next, expected, i);
42
+ summary = recomputeTotal(next);
43
+ }
44
+ return summary;
45
+ }
46
+ /**
47
+ * Runs beforeConfirmOrder hooks sequentially.
48
+ * Throws if any hook throws, aborting the confirmation.
49
+ */ export async function runBeforeConfirmOrderHooks(hooks, context) {
50
+ for (const hook of hooks){
51
+ await hook(context);
52
+ }
53
+ }
54
+ /**
55
+ * Runs afterConfirmOrder hooks sequentially.
56
+ * Errors are caught and logged but do not fail the response.
57
+ * All hooks execute even if some fail.
58
+ */ export async function runAfterConfirmOrderHooks(hooks, context, logger) {
59
+ for (const hook of hooks){
60
+ try {
61
+ await hook(context);
62
+ } catch (error) {
63
+ logger.error(error, 'Error in afterConfirmOrder hook.');
64
+ }
65
+ }
66
+ }
67
+
68
+ //# sourceMappingURL=runPaymentHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/runPaymentHooks.ts"],"sourcesContent":["import type {\n AfterConfirmOrderHook,\n BeforeConfirmOrderHook,\n BeforeInitiatePaymentHook,\n Summary,\n} from '../types/index.js'\n\nconst recomputeTotal = (summary: Summary): Summary => ({\n ...summary,\n total: summary.lines.reduce((sum, line) => sum + line.amount, 0),\n})\n\nconst assertSummaryInvariants = (\n summary: Summary,\n expected: { currency: string; subtotal: number },\n hookIndex: number,\n): void => {\n if (!summary || !Array.isArray(summary.lines)) {\n throw new Error(\n `beforeInitiatePayment hook ${hookIndex} returned an invalid summary (missing lines).`,\n )\n }\n\n const subtotalLine = summary.lines[0]\n\n if (!subtotalLine || subtotalLine.type !== 'subtotal') {\n throw new Error(\n `beforeInitiatePayment hook ${hookIndex} removed or reordered the subtotal line. lines[0] must always be the cart subtotal.`,\n )\n }\n\n if (subtotalLine.amount !== expected.subtotal) {\n throw new Error(\n `beforeInitiatePayment hook ${hookIndex} changed the subtotal amount from ${expected.subtotal} to ${subtotalLine.amount}. Subtotal is managed by the plugin and must not be mutated.`,\n )\n }\n\n if (summary.currency !== expected.currency) {\n throw new Error(\n `beforeInitiatePayment hook ${hookIndex} changed summary.currency — currency must remain \"${expected.currency}\".`,\n )\n }\n}\n\n/**\n * Runs beforeInitiatePayment hooks sequentially, piping the Summary through each.\n *\n * After every hook, the plugin:\n * 1. Recomputes `total` from `sum(lines[].amount)` — any total the hook sets is ignored.\n * 2. Validates `lines[0]` is still the subtotal line with the original cart subtotal.\n * 3. Validates `currency` has not changed.\n *\n * Throws (aborting the payment) if a hook throws or breaks an invariant.\n */\nexport async function runBeforeInitiatePaymentHooks(\n hooks: BeforeInitiatePaymentHook[],\n context: { summary: Summary } & Omit<Parameters<BeforeInitiatePaymentHook>[0], 'summary'>,\n): Promise<Summary> {\n let summary: Summary = recomputeTotal(context.summary)\n\n const expected = {\n currency: summary.currency,\n subtotal: summary.lines[0]?.amount ?? 0,\n }\n\n for (let i = 0; i < hooks.length; i++) {\n const hook = hooks[i]!\n const next = await hook({ ...context, summary })\n\n assertSummaryInvariants(next, expected, i)\n summary = recomputeTotal(next)\n }\n\n return summary\n}\n\n/**\n * Runs beforeConfirmOrder hooks sequentially.\n * Throws if any hook throws, aborting the confirmation.\n */\nexport async function runBeforeConfirmOrderHooks(\n hooks: BeforeConfirmOrderHook[],\n context: Parameters<BeforeConfirmOrderHook>[0],\n): Promise<void> {\n for (const hook of hooks) {\n await hook(context)\n }\n}\n\n/**\n * Runs afterConfirmOrder hooks sequentially.\n * Errors are caught and logged but do not fail the response.\n * All hooks execute even if some fail.\n */\nexport async function runAfterConfirmOrderHooks(\n hooks: AfterConfirmOrderHook[],\n context: Parameters<AfterConfirmOrderHook>[0],\n logger: { error: (...args: unknown[]) => void },\n): Promise<void> {\n for (const hook of hooks) {\n try {\n await hook(context)\n } catch (error) {\n logger.error(error, 'Error in afterConfirmOrder hook.')\n }\n }\n}\n"],"names":["recomputeTotal","summary","total","lines","reduce","sum","line","amount","assertSummaryInvariants","expected","hookIndex","Array","isArray","Error","subtotalLine","type","subtotal","currency","runBeforeInitiatePaymentHooks","hooks","context","i","length","hook","next","runBeforeConfirmOrderHooks","runAfterConfirmOrderHooks","logger","error"],"mappings":"AAOA,MAAMA,iBAAiB,CAACC,UAA+B,CAAA;QACrD,GAAGA,OAAO;QACVC,OAAOD,QAAQE,KAAK,CAACC,MAAM,CAAC,CAACC,KAAKC,OAASD,MAAMC,KAAKC,MAAM,EAAE;IAChE,CAAA;AAEA,MAAMC,0BAA0B,CAC9BP,SACAQ,UACAC;IAEA,IAAI,CAACT,WAAW,CAACU,MAAMC,OAAO,CAACX,QAAQE,KAAK,GAAG;QAC7C,MAAM,IAAIU,MACR,CAAC,2BAA2B,EAAEH,UAAU,6CAA6C,CAAC;IAE1F;IAEA,MAAMI,eAAeb,QAAQE,KAAK,CAAC,EAAE;IAErC,IAAI,CAACW,gBAAgBA,aAAaC,IAAI,KAAK,YAAY;QACrD,MAAM,IAAIF,MACR,CAAC,2BAA2B,EAAEH,UAAU,mFAAmF,CAAC;IAEhI;IAEA,IAAII,aAAaP,MAAM,KAAKE,SAASO,QAAQ,EAAE;QAC7C,MAAM,IAAIH,MACR,CAAC,2BAA2B,EAAEH,UAAU,kCAAkC,EAAED,SAASO,QAAQ,CAAC,IAAI,EAAEF,aAAaP,MAAM,CAAC,4DAA4D,CAAC;IAEzL;IAEA,IAAIN,QAAQgB,QAAQ,KAAKR,SAASQ,QAAQ,EAAE;QAC1C,MAAM,IAAIJ,MACR,CAAC,2BAA2B,EAAEH,UAAU,kDAAkD,EAAED,SAASQ,QAAQ,CAAC,EAAE,CAAC;IAErH;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeC,8BACpBC,KAAkC,EAClCC,OAAyF;IAEzF,IAAInB,UAAmBD,eAAeoB,QAAQnB,OAA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