-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayload.config.ts
69 lines (67 loc) · 2.76 KB
/
payload.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { mongooseAdapter } from '@payloadcms/db-mongodb';
import { lexicalEditor } from '@payloadcms/richtext-lexical';
import path from 'path';
import { buildConfig } from 'payload/config';
import sharp from 'sharp'
import { fileURLToPath } from 'url';
import { stripePlugin } from '@payloadcms/plugin-stripe'
import { resendAdapter } from '@payloadcms/email-resend'
import { Users } from './collections/Users';
import { Media } from './collections/Media';
import Categories from './collections/Categories';
import Products from './collections/Products';
import Producers from './collections/Producers';
import ShippingMethods from './collections/ShippingMethods';
import { Orders } from './collections/Orders';
import DashboardHeader from './components/payload/DashboardHeader';
import Notifications from './collections/Notifications';
import { productUpdated } from './stripe/webhooks/productUpdated';
import { priceUpdated } from './stripe/webhooks/priceUpdated';
import { paymentSucceeded } from './stripe/webhooks/paymentSucceeded';
import { subscriptionSucceeded } from './stripe/webhooks/subscriptionSucceeded';
import { subscriptionDeleted } from './stripe/webhooks/subscriptionDeleted';
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
export default buildConfig({
admin: {
user: Users.slug,
components: {
beforeDashboard: [
DashboardHeader
]
}
},
collections: [ Users, Media, Products, Categories, Producers, ShippingMethods, Orders, Notifications ],
editor: lexicalEditor({}),
plugins: [
stripePlugin({
stripeSecretKey: process.env.STRIPE_SECRET_KEY || '',
isTestKey: Boolean(process.env.PAYLOAD_PUBLIC_STRIPE_IS_TEST_KEY),
stripeWebhooksEndpointSecret: process.env.STRIPE_WEBHOOKS_SIGNING_SECRET,
rest: false,
webhooks: {
'product.created': productUpdated,
'product.updated': productUpdated,
// 'customer.updated': customerUpdated,
'price.updated': priceUpdated,
'payment_intent.succeeded': paymentSucceeded,
'checkout.session.completed': subscriptionSucceeded,
'invoice.payment_succeeded': subscriptionSucceeded,
'customer.subscription.deleted': subscriptionDeleted,
},
}),
],
secret: process.env.PAYLOAD_SECRET!,
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: mongooseAdapter({
url: process.env.DATABASE_URI!,
}),
sharp,
email: resendAdapter({
defaultFromAddress: 'netnook@kamilmarczak.pl',
defaultFromName: 'NetNook',
apiKey: process.env.RESEND_API_KEY!,
}),
});