Files
zeekay 09c5e16c5c feat: rebrand all packages to @hanzo/cms scope (Payload v3.85.2 fork)
- payload -> @hanzo/cms (core), bin payload -> hanzo-cms
- create-payload-app -> @hanzo/create-cms-app
- @payloadcms/<x> -> @hanzo/cms-<x> across the whole dependency graph
- 3545 files, 72 package.json, 4419 scoped refs, 3852 core import specifiers, 82 scss imports
- MIT attribution to Payload CMS Inc. preserved (LICENSE.md, author emails)

Upstream: github.com/payloadcms/payload @ v3.85.2 (MIT)
2026-07-01 17:56:00 -07:00

114 lines
2.9 KiB
TypeScript

import { fileURLToPath } from 'node:url'
import path from 'path'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import { ecommercePlugin, EUR, USD } from '@hanzo/cms-plugin-ecommerce'
import { stripeAdapter } from '@hanzo/cms-plugin-ecommerce/payments/stripe'
import type { EcommercePluginConfig } from '../../packages/plugin-ecommerce/src/types.js'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { Media } from './collections/Media.js'
import { Users } from './collections/Users.js'
import { seed } from './seed/index.js'
export const currenciesConfig: NonNullable<EcommercePluginConfig['currencies']> = {
supportedCurrencies: [
USD,
EUR,
{
code: 'JPY',
decimals: 0,
label: 'Japanese Yen',
symbol: '¥',
},
],
defaultCurrency: 'USD',
}
export default buildConfigWithDefaults({
collections: [Users, Media],
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
},
maxDepth: 10,
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
await seed(payload)
},
jobs: {
autoRun: undefined,
},
plugins: [
ecommercePlugin({
access: {
adminOnlyFieldAccess: ({ req }) => Boolean(req.user),
adminOrPublishedStatus: ({ req }) => {
if (req.user) {
return true
}
return {
_status: {
equals: 'published',
},
}
},
customerOnlyFieldAccess: ({ req }) => Boolean(req.user),
isAdmin: ({ req }) => Boolean(req.user),
isAuthenticated: ({ req }) => Boolean(req.user),
isCustomer: ({ req }) => Boolean(req.user),
isDocumentOwner: ({ req }) => {
if (req.user) {
return {
customer: {
equals: req.user.id,
},
}
}
return false
},
},
carts: {
allowGuestCarts: true,
},
customers: {
slug: 'users',
},
products: {
variants: true,
},
payments: {
paymentMethods: [
stripeAdapter({
secretKey: process.env.STRIPE_SECRET_KEY!,
publishableKey: process.env.STRIPE_PUBLISHABLE_KEY!,
webhookSecret: process.env.STRIPE_WEBHOOKS_SECRET!,
webhooks: {
'payment_intent.succeeded': ({ event, req }) => {
console.log({ event, data: event.data.object })
req.payload.logger.info('Payment succeeded')
},
},
}),
],
},
currencies: currenciesConfig,
}),
],
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})