@payloadcms/plugin-ecommerce 0.0.1-beta.0 → 3.57.0-internal.46327a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/addresses/createAddressesCollection.d.ts +21 -0
- package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -0
- package/dist/collections/addresses/createAddressesCollection.js +71 -0
- package/dist/collections/addresses/createAddressesCollection.js.map +1 -0
- package/dist/collections/addresses/defaultAddressFields.d.ts +3 -0
- package/dist/collections/addresses/defaultAddressFields.d.ts.map +1 -0
- package/dist/collections/addresses/defaultAddressFields.js +72 -0
- package/dist/collections/addresses/defaultAddressFields.js.map +1 -0
- package/dist/collections/addresses/defaultCountries.d.ts +9 -0
- package/dist/collections/addresses/defaultCountries.d.ts.map +1 -0
- package/dist/collections/addresses/defaultCountries.js +169 -0
- package/dist/collections/addresses/defaultCountries.js.map +1 -0
- package/dist/collections/addresses/hooks/beforeChange.d.ts +8 -0
- package/dist/collections/addresses/hooks/beforeChange.d.ts.map +1 -0
- package/dist/collections/addresses/hooks/beforeChange.js +12 -0
- package/dist/collections/addresses/hooks/beforeChange.js.map +1 -0
- package/dist/collections/carts/beforeChange.d.ts +8 -0
- package/dist/collections/carts/beforeChange.d.ts.map +1 -0
- package/dist/collections/carts/beforeChange.js +37 -0
- package/dist/collections/carts/beforeChange.js.map +1 -0
- package/dist/collections/carts/createCartsCollection.d.ts +29 -0
- package/dist/collections/carts/createCartsCollection.d.ts.map +1 -0
- package/dist/collections/carts/createCartsCollection.js +138 -0
- package/dist/collections/carts/createCartsCollection.js.map +1 -0
- package/dist/collections/carts/statusBeforeRead.d.ts +3 -0
- package/dist/collections/carts/statusBeforeRead.d.ts.map +1 -0
- package/dist/collections/carts/statusBeforeRead.js +18 -0
- package/dist/collections/carts/statusBeforeRead.js.map +1 -0
- package/dist/collections/orders/createOrdersCollection.d.ts +34 -0
- package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -0
- package/dist/collections/orders/createOrdersCollection.js +162 -0
- package/dist/collections/orders/createOrdersCollection.js.map +1 -0
- package/dist/collections/products/createProductsCollection.d.ts +26 -0
- package/dist/collections/products/createProductsCollection.d.ts.map +1 -0
- package/dist/collections/products/createProductsCollection.js +62 -0
- package/dist/collections/products/createProductsCollection.js.map +1 -0
- package/dist/collections/transactions/createTransactionsCollection.d.ts +40 -0
- package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -0
- package/dist/collections/transactions/createTransactionsCollection.js +157 -0
- package/dist/collections/transactions/createTransactionsCollection.js.map +1 -0
- package/dist/collections/variants/createVariantOptionsCollection.d.ts +15 -0
- package/dist/collections/variants/createVariantOptionsCollection.d.ts.map +1 -0
- package/dist/collections/variants/createVariantOptionsCollection.js +53 -0
- package/dist/collections/variants/createVariantOptionsCollection.js.map +1 -0
- package/dist/collections/variants/createVariantTypesCollection.d.ts +15 -0
- package/dist/collections/variants/createVariantTypesCollection.d.ts.map +1 -0
- package/dist/collections/variants/createVariantTypesCollection.js +49 -0
- package/dist/collections/variants/createVariantTypesCollection.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.d.ts +8 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.js +38 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.d.ts +7 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.js +53 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/index.d.ts +24 -0
- package/dist/collections/variants/createVariantsCollection/index.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/index.js +101 -0
- package/dist/collections/variants/createVariantsCollection/index.js.map +1 -0
- package/dist/currencies/index.d.ts +5 -0
- package/dist/currencies/index.d.ts.map +1 -0
- package/dist/currencies/index.js +20 -0
- package/dist/currencies/index.js.map +1 -0
- package/dist/endpoints/confirmOrder.d.ts +42 -0
- package/dist/endpoints/confirmOrder.d.ts.map +1 -0
- package/dist/endpoints/confirmOrder.js +143 -0
- package/dist/endpoints/confirmOrder.js.map +1 -0
- package/dist/endpoints/initiatePayment.d.ts +43 -0
- package/dist/endpoints/initiatePayment.d.ts.map +1 -0
- package/dist/endpoints/initiatePayment.js +220 -0
- package/dist/endpoints/initiatePayment.js.map +1 -0
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -0
- package/dist/exports/client/index.js +4 -0
- package/dist/exports/client/index.js.map +1 -0
- package/dist/exports/client/react.d.ts +4 -0
- package/dist/exports/client/react.d.ts.map +1 -0
- package/dist/exports/client/react.js +5 -0
- package/dist/exports/client/react.js.map +1 -0
- package/dist/exports/payments/stripe.d.ts +2 -0
- package/dist/exports/payments/stripe.d.ts.map +1 -0
- package/dist/exports/payments/stripe.js +3 -0
- package/dist/exports/payments/stripe.js.map +1 -0
- package/dist/exports/rsc.d.ts +3 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +4 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/translations.d.ts +2 -0
- package/dist/exports/translations.d.ts.map +1 -0
- package/dist/exports/translations.js +3 -0
- package/dist/exports/translations.js.map +1 -0
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/fields/amountField.d.ts +13 -0
- package/dist/fields/amountField.d.ts.map +1 -0
- package/dist/fields/amountField.js +33 -0
- package/dist/fields/amountField.js.map +1 -0
- package/dist/fields/cartItemsField.d.ts +26 -0
- package/dist/fields/cartItemsField.d.ts.map +1 -0
- package/dist/fields/cartItemsField.js +55 -0
- package/dist/fields/cartItemsField.js.map +1 -0
- package/dist/fields/currencyField.d.ts +9 -0
- package/dist/fields/currencyField.d.ts.map +1 -0
- package/dist/fields/currencyField.js +29 -0
- package/dist/fields/currencyField.js.map +1 -0
- package/dist/fields/inventoryField.d.ts +7 -0
- package/dist/fields/inventoryField.d.ts.map +1 -0
- package/dist/fields/inventoryField.js +16 -0
- package/dist/fields/inventoryField.js.map +1 -0
- package/dist/fields/pricesField.d.ts +12 -0
- package/dist/fields/pricesField.d.ts.map +1 -0
- package/dist/fields/pricesField.js +54 -0
- package/dist/fields/pricesField.js.map +1 -0
- package/dist/fields/statusField.d.ts +8 -0
- package/dist/fields/statusField.d.ts.map +1 -0
- package/dist/fields/statusField.js +49 -0
- package/dist/fields/statusField.js.map +1 -0
- package/dist/fields/variantsFields.d.ts +14 -0
- package/dist/fields/variantsFields.d.ts.map +1 -0
- package/dist/fields/variantsFields.js +48 -0
- package/dist/fields/variantsFields.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/adapters/stripe/confirmOrder.d.ts +11 -0
- package/dist/payments/adapters/stripe/confirmOrder.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/confirmOrder.js +101 -0
- package/dist/payments/adapters/stripe/confirmOrder.js.map +1 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.d.ts +13 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.js +53 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.js.map +1 -0
- package/dist/payments/adapters/stripe/index.d.ts +60 -0
- package/dist/payments/adapters/stripe/index.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/index.js +68 -0
- package/dist/payments/adapters/stripe/index.js.map +1 -0
- package/dist/payments/adapters/stripe/initiatePayment.d.ts +11 -0
- package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/initiatePayment.js +102 -0
- package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -0
- package/dist/react/provider/index.d.ts +41 -0
- package/dist/react/provider/index.d.ts.map +1 -0
- package/dist/react/provider/index.js +791 -0
- package/dist/react/provider/index.js.map +1 -0
- package/dist/react/provider/types.d.ts +171 -0
- package/dist/react/provider/types.d.ts.map +1 -0
- package/dist/react/provider/types.js +3 -0
- package/dist/react/provider/types.js.map +1 -0
- package/dist/react/provider/utilities.d.ts +9 -0
- package/dist/react/provider/utilities.d.ts.map +1 -0
- package/dist/react/provider/utilities.js +13 -0
- package/dist/react/provider/utilities.js.map +1 -0
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.d.ts.map +1 -0
- package/dist/translations/en.js +86 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/index.d.ts +7 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +6 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/types.d.ts +658 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/PriceCell/index.d.ts +12 -0
- package/dist/ui/PriceCell/index.d.ts.map +1 -0
- package/dist/ui/PriceCell/index.js +38 -0
- package/dist/ui/PriceCell/index.js.map +1 -0
- package/dist/ui/PriceInput/FormattedInput.d.ts +17 -0
- package/dist/ui/PriceInput/FormattedInput.d.ts.map +1 -0
- package/dist/ui/PriceInput/FormattedInput.js +146 -0
- package/dist/ui/PriceInput/FormattedInput.js.map +1 -0
- package/{src/ui/PriceInput/index.scss → dist/ui/PriceInput/index.css} +7 -0
- package/dist/ui/PriceInput/index.d.ts +11 -0
- package/dist/ui/PriceInput/index.d.ts.map +1 -0
- package/dist/ui/PriceInput/index.js +20 -0
- package/dist/ui/PriceInput/index.js.map +1 -0
- package/dist/ui/PriceRowLabel/index.d.ts +8 -0
- package/dist/ui/PriceRowLabel/index.d.ts.map +1 -0
- package/dist/ui/PriceRowLabel/index.js +66 -0
- package/dist/ui/PriceRowLabel/index.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.d.ts +8 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.js +28 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.d.ts +13 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.js +71 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/index.d.ts +6 -0
- package/dist/ui/VariantOptionsSelector/index.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/index.js +78 -0
- package/dist/ui/VariantOptionsSelector/index.js.map +1 -0
- package/dist/ui/utilities.d.ts +16 -0
- package/dist/ui/utilities.d.ts.map +1 -0
- package/dist/ui/utilities.js +26 -0
- package/dist/ui/utilities.js.map +1 -0
- package/dist/utilities/defaultProductsValidation.d.ts +3 -0
- package/dist/utilities/defaultProductsValidation.d.ts.map +1 -0
- package/dist/utilities/defaultProductsValidation.js +40 -0
- package/dist/utilities/defaultProductsValidation.js.map +1 -0
- package/dist/utilities/errorCodes.d.ts +3 -0
- package/dist/utilities/errorCodes.d.ts.map +1 -0
- package/dist/utilities/errorCodes.js +4 -0
- package/dist/utilities/errorCodes.js.map +1 -0
- package/dist/utilities/getCollectionSlugMap.d.ts +11 -0
- package/dist/utilities/getCollectionSlugMap.d.ts.map +1 -0
- package/dist/utilities/getCollectionSlugMap.js +25 -0
- package/dist/utilities/getCollectionSlugMap.js.map +1 -0
- package/dist/utilities/sanitizePluginConfig.d.ts +7 -0
- package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -0
- package/dist/utilities/sanitizePluginConfig.js +67 -0
- package/dist/utilities/sanitizePluginConfig.js.map +1 -0
- package/package.json +98 -1
- package/.prettierignore +0 -12
- package/.swcrc +0 -24
- package/eslint.config.js +0 -18
- package/src/addresses/addressesCollection.ts +0 -76
- package/src/addresses/defaultAddressFields.ts +0 -83
- package/src/addresses/defaultCountries.ts +0 -50
- package/src/carts/beforeChange.ts +0 -51
- package/src/carts/cartsCollection.ts +0 -146
- package/src/currencies/index.ts +0 -29
- package/src/endpoints/confirmOrder.ts +0 -312
- package/src/endpoints/initiatePayment.ts +0 -322
- package/src/exports/addresses.ts +0 -2
- package/src/exports/currencies.ts +0 -1
- package/src/exports/fields.ts +0 -5
- package/src/exports/orders.ts +0 -1
- package/src/exports/payments/stripe.ts +0 -1
- package/src/exports/plugin.ts +0 -1
- package/src/exports/products.ts +0 -1
- package/src/exports/react.ts +0 -8
- package/src/exports/transactions.ts +0 -1
- package/src/exports/translations.ts +0 -1
- package/src/exports/types.ts +0 -7
- package/src/exports/ui.ts +0 -3
- package/src/exports/variants.ts +0 -5
- package/src/fields/amountField.ts +0 -43
- package/src/fields/cartItemsField.ts +0 -84
- package/src/fields/currencyField.ts +0 -39
- package/src/fields/inventoryField.ts +0 -22
- package/src/fields/pricesField.ts +0 -65
- package/src/fields/statusField.ts +0 -57
- package/src/fields/variantsFields.ts +0 -56
- package/src/index.ts +0 -275
- package/src/orders/ordersCollection.ts +0 -157
- package/src/payments/adapters/stripe/confirmOrder.ts +0 -123
- package/src/payments/adapters/stripe/endpoints/webhooks.ts +0 -69
- package/src/payments/adapters/stripe/index.ts +0 -135
- package/src/payments/adapters/stripe/initiatePayment.ts +0 -131
- package/src/products/productsCollection.ts +0 -78
- package/src/react/provider/index.tsx +0 -893
- package/src/react/provider/types.ts +0 -184
- package/src/react/provider/utilities.ts +0 -22
- package/src/transactions/transactionsCollection.ts +0 -166
- package/src/translations/en.ts +0 -64
- package/src/translations/index.ts +0 -11
- package/src/types.ts +0 -403
- package/src/ui/PriceInput/FormattedInput.tsx +0 -134
- package/src/ui/PriceInput/index.tsx +0 -43
- package/src/ui/PriceInput/utilities.ts +0 -46
- package/src/ui/PriceRowLabel/index.tsx +0 -56
- package/src/ui/VariantOptionsSelector/ErrorBox.tsx +0 -27
- package/src/ui/VariantOptionsSelector/OptionsSelect.tsx +0 -78
- package/src/ui/VariantOptionsSelector/index.tsx +0 -83
- package/src/utilities/defaultProductsValidation.ts +0 -42
- package/src/utilities/errorCodes.ts +0 -14
- package/src/utilities/getCollectionSlugMap.ts +0 -84
- package/src/utilities/sanitizePluginConfig.ts +0 -80
- package/src/variants/variantOptionsCollection.ts +0 -59
- package/src/variants/variantTypesCollection.ts +0 -55
- package/src/variants/variantsCollection/hooks/beforeChange.ts +0 -47
- package/src/variants/variantsCollection/hooks/validateOptions.ts +0 -72
- package/src/variants/variantsCollection/index.ts +0 -119
- package/tsconfig.json +0 -7
- package/tsconfig.tsbuildinfo +0 -1
- /package/{src → dist}/translations/translation-schema.json +0 -0
- /package/{src → dist}/ui/PriceRowLabel/index.css +0 -0
- /package/{src → dist}/ui/VariantOptionsSelector/index.css +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { deepMergeSimple } from 'payload/shared';
|
|
2
|
+
import { createAddressesCollection } from './collections/addresses/createAddressesCollection.js';
|
|
3
|
+
import { createCartsCollection } from './collections/carts/createCartsCollection.js';
|
|
4
|
+
import { createOrdersCollection } from './collections/orders/createOrdersCollection.js';
|
|
5
|
+
import { createProductsCollection } from './collections/products/createProductsCollection.js';
|
|
6
|
+
import { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js';
|
|
7
|
+
import { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js';
|
|
8
|
+
import { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js';
|
|
9
|
+
import { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js';
|
|
10
|
+
import { confirmOrderHandler } from './endpoints/confirmOrder.js';
|
|
11
|
+
import { initiatePaymentHandler } from './endpoints/initiatePayment.js';
|
|
12
|
+
import { translations } from './translations/index.js';
|
|
13
|
+
import { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js';
|
|
14
|
+
import { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js';
|
|
15
|
+
export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
|
|
16
|
+
if (!pluginConfig) {
|
|
17
|
+
return incomingConfig;
|
|
18
|
+
}
|
|
19
|
+
const sanitizedPluginConfig = sanitizePluginConfig({
|
|
20
|
+
pluginConfig
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Used to keep track of the slugs of collections in case they are overridden by the user.
|
|
24
|
+
*/ const collectionSlugMap = getCollectionSlugMap({
|
|
25
|
+
sanitizedPluginConfig
|
|
26
|
+
});
|
|
27
|
+
const accessConfig = sanitizedPluginConfig.access;
|
|
28
|
+
// Ensure collections exists
|
|
29
|
+
if (!incomingConfig.collections) {
|
|
30
|
+
incomingConfig.collections = [];
|
|
31
|
+
}
|
|
32
|
+
// Controls whether variants are enabled in the plugin. This is toggled to true under products config
|
|
33
|
+
let enableVariants = false;
|
|
34
|
+
const currenciesConfig = sanitizedPluginConfig.currencies;
|
|
35
|
+
let addressFields;
|
|
36
|
+
if (sanitizedPluginConfig.addresses) {
|
|
37
|
+
addressFields = sanitizedPluginConfig.addresses.addressFields;
|
|
38
|
+
const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries;
|
|
39
|
+
const defaultAddressesCollection = createAddressesCollection({
|
|
40
|
+
access: {
|
|
41
|
+
adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,
|
|
42
|
+
authenticatedOnly: accessConfig.authenticatedOnly,
|
|
43
|
+
customerOnlyFieldAccess: accessConfig.customerOnlyFieldAccess
|
|
44
|
+
},
|
|
45
|
+
addressFields,
|
|
46
|
+
customersSlug: collectionSlugMap.customers,
|
|
47
|
+
supportedCountries
|
|
48
|
+
});
|
|
49
|
+
const addressesCollection = sanitizedPluginConfig.addresses && typeof sanitizedPluginConfig.addresses === 'object' && 'addressesCollectionOverride' in sanitizedPluginConfig.addresses && sanitizedPluginConfig.addresses.addressesCollectionOverride ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({
|
|
50
|
+
defaultCollection: defaultAddressesCollection
|
|
51
|
+
}) : defaultAddressesCollection;
|
|
52
|
+
incomingConfig.collections.push(addressesCollection);
|
|
53
|
+
}
|
|
54
|
+
if (sanitizedPluginConfig.products) {
|
|
55
|
+
const productsConfig = typeof sanitizedPluginConfig.products === 'boolean' ? {
|
|
56
|
+
variants: true
|
|
57
|
+
} : sanitizedPluginConfig.products;
|
|
58
|
+
enableVariants = Boolean(productsConfig.variants);
|
|
59
|
+
if (productsConfig.variants) {
|
|
60
|
+
const variantsConfig = typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants;
|
|
61
|
+
const defaultVariantsCollection = createVariantsCollection({
|
|
62
|
+
access: {
|
|
63
|
+
adminOnly: accessConfig.adminOnly,
|
|
64
|
+
adminOrPublishedStatus: accessConfig.adminOrPublishedStatus
|
|
65
|
+
},
|
|
66
|
+
currenciesConfig,
|
|
67
|
+
inventory: sanitizedPluginConfig.inventory,
|
|
68
|
+
productsSlug: collectionSlugMap.products,
|
|
69
|
+
variantOptionsSlug: collectionSlugMap.variantOptions
|
|
70
|
+
});
|
|
71
|
+
const variants = variantsConfig && typeof variantsConfig === 'object' && 'variantsCollectionOverride' in variantsConfig && variantsConfig.variantsCollectionOverride ? await variantsConfig.variantsCollectionOverride({
|
|
72
|
+
defaultCollection: defaultVariantsCollection
|
|
73
|
+
}) : defaultVariantsCollection;
|
|
74
|
+
const defaultVariantTypesCollection = createVariantTypesCollection({
|
|
75
|
+
access: {
|
|
76
|
+
adminOnly: accessConfig.adminOnly,
|
|
77
|
+
publicAccess: accessConfig.publicAccess
|
|
78
|
+
},
|
|
79
|
+
variantOptionsSlug: collectionSlugMap.variantOptions
|
|
80
|
+
});
|
|
81
|
+
const variantTypes = variantsConfig && typeof variantsConfig === 'object' && 'variantTypesCollectionOverride' in variantsConfig && variantsConfig.variantTypesCollectionOverride ? await variantsConfig.variantTypesCollectionOverride({
|
|
82
|
+
defaultCollection: defaultVariantTypesCollection
|
|
83
|
+
}) : defaultVariantTypesCollection;
|
|
84
|
+
const defaultVariantOptionsCollection = createVariantOptionsCollection({
|
|
85
|
+
access: {
|
|
86
|
+
adminOnly: accessConfig.adminOnly,
|
|
87
|
+
publicAccess: accessConfig.publicAccess
|
|
88
|
+
},
|
|
89
|
+
variantTypesSlug: collectionSlugMap.variantTypes
|
|
90
|
+
});
|
|
91
|
+
const variantOptions = variantsConfig && typeof variantsConfig === 'object' && 'variantOptionsCollectionOverride' in variantsConfig && variantsConfig.variantOptionsCollectionOverride ? await variantsConfig.variantOptionsCollectionOverride({
|
|
92
|
+
defaultCollection: defaultVariantOptionsCollection
|
|
93
|
+
}) : defaultVariantOptionsCollection;
|
|
94
|
+
incomingConfig.collections.push(variants, variantTypes, variantOptions);
|
|
95
|
+
}
|
|
96
|
+
const defaultProductsCollection = createProductsCollection({
|
|
97
|
+
access: {
|
|
98
|
+
adminOnly: accessConfig.adminOnly,
|
|
99
|
+
adminOrPublishedStatus: accessConfig.adminOrPublishedStatus
|
|
100
|
+
},
|
|
101
|
+
currenciesConfig,
|
|
102
|
+
enableVariants,
|
|
103
|
+
inventory: sanitizedPluginConfig.inventory,
|
|
104
|
+
variantsSlug: collectionSlugMap.variants,
|
|
105
|
+
variantTypesSlug: collectionSlugMap.variantTypes
|
|
106
|
+
});
|
|
107
|
+
const productsCollection = productsConfig && 'productsCollectionOverride' in productsConfig && productsConfig.productsCollectionOverride ? await productsConfig.productsCollectionOverride({
|
|
108
|
+
defaultCollection: defaultProductsCollection
|
|
109
|
+
}) : defaultProductsCollection;
|
|
110
|
+
incomingConfig.collections.push(productsCollection);
|
|
111
|
+
if (sanitizedPluginConfig.carts) {
|
|
112
|
+
const defaultCartsCollection = createCartsCollection({
|
|
113
|
+
access: {
|
|
114
|
+
adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,
|
|
115
|
+
publicAccess: accessConfig.publicAccess
|
|
116
|
+
},
|
|
117
|
+
currenciesConfig,
|
|
118
|
+
customersSlug: collectionSlugMap.customers,
|
|
119
|
+
enableVariants: Boolean(productsConfig.variants),
|
|
120
|
+
productsSlug: collectionSlugMap.products,
|
|
121
|
+
variantsSlug: collectionSlugMap.variants
|
|
122
|
+
});
|
|
123
|
+
const cartsCollection = sanitizedPluginConfig.carts && typeof sanitizedPluginConfig.carts === 'object' && 'cartsCollectionOverride' in sanitizedPluginConfig.carts && sanitizedPluginConfig.carts.cartsCollectionOverride ? await sanitizedPluginConfig.carts.cartsCollectionOverride({
|
|
124
|
+
defaultCollection: defaultCartsCollection
|
|
125
|
+
}) : defaultCartsCollection;
|
|
126
|
+
incomingConfig.collections.push(cartsCollection);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (sanitizedPluginConfig.orders) {
|
|
130
|
+
const defaultOrdersCollection = createOrdersCollection({
|
|
131
|
+
access: {
|
|
132
|
+
adminOnly: accessConfig.adminOnly,
|
|
133
|
+
adminOnlyFieldAccess: accessConfig.adminOnlyFieldAccess,
|
|
134
|
+
adminOrCustomerOwner: accessConfig.adminOrCustomerOwner
|
|
135
|
+
},
|
|
136
|
+
addressFields,
|
|
137
|
+
currenciesConfig,
|
|
138
|
+
customersSlug: collectionSlugMap.customers,
|
|
139
|
+
enableVariants,
|
|
140
|
+
productsSlug: collectionSlugMap.products,
|
|
141
|
+
variantsSlug: collectionSlugMap.variants
|
|
142
|
+
});
|
|
143
|
+
const ordersCollection = sanitizedPluginConfig.orders && typeof sanitizedPluginConfig.orders === 'object' && 'ordersCollectionOverride' in sanitizedPluginConfig.orders && sanitizedPluginConfig.orders.ordersCollectionOverride ? await sanitizedPluginConfig.orders.ordersCollectionOverride({
|
|
144
|
+
defaultCollection: defaultOrdersCollection
|
|
145
|
+
}) : defaultOrdersCollection;
|
|
146
|
+
incomingConfig.collections.push(ordersCollection);
|
|
147
|
+
}
|
|
148
|
+
const paymentMethods = sanitizedPluginConfig.payments.paymentMethods;
|
|
149
|
+
if (sanitizedPluginConfig.payments) {
|
|
150
|
+
if (paymentMethods.length) {
|
|
151
|
+
if (!Array.isArray(incomingConfig.endpoints)) {
|
|
152
|
+
incomingConfig.endpoints = [];
|
|
153
|
+
}
|
|
154
|
+
const productsValidation = typeof sanitizedPluginConfig.products === 'object' && sanitizedPluginConfig.products.validation || undefined;
|
|
155
|
+
paymentMethods.forEach((paymentMethod)=>{
|
|
156
|
+
const methodPath = `/payments/${paymentMethod.name}`;
|
|
157
|
+
const endpoints = [];
|
|
158
|
+
const initiatePayment = {
|
|
159
|
+
handler: initiatePaymentHandler({
|
|
160
|
+
currenciesConfig,
|
|
161
|
+
inventory: sanitizedPluginConfig.inventory,
|
|
162
|
+
paymentMethod,
|
|
163
|
+
productsSlug: collectionSlugMap.products,
|
|
164
|
+
productsValidation,
|
|
165
|
+
transactionsSlug: collectionSlugMap.transactions,
|
|
166
|
+
variantsSlug: collectionSlugMap.variants
|
|
167
|
+
}),
|
|
168
|
+
method: 'post',
|
|
169
|
+
path: `${methodPath}/initiate`
|
|
170
|
+
};
|
|
171
|
+
const confirmOrder = {
|
|
172
|
+
handler: confirmOrderHandler({
|
|
173
|
+
cartsSlug: collectionSlugMap.carts,
|
|
174
|
+
currenciesConfig,
|
|
175
|
+
ordersSlug: collectionSlugMap.orders,
|
|
176
|
+
paymentMethod,
|
|
177
|
+
productsValidation,
|
|
178
|
+
transactionsSlug: collectionSlugMap.transactions
|
|
179
|
+
}),
|
|
180
|
+
method: 'post',
|
|
181
|
+
path: `${methodPath}/confirm-order`
|
|
182
|
+
};
|
|
183
|
+
endpoints.push(initiatePayment, confirmOrder);
|
|
184
|
+
// Attach any additional endpoints defined in the payment method
|
|
185
|
+
if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {
|
|
186
|
+
const methodEndpoints = paymentMethod.endpoints.map((endpoint)=>{
|
|
187
|
+
const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`;
|
|
188
|
+
return {
|
|
189
|
+
...endpoint,
|
|
190
|
+
path: `${methodPath}${path}`
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
endpoints.push(...methodEndpoints);
|
|
194
|
+
}
|
|
195
|
+
incomingConfig.endpoints.push(...endpoints);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (sanitizedPluginConfig.transactions) {
|
|
200
|
+
const defaultTransactionsCollection = createTransactionsCollection({
|
|
201
|
+
access: {
|
|
202
|
+
adminOnly: accessConfig.adminOnly
|
|
203
|
+
},
|
|
204
|
+
addressFields,
|
|
205
|
+
cartsSlug: collectionSlugMap.carts,
|
|
206
|
+
currenciesConfig,
|
|
207
|
+
customersSlug: collectionSlugMap.customers,
|
|
208
|
+
enableVariants,
|
|
209
|
+
ordersSlug: collectionSlugMap.orders,
|
|
210
|
+
paymentMethods,
|
|
211
|
+
productsSlug: collectionSlugMap.products,
|
|
212
|
+
variantsSlug: collectionSlugMap.variants
|
|
213
|
+
});
|
|
214
|
+
const transactionsCollection = sanitizedPluginConfig.transactions && typeof sanitizedPluginConfig.transactions === 'object' && 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions && sanitizedPluginConfig.transactions.transactionsCollectionOverride ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({
|
|
215
|
+
defaultCollection: defaultTransactionsCollection
|
|
216
|
+
}) : defaultTransactionsCollection;
|
|
217
|
+
incomingConfig.collections.push(transactionsCollection);
|
|
218
|
+
}
|
|
219
|
+
if (!incomingConfig.i18n) {
|
|
220
|
+
incomingConfig.i18n = {};
|
|
221
|
+
}
|
|
222
|
+
if (!incomingConfig.i18n?.translations) {
|
|
223
|
+
incomingConfig.i18n.translations = {};
|
|
224
|
+
}
|
|
225
|
+
incomingConfig.i18n.translations = deepMergeSimple(translations, incomingConfig.i18n?.translations);
|
|
226
|
+
return {
|
|
227
|
+
...incomingConfig
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
export { createAddressesCollection, createCartsCollection, createOrdersCollection, createProductsCollection, createTransactionsCollection, createVariantOptionsCollection, createVariantsCollection, createVariantTypesCollection, };
|
|
231
|
+
export { EUR, GBP, USD } from './currencies/index.js';
|
|
232
|
+
export { amountField } from './fields/amountField.js';
|
|
233
|
+
export { currencyField } from './fields/currencyField.js';
|
|
234
|
+
export { pricesField } from './fields/pricesField.js';
|
|
235
|
+
export { statusField } from './fields/statusField.js';
|
|
236
|
+
export { variantsFields } from './fields/variantsFields.js';
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from './types.js'\n\nimport { createAddressesCollection } from './collections/addresses/createAddressesCollection.js'\nimport { createCartsCollection } from './collections/carts/createCartsCollection.js'\nimport { createOrdersCollection } from './collections/orders/createOrdersCollection.js'\nimport { createProductsCollection } from './collections/products/createProductsCollection.js'\nimport { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js'\nimport { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js'\nimport { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js'\nimport { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js'\nimport { confirmOrderHandler } from './endpoints/confirmOrder.js'\nimport { initiatePaymentHandler } from './endpoints/initiatePayment.js'\nimport { translations } from './translations/index.js'\nimport { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js'\nimport { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js'\n\nexport const ecommercePlugin =\n (pluginConfig?: EcommercePluginConfig) =>\n async (incomingConfig: Config): Promise<Config> => {\n if (!pluginConfig) {\n return incomingConfig\n }\n\n const sanitizedPluginConfig = sanitizePluginConfig({ pluginConfig })\n /**\n * Used to keep track of the slugs of collections in case they are overridden by the user.\n */\n const collectionSlugMap = getCollectionSlugMap({ sanitizedPluginConfig })\n\n const accessConfig = sanitizedPluginConfig.access\n\n // Ensure collections exists\n if (!incomingConfig.collections) {\n incomingConfig.collections = []\n }\n\n // Controls whether variants are enabled in the plugin. This is toggled to true under products config\n let enableVariants = false\n\n const currenciesConfig: Required<SanitizedEcommercePluginConfig['currencies']> =\n sanitizedPluginConfig.currencies\n\n let addressFields\n\n if (sanitizedPluginConfig.addresses) {\n addressFields = sanitizedPluginConfig.addresses.addressFields\n\n const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries\n\n const defaultAddressesCollection = createAddressesCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n authenticatedOnly: accessConfig.authenticatedOnly,\n customerOnlyFieldAccess: accessConfig.customerOnlyFieldAccess,\n },\n addressFields,\n customersSlug: collectionSlugMap.customers,\n supportedCountries,\n })\n\n const addressesCollection =\n sanitizedPluginConfig.addresses &&\n typeof sanitizedPluginConfig.addresses === 'object' &&\n 'addressesCollectionOverride' in sanitizedPluginConfig.addresses &&\n sanitizedPluginConfig.addresses.addressesCollectionOverride\n ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({\n defaultCollection: defaultAddressesCollection,\n })\n : defaultAddressesCollection\n\n incomingConfig.collections.push(addressesCollection)\n }\n\n if (sanitizedPluginConfig.products) {\n const productsConfig =\n typeof sanitizedPluginConfig.products === 'boolean'\n ? {\n variants: true,\n }\n : sanitizedPluginConfig.products\n\n enableVariants = Boolean(productsConfig.variants)\n\n if (productsConfig.variants) {\n const variantsConfig =\n typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants\n\n const defaultVariantsCollection = createVariantsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n productsSlug: collectionSlugMap.products,\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variants =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantsCollectionOverride' in variantsConfig &&\n variantsConfig.variantsCollectionOverride\n ? await variantsConfig.variantsCollectionOverride({\n defaultCollection: defaultVariantsCollection,\n })\n : defaultVariantsCollection\n\n const defaultVariantTypesCollection = createVariantTypesCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variantTypes =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantTypesCollectionOverride' in variantsConfig &&\n variantsConfig.variantTypesCollectionOverride\n ? await variantsConfig.variantTypesCollectionOverride({\n defaultCollection: defaultVariantTypesCollection,\n })\n : defaultVariantTypesCollection\n\n const defaultVariantOptionsCollection = createVariantOptionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const variantOptions =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantOptionsCollectionOverride' in variantsConfig &&\n variantsConfig.variantOptionsCollectionOverride\n ? await variantsConfig.variantOptionsCollectionOverride({\n defaultCollection: defaultVariantOptionsCollection,\n })\n : defaultVariantOptionsCollection\n\n incomingConfig.collections.push(variants, variantTypes, variantOptions)\n }\n\n const defaultProductsCollection = createProductsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n enableVariants,\n inventory: sanitizedPluginConfig.inventory,\n variantsSlug: collectionSlugMap.variants,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const productsCollection =\n productsConfig &&\n 'productsCollectionOverride' in productsConfig &&\n productsConfig.productsCollectionOverride\n ? await productsConfig.productsCollectionOverride({\n defaultCollection: defaultProductsCollection,\n })\n : defaultProductsCollection\n\n incomingConfig.collections.push(productsCollection)\n\n if (sanitizedPluginConfig.carts) {\n const defaultCartsCollection = createCartsCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n publicAccess: accessConfig.publicAccess,\n },\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants: Boolean(productsConfig.variants),\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const cartsCollection =\n sanitizedPluginConfig.carts &&\n typeof sanitizedPluginConfig.carts === 'object' &&\n 'cartsCollectionOverride' in sanitizedPluginConfig.carts &&\n sanitizedPluginConfig.carts.cartsCollectionOverride\n ? await sanitizedPluginConfig.carts.cartsCollectionOverride({\n defaultCollection: defaultCartsCollection,\n })\n : defaultCartsCollection\n\n incomingConfig.collections.push(cartsCollection)\n }\n }\n\n if (sanitizedPluginConfig.orders) {\n const defaultOrdersCollection = createOrdersCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOnlyFieldAccess: accessConfig.adminOnlyFieldAccess,\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n },\n addressFields,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const ordersCollection =\n sanitizedPluginConfig.orders &&\n typeof sanitizedPluginConfig.orders === 'object' &&\n 'ordersCollectionOverride' in sanitizedPluginConfig.orders &&\n sanitizedPluginConfig.orders.ordersCollectionOverride\n ? await sanitizedPluginConfig.orders.ordersCollectionOverride({\n defaultCollection: defaultOrdersCollection,\n })\n : defaultOrdersCollection\n\n incomingConfig.collections.push(ordersCollection)\n }\n\n const paymentMethods = sanitizedPluginConfig.payments.paymentMethods\n\n if (sanitizedPluginConfig.payments) {\n if (paymentMethods.length) {\n if (!Array.isArray(incomingConfig.endpoints)) {\n incomingConfig.endpoints = []\n }\n\n const productsValidation =\n (typeof sanitizedPluginConfig.products === 'object' &&\n sanitizedPluginConfig.products.validation) ||\n undefined\n\n paymentMethods.forEach((paymentMethod) => {\n const methodPath = `/payments/${paymentMethod.name}`\n const endpoints: Endpoint[] = []\n\n const initiatePayment: Endpoint = {\n handler: initiatePaymentHandler({\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants,\n }),\n method: 'post',\n path: `${methodPath}/initiate`,\n }\n\n const confirmOrder: Endpoint = {\n handler: confirmOrderHandler({\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n ordersSlug: collectionSlugMap.orders,\n paymentMethod,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n }),\n method: 'post',\n path: `${methodPath}/confirm-order`,\n }\n\n endpoints.push(initiatePayment, confirmOrder)\n\n // Attach any additional endpoints defined in the payment method\n if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {\n const methodEndpoints = paymentMethod.endpoints.map((endpoint) => {\n const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`\n\n return {\n ...endpoint,\n path: `${methodPath}${path}`,\n }\n })\n\n endpoints.push(...methodEndpoints)\n }\n\n incomingConfig.endpoints!.push(...endpoints)\n })\n }\n }\n\n if (sanitizedPluginConfig.transactions) {\n const defaultTransactionsCollection = createTransactionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n },\n addressFields,\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n ordersSlug: collectionSlugMap.orders,\n paymentMethods,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const transactionsCollection =\n sanitizedPluginConfig.transactions &&\n typeof sanitizedPluginConfig.transactions === 'object' &&\n 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions &&\n sanitizedPluginConfig.transactions.transactionsCollectionOverride\n ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({\n defaultCollection: defaultTransactionsCollection,\n })\n : defaultTransactionsCollection\n\n incomingConfig.collections.push(transactionsCollection)\n }\n\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n\n if (!incomingConfig.i18n?.translations) {\n incomingConfig.i18n.translations = {}\n }\n\n incomingConfig.i18n.translations = deepMergeSimple(\n translations,\n incomingConfig.i18n?.translations,\n )\n\n return {\n ...incomingConfig,\n }\n }\n\nexport {\n createAddressesCollection,\n createCartsCollection,\n createOrdersCollection,\n createProductsCollection,\n createTransactionsCollection,\n createVariantOptionsCollection,\n createVariantsCollection,\n createVariantTypesCollection,\n}\n\nexport { EUR, GBP, USD } from './currencies/index.js'\nexport { amountField } from './fields/amountField.js'\nexport { currencyField } from './fields/currencyField.js'\nexport { pricesField } from './fields/pricesField.js'\nexport { statusField } from './fields/statusField.js'\nexport { variantsFields } from './fields/variantsFields.js'\n"],"names":["deepMergeSimple","createAddressesCollection","createCartsCollection","createOrdersCollection","createProductsCollection","createTransactionsCollection","createVariantOptionsCollection","createVariantsCollection","createVariantTypesCollection","confirmOrderHandler","initiatePaymentHandler","translations","getCollectionSlugMap","sanitizePluginConfig","ecommercePlugin","pluginConfig","incomingConfig","sanitizedPluginConfig","collectionSlugMap","accessConfig","access","collections","enableVariants","currenciesConfig","currencies","addressFields","addresses","supportedCountries","defaultAddressesCollection","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","customersSlug","customers","addressesCollection","addressesCollectionOverride","defaultCollection","push","products","productsConfig","variants","Boolean","variantsConfig","undefined","defaultVariantsCollection","adminOnly","adminOrPublishedStatus","inventory","productsSlug","variantOptionsSlug","variantOptions","variantsCollectionOverride","defaultVariantTypesCollection","publicAccess","variantTypes","variantTypesCollectionOverride","defaultVariantOptionsCollection","variantTypesSlug","variantOptionsCollectionOverride","defaultProductsCollection","variantsSlug","productsCollection","productsCollectionOverride","carts","defaultCartsCollection","cartsCollection","cartsCollectionOverride","orders","defaultOrdersCollection","adminOnlyFieldAccess","ordersCollection","ordersCollectionOverride","paymentMethods","payments","length","Array","isArray","endpoints","productsValidation","validation","forEach","paymentMethod","methodPath","name","initiatePayment","handler","transactionsSlug","transactions","method","path","confirmOrder","cartsSlug","ordersSlug","methodEndpoints","map","endpoint","startsWith","defaultTransactionsCollection","transactionsCollection","transactionsCollectionOverride","i18n","EUR","GBP","USD","amountField","currencyField","pricesField","statusField","variantsFields"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAIhD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,sBAAsB,QAAQ,iDAAgD;AACvF,SAASC,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,4BAA4B,QAAQ,6DAA4D;AACzG,SAASC,8BAA8B,QAAQ,2DAA0D;AACzG,SAASC,wBAAwB,QAAQ,2DAA0D;AACnG,SAASC,4BAA4B,QAAQ,yDAAwD;AACrG,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,MAAMC,kBACX,CAACC,eACD,OAAOC;QACL,IAAI,CAACD,cAAc;YACjB,OAAOC;QACT;QAEA,MAAMC,wBAAwBJ,qBAAqB;YAAEE;QAAa;QAClE;;KAEC,GACD,MAAMG,oBAAoBN,qBAAqB;YAAEK;QAAsB;QAEvE,MAAME,eAAeF,sBAAsBG,MAAM;QAEjD,4BAA4B;QAC5B,IAAI,CAACJ,eAAeK,WAAW,EAAE;YAC/BL,eAAeK,WAAW,GAAG,EAAE;QACjC;QAEA,qGAAqG;QACrG,IAAIC,iBAAiB;QAErB,MAAMC,mBACJN,sBAAsBO,UAAU;QAElC,IAAIC;QAEJ,IAAIR,sBAAsBS,SAAS,EAAE;YACnCD,gBAAgBR,sBAAsBS,SAAS,CAACD,aAAa;YAE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,EAAEC,GAAG,EAAEC,GAAG,QAAQ,wBAAuB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,cAAc,QAAQ,6BAA4B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import type { PaymentAdapter } from '../../../types.js';
|
|
3
|
+
import type { StripeAdapterArgs } from './index.js';
|
|
4
|
+
type Props = {
|
|
5
|
+
apiVersion?: Stripe.StripeConfig['apiVersion'];
|
|
6
|
+
appInfo?: Stripe.StripeConfig['appInfo'];
|
|
7
|
+
secretKey: StripeAdapterArgs['secretKey'];
|
|
8
|
+
};
|
|
9
|
+
export declare const confirmOrder: (props: Props) => NonNullable<PaymentAdapter>['confirmOrder'];
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=confirmOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmOrder.d.ts","sourceRoot":"","sources":["../../../../src/payments/adapters/stripe/confirmOrder.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACxC,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,cAAc,CAwHpF,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
export const confirmOrder = (props)=>async ({ data, ordersSlug = 'orders', req, transactionsSlug = 'transactions' })=>{
|
|
3
|
+
const payload = req.payload;
|
|
4
|
+
const { apiVersion, appInfo, secretKey } = props || {};
|
|
5
|
+
const customerEmail = data.customerEmail;
|
|
6
|
+
const paymentIntentID = data.paymentIntentID;
|
|
7
|
+
if (!secretKey) {
|
|
8
|
+
throw new Error('Stripe secret key is required');
|
|
9
|
+
}
|
|
10
|
+
if (!paymentIntentID) {
|
|
11
|
+
throw new Error('PaymentIntent ID is required');
|
|
12
|
+
}
|
|
13
|
+
const stripe = new Stripe(secretKey, {
|
|
14
|
+
// API version can only be the latest, stripe recommends ts ignoring it
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised
|
|
17
|
+
apiVersion: apiVersion || '2025-03-31.basil',
|
|
18
|
+
appInfo: appInfo || {
|
|
19
|
+
name: 'Stripe Payload Plugin',
|
|
20
|
+
url: 'https://payloadcms.com'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
let customer = (await stripe.customers.list({
|
|
25
|
+
email: customerEmail
|
|
26
|
+
})).data[0];
|
|
27
|
+
if (!customer?.id) {
|
|
28
|
+
customer = await stripe.customers.create({
|
|
29
|
+
email: customerEmail
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Find our existing transaction by the payment intent ID
|
|
33
|
+
const transactionsResults = await payload.find({
|
|
34
|
+
collection: transactionsSlug,
|
|
35
|
+
where: {
|
|
36
|
+
'stripe.paymentIntentID': {
|
|
37
|
+
equals: paymentIntentID
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const transaction = transactionsResults.docs[0];
|
|
42
|
+
if (!transactionsResults.totalDocs || !transaction) {
|
|
43
|
+
throw new Error('No transaction found for the provided PaymentIntent ID');
|
|
44
|
+
}
|
|
45
|
+
// Verify the payment intent exists and retrieve it
|
|
46
|
+
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentID);
|
|
47
|
+
const cartID = paymentIntent.metadata.cartID;
|
|
48
|
+
const cartItemsSnapshot = paymentIntent.metadata.cartItemsSnapshot ? JSON.parse(paymentIntent.metadata.cartItemsSnapshot) : undefined;
|
|
49
|
+
const shippingAddress = paymentIntent.metadata.shippingAddress ? JSON.parse(paymentIntent.metadata.shippingAddress) : undefined;
|
|
50
|
+
if (!cartID) {
|
|
51
|
+
throw new Error('Cart ID not found in the PaymentIntent metadata');
|
|
52
|
+
}
|
|
53
|
+
if (!cartItemsSnapshot || !Array.isArray(cartItemsSnapshot)) {
|
|
54
|
+
throw new Error('Cart items snapshot not found or invalid in the PaymentIntent metadata');
|
|
55
|
+
}
|
|
56
|
+
const order = await payload.create({
|
|
57
|
+
collection: ordersSlug,
|
|
58
|
+
data: {
|
|
59
|
+
amount: paymentIntent.amount,
|
|
60
|
+
currency: paymentIntent.currency.toUpperCase(),
|
|
61
|
+
...req.user ? {
|
|
62
|
+
customer: req.user.id
|
|
63
|
+
} : {
|
|
64
|
+
customerEmail
|
|
65
|
+
},
|
|
66
|
+
items: cartItemsSnapshot,
|
|
67
|
+
shippingAddress,
|
|
68
|
+
status: 'processing',
|
|
69
|
+
transactions: [
|
|
70
|
+
transaction.id
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const timestamp = new Date().toISOString();
|
|
75
|
+
await payload.update({
|
|
76
|
+
id: cartID,
|
|
77
|
+
collection: 'carts',
|
|
78
|
+
data: {
|
|
79
|
+
purchasedAt: timestamp
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
await payload.update({
|
|
83
|
+
id: transaction.id,
|
|
84
|
+
collection: transactionsSlug,
|
|
85
|
+
data: {
|
|
86
|
+
order: order.id,
|
|
87
|
+
status: 'succeeded'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
message: 'Payment initiated successfully',
|
|
92
|
+
orderID: order.id,
|
|
93
|
+
transactionID: transaction.id
|
|
94
|
+
};
|
|
95
|
+
} catch (error) {
|
|
96
|
+
payload.logger.error(error, 'Error initiating payment with Stripe');
|
|
97
|
+
throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment');
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=confirmOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/payments/adapters/stripe/confirmOrder.ts"],"sourcesContent":["import Stripe from 'stripe'\n\nimport type { PaymentAdapter } from '../../../types.js'\nimport type { StripeAdapterArgs } from './index.js'\n\ntype Props = {\n apiVersion?: Stripe.StripeConfig['apiVersion']\n appInfo?: Stripe.StripeConfig['appInfo']\n secretKey: StripeAdapterArgs['secretKey']\n}\n\nexport const confirmOrder: (props: Props) => NonNullable<PaymentAdapter>['confirmOrder'] =\n (props) =>\n async ({ data, ordersSlug = 'orders', req, transactionsSlug = 'transactions' }) => {\n const payload = req.payload\n const { apiVersion, appInfo, secretKey } = props || {}\n\n const customerEmail = data.customerEmail\n\n const paymentIntentID = data.paymentIntentID as string\n\n if (!secretKey) {\n throw new Error('Stripe secret key is required')\n }\n\n if (!paymentIntentID) {\n throw new Error('PaymentIntent ID is required')\n }\n\n const stripe = new Stripe(secretKey, {\n // API version can only be the latest, stripe recommends ts ignoring it\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised\n apiVersion: apiVersion || '2025-03-31.basil',\n appInfo: appInfo || {\n name: 'Stripe Payload Plugin',\n url: 'https://payloadcms.com',\n },\n })\n\n try {\n let customer = (\n await stripe.customers.list({\n email: customerEmail,\n })\n ).data[0]\n\n if (!customer?.id) {\n customer = await stripe.customers.create({\n email: customerEmail,\n })\n }\n\n // Find our existing transaction by the payment intent ID\n const transactionsResults = await payload.find({\n collection: transactionsSlug,\n where: {\n 'stripe.paymentIntentID': {\n equals: paymentIntentID,\n },\n },\n })\n\n const transaction = transactionsResults.docs[0]\n\n if (!transactionsResults.totalDocs || !transaction) {\n throw new Error('No transaction found for the provided PaymentIntent ID')\n }\n\n // Verify the payment intent exists and retrieve it\n const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentID)\n\n const cartID = paymentIntent.metadata.cartID\n const cartItemsSnapshot = paymentIntent.metadata.cartItemsSnapshot\n ? JSON.parse(paymentIntent.metadata.cartItemsSnapshot)\n : undefined\n\n const shippingAddress = paymentIntent.metadata.shippingAddress\n ? JSON.parse(paymentIntent.metadata.shippingAddress)\n : undefined\n\n if (!cartID) {\n throw new Error('Cart ID not found in the PaymentIntent metadata')\n }\n\n if (!cartItemsSnapshot || !Array.isArray(cartItemsSnapshot)) {\n throw new Error('Cart items snapshot not found or invalid in the PaymentIntent metadata')\n }\n\n const order = await payload.create({\n collection: ordersSlug,\n data: {\n amount: paymentIntent.amount,\n currency: paymentIntent.currency.toUpperCase(),\n ...(req.user ? { customer: req.user.id } : { customerEmail }),\n items: cartItemsSnapshot,\n shippingAddress,\n status: 'processing',\n transactions: [transaction.id],\n },\n })\n\n const timestamp = new Date().toISOString()\n\n await payload.update({\n id: cartID,\n collection: 'carts',\n data: {\n purchasedAt: timestamp,\n },\n })\n\n await payload.update({\n id: transaction.id,\n collection: transactionsSlug,\n data: {\n order: order.id,\n status: 'succeeded',\n },\n })\n\n return {\n message: 'Payment initiated successfully',\n orderID: order.id,\n transactionID: transaction.id,\n }\n } catch (error) {\n payload.logger.error(error, 'Error initiating payment with Stripe')\n\n throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment')\n }\n }\n"],"names":["Stripe","confirmOrder","props","data","ordersSlug","req","transactionsSlug","payload","apiVersion","appInfo","secretKey","customerEmail","paymentIntentID","Error","stripe","name","url","customer","customers","list","email","id","create","transactionsResults","find","collection","where","equals","transaction","docs","totalDocs","paymentIntent","paymentIntents","retrieve","cartID","metadata","cartItemsSnapshot","JSON","parse","undefined","shippingAddress","Array","isArray","order","amount","currency","toUpperCase","user","items","status","transactions","timestamp","Date","toISOString","update","purchasedAt","message","orderID","transactionID","error","logger"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAW3B,OAAO,MAAMC,eACX,CAACC,QACD,OAAO,EAAEC,IAAI,EAAEC,aAAa,QAAQ,EAAEC,GAAG,EAAEC,mBAAmB,cAAc,EAAE;QAC5E,MAAMC,UAAUF,IAAIE,OAAO;QAC3B,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGR,SAAS,CAAC;QAErD,MAAMS,gBAAgBR,KAAKQ,aAAa;QAExC,MAAMC,kBAAkBT,KAAKS,eAAe;QAE5C,IAAI,CAACF,WAAW;YACd,MAAM,IAAIG,MAAM;QAClB;QAEA,IAAI,CAACD,iBAAiB;YACpB,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,SAAS,IAAId,OAAOU,WAAW;YACnC,uEAAuE;YACvE,6DAA6D;YAC7D,yGAAyG;YACzGF,YAAYA,cAAc;YAC1BC,SAASA,WAAW;gBAClBM,MAAM;gBACNC,KAAK;YACP;QACF;QAEA,IAAI;YACF,IAAIC,WAAW,AACb,CAAA,MAAMH,OAAOI,SAAS,CAACC,IAAI,CAAC;gBAC1BC,OAAOT;YACT,EAAC,EACDR,IAAI,CAAC,EAAE;YAET,IAAI,CAACc,UAAUI,IAAI;gBACjBJ,WAAW,MAAMH,OAAOI,SAAS,CAACI,MAAM,CAAC;oBACvCF,OAAOT;gBACT;YACF;YAEA,yDAAyD;YACzD,MAAMY,sBAAsB,MAAMhB,QAAQiB,IAAI,CAAC;gBAC7CC,YAAYnB;gBACZoB,OAAO;oBACL,0BAA0B;wBACxBC,QAAQf;oBACV;gBACF;YACF;YAEA,MAAMgB,cAAcL,oBAAoBM,IAAI,CAAC,EAAE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EAAE;oBACf4B,QAAQ;gBACV;YACF;YAEA,OAAO;gBACLO,SAAS;gBACTC,SAASd,MAAMtB,EAAE;gBACjBqC,eAAe9B,YAAYP,EAAE;YAC/B;QACF,EAAE,OAAOsC,OAAO;YACdpD,QAAQqD,MAAM,CAACD,KAAK,CAACA,OAAO;YAE5B,MAAM,IAAI9C,MAAM8C,iBAAiB9C,QAAQ8C,MAAMH,OAAO,GAAG;QAC3D;IACF,EAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Endpoint } from 'payload';
|
|
2
|
+
import Stripe from 'stripe';
|
|
3
|
+
import type { StripeAdapterArgs } from '../index.js';
|
|
4
|
+
type Props = {
|
|
5
|
+
apiVersion?: Stripe.StripeConfig['apiVersion'];
|
|
6
|
+
appInfo?: Stripe.StripeConfig['appInfo'];
|
|
7
|
+
secretKey: StripeAdapterArgs['secretKey'];
|
|
8
|
+
webhooks?: StripeAdapterArgs['webhooks'];
|
|
9
|
+
webhookSecret: StripeAdapterArgs['webhookSecret'];
|
|
10
|
+
};
|
|
11
|
+
export declare const webhooksEndpoint: (props: Props) => Endpoint;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../../../src/payments/adapters/stripe/endpoints/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACxC,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;IACzC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACxC,aAAa,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAA;CAClD,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,QAsDhD,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
export const webhooksEndpoint = (props)=>{
|
|
3
|
+
const { apiVersion, appInfo, secretKey, webhooks, webhookSecret } = props || {};
|
|
4
|
+
const handler = async (req)=>{
|
|
5
|
+
let returnStatus = 200;
|
|
6
|
+
if (webhookSecret && secretKey && req.text) {
|
|
7
|
+
const stripe = new Stripe(secretKey, {
|
|
8
|
+
// API version can only be the latest, stripe recommends ts ignoring it
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
// @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised
|
|
11
|
+
apiVersion: apiVersion || '2025-03-31.basil',
|
|
12
|
+
appInfo: appInfo || {
|
|
13
|
+
name: 'Stripe Payload Plugin',
|
|
14
|
+
url: 'https://payloadcms.com'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const body = await req.text();
|
|
18
|
+
const stripeSignature = req.headers.get('stripe-signature');
|
|
19
|
+
if (stripeSignature) {
|
|
20
|
+
let event;
|
|
21
|
+
try {
|
|
22
|
+
event = stripe.webhooks.constructEvent(body, stripeSignature, webhookSecret);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const msg = err instanceof Error ? err.message : JSON.stringify(err);
|
|
25
|
+
req.payload.logger.error(`Error constructing Stripe event: ${msg}`);
|
|
26
|
+
returnStatus = 400;
|
|
27
|
+
}
|
|
28
|
+
if (typeof webhooks === 'object' && event) {
|
|
29
|
+
const webhookEventHandler = webhooks[event.type];
|
|
30
|
+
if (typeof webhookEventHandler === 'function') {
|
|
31
|
+
await webhookEventHandler({
|
|
32
|
+
event,
|
|
33
|
+
req,
|
|
34
|
+
stripe
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Response.json({
|
|
41
|
+
received: true
|
|
42
|
+
}, {
|
|
43
|
+
status: returnStatus
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
handler,
|
|
48
|
+
method: 'post',
|
|
49
|
+
path: '/webhooks'
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/payments/adapters/stripe/endpoints/webhooks.ts"],"sourcesContent":["import type { Endpoint } from 'payload'\n\nimport Stripe from 'stripe'\n\nimport type { StripeAdapterArgs } from '../index.js'\n\ntype Props = {\n apiVersion?: Stripe.StripeConfig['apiVersion']\n appInfo?: Stripe.StripeConfig['appInfo']\n secretKey: StripeAdapterArgs['secretKey']\n webhooks?: StripeAdapterArgs['webhooks']\n webhookSecret: StripeAdapterArgs['webhookSecret']\n}\n\nexport const webhooksEndpoint: (props: Props) => Endpoint = (props) => {\n const { apiVersion, appInfo, secretKey, webhooks, webhookSecret } = props || {}\n\n const handler: Endpoint['handler'] = async (req) => {\n let returnStatus = 200\n\n if (webhookSecret && secretKey && req.text) {\n const stripe = new Stripe(secretKey, {\n // API version can only be the latest, stripe recommends ts ignoring it\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised\n apiVersion: apiVersion || '2025-03-31.basil',\n appInfo: appInfo || {\n name: 'Stripe Payload Plugin',\n url: 'https://payloadcms.com',\n },\n })\n\n const body = await req.text()\n const stripeSignature = req.headers.get('stripe-signature')\n\n if (stripeSignature) {\n let event: Stripe.Event | undefined\n\n try {\n event = stripe.webhooks.constructEvent(body, stripeSignature, webhookSecret)\n } catch (err: unknown) {\n const msg: string = err instanceof Error ? err.message : JSON.stringify(err)\n req.payload.logger.error(`Error constructing Stripe event: ${msg}`)\n returnStatus = 400\n }\n\n if (typeof webhooks === 'object' && event) {\n const webhookEventHandler = webhooks[event.type]\n\n if (typeof webhookEventHandler === 'function') {\n await webhookEventHandler({\n event,\n req,\n stripe,\n })\n }\n }\n }\n }\n\n return Response.json({ received: true }, { status: returnStatus })\n }\n\n return {\n handler,\n method: 'post',\n path: '/webhooks',\n }\n}\n"],"names":["Stripe","webhooksEndpoint","props","apiVersion","appInfo","secretKey","webhooks","webhookSecret","handler","req","returnStatus","text","stripe","name","url","body","stripeSignature","headers","get","event","constructEvent","err","msg","Error","message","JSON","stringify","payload","logger","error","webhookEventHandler","type","Response","json","received","status","method","path"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAY3B,OAAO,MAAMC,mBAA+C,CAACC;IAC3D,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,aAAa,EAAE,GAAGL,SAAS,CAAC;IAE9E,MAAMM,UAA+B,OAAOC;QAC1C,IAAIC,eAAe;QAEnB,IAAIH,iBAAiBF,aAAaI,IAAIE,IAAI,EAAE;YAC1C,MAAMC,SAAS,IAAIZ,OAAOK,WAAW;gBACnC,uEAAuE;gBACvE,6DAA6D;gBAC7D,yGAAyG;gBACzGF,YAAYA,cAAc;gBAC1BC,SAASA,WAAW;oBAClBS,MAAM;oBACNC,KAAK;gBACP;YACF;YAEA,MAAMC,OAAO,MAAMN,IAAIE,IAAI;YAC3B,MAAMK,kBAAkBP,IAAIQ,OAAO,CAACC,GAAG,CAAC;YAExC,IAAIF,iBAAiB;gBACnB,IAAIG;gBAEJ,IAAI;oBACFA,QAAQP,OAAON,QAAQ,CAACc,cAAc,CAACL,MAAMC,iBAAiBT;gBAChE,EAAE,OAAOc,KAAc;oBACrB,MAAMC,MAAcD,eAAeE,QAAQF,IAAIG,OAAO,GAAGC,KAAKC,SAAS,CAACL;oBACxEZ,IAAIkB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,iCAAiC,EAAEP,KAAK;oBAClEZ,eAAe;gBACjB;gBAEA,IAAI,OAAOJ,aAAa,YAAYa,OAAO;oBACzC,MAAMW,sBAAsBxB,QAAQ,CAACa,MAAMY,IAAI,CAAC;oBAEhD,IAAI,OAAOD,wBAAwB,YAAY;wBAC7C,MAAMA,oBAAoB;4BACxBX;4BACAV;4BACAG;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAOoB,SAASC,IAAI,CAAC;YAAEC,UAAU;QAAK,GAAG;YAAEC,QAAQzB;QAAa;IAClE;IAEA,OAAO;QACLF;QACA4B,QAAQ;QACRC,MAAM;IACR;AACF,EAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { Stripe } from 'stripe';
|
|
3
|
+
import type { PaymentAdapter, PaymentAdapterArgs, PaymentAdapterClient, PaymentAdapterClientArgs } from '../../../types.js';
|
|
4
|
+
type StripeWebhookHandler = (args: {
|
|
5
|
+
event: Stripe.Event;
|
|
6
|
+
req: PayloadRequest;
|
|
7
|
+
stripe: Stripe;
|
|
8
|
+
}) => Promise<void> | void;
|
|
9
|
+
type StripeWebhookHandlers = {
|
|
10
|
+
/**
|
|
11
|
+
* Description of the event (e.g., invoice.created or charge.refunded).
|
|
12
|
+
*/
|
|
13
|
+
[webhookName: string]: StripeWebhookHandler;
|
|
14
|
+
};
|
|
15
|
+
export type StripeAdapterArgs = {
|
|
16
|
+
/**
|
|
17
|
+
* This library's types only reflect the latest API version.
|
|
18
|
+
*
|
|
19
|
+
* We recommend upgrading your account's API Version to the latest version
|
|
20
|
+
* if you wish to use TypeScript with this library.
|
|
21
|
+
*
|
|
22
|
+
* If you wish to remain on your account's default API version,
|
|
23
|
+
* you may pass `null` or another version instead of the latest version,
|
|
24
|
+
* and add a `@ts-ignore` comment here and anywhere the types differ between API versions.
|
|
25
|
+
*
|
|
26
|
+
* @docs https://stripe.com/docs/api/versioning
|
|
27
|
+
*/
|
|
28
|
+
apiVersion?: Stripe.StripeConfig['apiVersion'];
|
|
29
|
+
appInfo?: Stripe.StripeConfig['appInfo'];
|
|
30
|
+
publishableKey: string;
|
|
31
|
+
secretKey: string;
|
|
32
|
+
webhooks?: StripeWebhookHandlers;
|
|
33
|
+
webhookSecret?: string;
|
|
34
|
+
} & PaymentAdapterArgs;
|
|
35
|
+
export declare const stripeAdapter: (props: StripeAdapterArgs) => PaymentAdapter;
|
|
36
|
+
export type StripeAdapterClientArgs = {
|
|
37
|
+
/**
|
|
38
|
+
* This library's types only reflect the latest API version.
|
|
39
|
+
*
|
|
40
|
+
* We recommend upgrading your account's API Version to the latest version
|
|
41
|
+
* if you wish to use TypeScript with this library.
|
|
42
|
+
*
|
|
43
|
+
* If you wish to remain on your account's default API version,
|
|
44
|
+
* you may pass `null` or another version instead of the latest version,
|
|
45
|
+
* and add a `@ts-ignore` comment here and anywhere the types differ between API versions.
|
|
46
|
+
*
|
|
47
|
+
* @docs https://stripe.com/docs/api/versioning
|
|
48
|
+
*/
|
|
49
|
+
apiVersion?: Stripe.StripeConfig['apiVersion'];
|
|
50
|
+
appInfo?: Stripe.StripeConfig['appInfo'];
|
|
51
|
+
publishableKey: string;
|
|
52
|
+
} & PaymentAdapterClientArgs;
|
|
53
|
+
export declare const stripeAdapterClient: (props: StripeAdapterClientArgs) => PaymentAdapterClient;
|
|
54
|
+
export type InitiatePaymentReturnType = {
|
|
55
|
+
clientSecret: string;
|
|
56
|
+
message: string;
|
|
57
|
+
paymentIntentID: string;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/payments/adapters/stripe/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,M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