@payloadcms/plugin-stripe 3.0.0-canary.cee5702 → 3.0.0-canary.ee0375f

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 (38) hide show
  1. package/dist/admin.d.ts +1 -1
  2. package/dist/admin.d.ts.map +1 -1
  3. package/dist/admin.js.map +1 -1
  4. package/dist/fields/getFields.d.ts +1 -1
  5. package/dist/fields/getFields.d.ts.map +1 -1
  6. package/dist/fields/getFields.js.map +1 -1
  7. package/dist/hooks/createNewInStripe.d.ts +1 -1
  8. package/dist/hooks/createNewInStripe.d.ts.map +1 -1
  9. package/dist/hooks/createNewInStripe.js +1 -1
  10. package/dist/hooks/createNewInStripe.js.map +1 -1
  11. package/dist/hooks/deleteFromStripe.d.ts +1 -1
  12. package/dist/hooks/deleteFromStripe.d.ts.map +1 -1
  13. package/dist/hooks/deleteFromStripe.js +1 -1
  14. package/dist/hooks/deleteFromStripe.js.map +1 -1
  15. package/dist/hooks/syncExistingWithStripe.d.ts +1 -1
  16. package/dist/hooks/syncExistingWithStripe.d.ts.map +1 -1
  17. package/dist/hooks/syncExistingWithStripe.js +1 -1
  18. package/dist/hooks/syncExistingWithStripe.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/routes/rest.d.ts +2 -2
  23. package/dist/routes/rest.d.ts.map +1 -1
  24. package/dist/routes/rest.js +7 -2
  25. package/dist/routes/rest.js.map +1 -1
  26. package/dist/routes/webhooks.d.ts +2 -3
  27. package/dist/routes/webhooks.d.ts.map +1 -1
  28. package/dist/routes/webhooks.js +3 -0
  29. package/dist/routes/webhooks.js.map +1 -1
  30. package/dist/types.d.ts +2 -128
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/types.js.map +1 -1
  33. package/dist/ui/LinkToDoc.d.ts +1 -2
  34. package/dist/ui/LinkToDoc.d.ts.map +1 -1
  35. package/dist/ui/LinkToDoc.js +14 -11
  36. package/dist/ui/LinkToDoc.js.map +1 -1
  37. package/dist/utilities/deepen.d.ts.map +1 -1
  38. package/package.json +18 -18
package/dist/admin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config } from 'payload/config';
1
+ import type { Config } from 'payload';
2
2
  import type { StripePluginConfig } from './types.js';
3
3
  export declare const stripePlugin: (incomingPluginConfig: StripePluginConfig) => (config: Config) => Config;
4
4
  //# sourceMappingURL=admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIjF,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAmCjB,CAAA"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIjF,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAmCjB,CAAA"}
package/dist/admin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/admin.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { SanitizedStripePluginConfig, StripePluginConfig } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\n\nexport const stripePlugin =\n (incomingPluginConfig: StripePluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // set config defaults here\n const pluginConfig: SanitizedStripePluginConfig = {\n ...incomingPluginConfig,\n // TODO: in the next major version, default this to `false`\n rest: incomingPluginConfig?.rest ?? true,\n sync: incomingPluginConfig?.sync || [],\n }\n\n // NOTE: env variables are never passed to the client, but we need to know if `stripeSecretKey` is a test key\n // unfortunately we must set the 'isTestKey' property on the config instead of using the following code:\n // const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');\n\n return {\n ...config,\n collections: collections?.map((collection) => {\n const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)\n\n if (syncConfig) {\n const fields = getFields({\n collection,\n pluginConfig,\n syncConfig,\n })\n return {\n ...collection,\n fields,\n }\n }\n\n return collection\n }),\n }\n }\n"],"names":["getFields","stripePlugin","incomingPluginConfig","config","collections","pluginConfig","rest","sync","map","collection","syncConfig","find","slug","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,wBAAuB;AAEjD,OAAO,MAAMC,eACX,CAACC,uBACD,CAACC;QACC,MAAM,EAAEC,WAAW,EAAE,GAAGD;QAExB,2BAA2B;QAC3B,MAAME,eAA4C;YAChD,GAAGH,oBAAoB;YACvB,2DAA2D;YAC3DI,MAAMJ,sBAAsBI,QAAQ;YACpCC,MAAML,sBAAsBK,QAAQ,EAAE;QACxC;QAEA,6GAA6G;QAC7G,wGAAwG;QACxG,0EAA0E;QAE1E,OAAO;YACL,GAAGJ,MAAM;YACTC,aAAaA,aAAaI,IAAI,CAACC;gBAC7B,MAAMC,aAAaL,aAAaE,IAAI,EAAEI,KAAK,CAACJ,OAASA,KAAKE,UAAU,KAAKA,WAAWG,IAAI;gBAExF,IAAIF,YAAY;oBACd,MAAMG,SAASb,UAAU;wBACvBS;wBACAJ;wBACAK;oBACF;oBACA,OAAO;wBACL,GAAGD,UAAU;wBACbI;oBACF;gBACF;gBAEA,OAAOJ;YACT;QACF;IACF,EAAC"}
1
+ {"version":3,"sources":["../src/admin.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport type { SanitizedStripePluginConfig, StripePluginConfig } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\n\nexport const stripePlugin =\n (incomingPluginConfig: StripePluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // set config defaults here\n const pluginConfig: SanitizedStripePluginConfig = {\n ...incomingPluginConfig,\n // TODO: in the next major version, default this to `false`\n rest: incomingPluginConfig?.rest ?? true,\n sync: incomingPluginConfig?.sync || [],\n }\n\n // NOTE: env variables are never passed to the client, but we need to know if `stripeSecretKey` is a test key\n // unfortunately we must set the 'isTestKey' property on the config instead of using the following code:\n // const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');\n\n return {\n ...config,\n collections: collections?.map((collection) => {\n const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)\n\n if (syncConfig) {\n const fields = getFields({\n collection,\n pluginConfig,\n syncConfig,\n })\n return {\n ...collection,\n fields,\n }\n }\n\n return collection\n }),\n }\n }\n"],"names":["getFields","stripePlugin","incomingPluginConfig","config","collections","pluginConfig","rest","sync","map","collection","syncConfig","find","slug","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,wBAAuB;AAEjD,OAAO,MAAMC,eACX,CAACC,uBACD,CAACC;QACC,MAAM,EAAEC,WAAW,EAAE,GAAGD;QAExB,2BAA2B;QAC3B,MAAME,eAA4C;YAChD,GAAGH,oBAAoB;YACvB,2DAA2D;YAC3DI,MAAMJ,sBAAsBI,QAAQ;YACpCC,MAAML,sBAAsBK,QAAQ,EAAE;QACxC;QAEA,6GAA6G;QAC7G,wGAAwG;QACxG,0EAA0E;QAE1E,OAAO;YACL,GAAGJ,MAAM;YACTC,aAAaA,aAAaI,IAAI,CAACC;gBAC7B,MAAMC,aAAaL,aAAaE,IAAI,EAAEI,KAAK,CAACJ,OAASA,KAAKE,UAAU,KAAKA,WAAWG,IAAI;gBAExF,IAAIF,YAAY;oBACd,MAAMG,SAASb,UAAU;wBACvBS;wBACAJ;wBACAK;oBACF;oBACA,OAAO;wBACL,GAAGD,UAAU;wBACbI;oBACF;gBACF;gBAEA,OAAOJ;YACT;QACF;IACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig, Field } from 'payload/types';
1
+ import type { CollectionConfig, Field } from 'payload';
2
2
  import type { SanitizedStripePluginConfig } from '../types.js';
3
3
  interface Args {
4
4
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"getFields.d.ts","sourceRoot":"","sources":["../../src/fields/getFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAI9D,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE;QACV,kBAAkB,EAAE,MAAM,CAAA;KAC3B,CAAA;CACF;AAED,eAAO,MAAM,SAAS,6CAA8C,IAAI,KAAG,KAAK,EAyC/E,CAAA"}
1
+ {"version":3,"file":"getFields.d.ts","sourceRoot":"","sources":["../../src/fields/getFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAI9D,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE;QACV,kBAAkB,EAAE,MAAM,CAAA;KAC3B,CAAA;CACF;AAED,eAAO,MAAM,SAAS,6CAA8C,IAAI,KAAG,KAAK,EAyC/E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/getFields.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload/types'\n\nimport type { SanitizedStripePluginConfig } from '../types.js'\n\nimport { LinkToDoc } from '../ui/LinkToDoc.js'\n\ninterface Args {\n collection: CollectionConfig\n pluginConfig: SanitizedStripePluginConfig\n syncConfig: {\n stripeResourceType: string\n }\n}\n\nexport const getFields = ({ collection, pluginConfig, syncConfig }: Args): Field[] => {\n const stripeIDField: Field = {\n name: 'stripeID',\n type: 'text',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: 'Stripe ID',\n saveToJWT: true,\n }\n\n const skipSyncField: Field = {\n name: 'skipSync',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: 'Skip Sync',\n }\n\n const docUrlField: Field = {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: LinkToDoc,\n },\n custom: {\n isTestKey: pluginConfig.isTestKey,\n nameOfIDField: 'stripeID',\n stripeResourceType: syncConfig.stripeResourceType,\n },\n position: 'sidebar',\n },\n }\n\n const fields = [...collection.fields, stripeIDField, skipSyncField, docUrlField]\n\n return fields\n}\n"],"names":["LinkToDoc","getFields","collection","pluginConfig","syncConfig","stripeIDField","name","type","admin","position","readOnly","label","saveToJWT","skipSyncField","docUrlField","components","Field","custom","isTestKey","nameOfIDField","stripeResourceType","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,qBAAoB;AAU9C,OAAO,MAAMC,YAAY,CAAC,EAAEC,UAAU,EAAEC,YAAY,EAAEC,UAAU,EAAQ;IACtE,MAAMC,gBAAuB;QAC3BC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,UAAU;YACVC,UAAU;QACZ;QACAC,OAAO;QACPC,WAAW;IACb;IAEA,MAAMC,gBAAuB;QAC3BP,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,UAAU;YACVC,UAAU;QACZ;QACAC,OAAO;IACT;IAEA,MAAMG,cAAqB;QACzBR,MAAM;QACNC,MAAM;QACNC,OAAO;YACLO,YAAY;gBACVC,OAAOhB;YACT;YACAiB,QAAQ;gBACNC,WAAWf,aAAae,SAAS;gBACjCC,eAAe;gBACfC,oBAAoBhB,WAAWgB,kBAAkB;YACnD;YACAX,UAAU;QACZ;IACF;IAEA,MAAMY,SAAS;WAAInB,WAAWmB,MAAM;QAAEhB;QAAeQ;QAAeC;KAAY;IAEhF,OAAOO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/getFields.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { SanitizedStripePluginConfig } from '../types.js'\n\nimport { LinkToDoc } from '../ui/LinkToDoc.js'\n\ninterface Args {\n collection: CollectionConfig\n pluginConfig: SanitizedStripePluginConfig\n syncConfig: {\n stripeResourceType: string\n }\n}\n\nexport const getFields = ({ collection, pluginConfig, syncConfig }: Args): Field[] => {\n const stripeIDField: Field = {\n name: 'stripeID',\n type: 'text',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: 'Stripe ID',\n saveToJWT: true,\n }\n\n const skipSyncField: Field = {\n name: 'skipSync',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: 'Skip Sync',\n }\n\n const docUrlField: Field = {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: LinkToDoc,\n },\n custom: {\n isTestKey: pluginConfig.isTestKey,\n nameOfIDField: 'stripeID',\n stripeResourceType: syncConfig.stripeResourceType,\n },\n position: 'sidebar',\n },\n }\n\n const fields = [...collection.fields, stripeIDField, skipSyncField, docUrlField]\n\n return fields\n}\n"],"names":["LinkToDoc","getFields","collection","pluginConfig","syncConfig","stripeIDField","name","type","admin","position","readOnly","label","saveToJWT","skipSyncField","docUrlField","components","Field","custom","isTestKey","nameOfIDField","stripeResourceType","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,qBAAoB;AAU9C,OAAO,MAAMC,YAAY,CAAC,EAAEC,UAAU,EAAEC,YAAY,EAAEC,UAAU,EAAQ;IACtE,MAAMC,gBAAuB;QAC3BC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,UAAU;YACVC,UAAU;QACZ;QACAC,OAAO;QACPC,WAAW;IACb;IAEA,MAAMC,gBAAuB;QAC3BP,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,UAAU;YACVC,UAAU;QACZ;QACAC,OAAO;IACT;IAEA,MAAMG,cAAqB;QACzBR,MAAM;QACNC,MAAM;QACNC,OAAO;YACLO,YAAY;gBACVC,OAAOhB;YACT;YACAiB,QAAQ;gBACNC,WAAWf,aAAae,SAAS;gBACjCC,eAAe;gBACfC,oBAAoBhB,WAAWgB,kBAAkB;YACnD;YACAX,UAAU;QACZ;IACF;IAEA,MAAMY,SAAS;WAAInB,WAAWmB,MAAM;QAAEhB;QAAeQ;QAAeC;KAAY;IAEhF,OAAOO;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionBeforeValidateHook, CollectionConfig } from 'payload/types';
1
+ import type { CollectionBeforeValidateHook, CollectionConfig } from 'payload';
2
2
  import type { StripePluginConfig } from '../types.js';
3
3
  type HookArgsWithCustomCollection = Omit<Parameters<CollectionBeforeValidateHook>[0], 'collection'> & {
4
4
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"createNewInStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/createNewInStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAKnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,KAAK,4BAA4B,GAAG,IAAI,CACtC,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,EAC3C,YAAY,CACb,GAAG;IACF,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG,CACjD,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,iBAAiB,EAAE,oCA8G/B,CAAA"}
1
+ {"version":3,"file":"createNewInStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/createNewInStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,KAAK,4BAA4B,GAAG,IAAI,CACtC,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,EAC3C,YAAY,CACb,GAAG;IACF,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG,CACjD,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,iBAAiB,EAAE,oCA8G/B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { APIError } from 'payload/errors';
1
+ import { APIError } from 'payload';
2
2
  import Stripe from 'stripe';
3
3
  import { deepen } from '../utilities/deepen.js';
4
4
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/createNewInStripe.ts"],"sourcesContent":["import type { CollectionBeforeValidateHook, CollectionConfig } from 'payload/types'\n\nimport { APIError } from 'payload/errors'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<\n Parameters<CollectionBeforeValidateHook>[0],\n 'collection'\n> & {\n collection: CollectionConfig\n}\n\nexport type CollectionBeforeValidateHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const createNewInStripe: CollectionBeforeValidateHookWithArgs = async (args) => {\n const { collection, data, operation, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const payload = req?.payload\n\n const dataRef = data || {}\n\n if (process.env.NODE_ENV === 'test') {\n dataRef.stripeID = 'test'\n return dataRef\n }\n\n if (payload) {\n if (data?.skipSync) {\n if (logs) payload.logger.info(`Bypassing collection-level hooks.`)\n } else {\n // initialize as 'false' so that all Payload admin events sync to Stripe\n // then conditionally set to 'true' to for events that originate from webhooks\n // this will prevent webhook events from triggering an unnecessary sync / infinite loop\n dataRef.skipSync = false\n\n const { slug: collectionSlug } = collection || {}\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n // combine all fields of this object and match their respective values within the document\n let syncedFields = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[stripeProperty] = dataRef[fieldPath]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedFields = deepen(syncedFields)\n\n if (operation === 'update') {\n if (logs)\n payload.logger.info(\n `A '${collectionSlug}' document has changed in Payload with ID: '${data?.id}', syncing with Stripe...`,\n )\n\n // NOTE: the Stripe document will be created in the \"afterChange\" hook, so create a new stripe document here if no stripeID exists\n if (!dataRef.stripeID) {\n try {\n // NOTE: Typed as \"any\" because the \"create\" method is not standard across all Stripe resources\n const stripeResource = await stripe?.[syncConfig.stripeResourceType]?.create(\n // @ts-expect-error\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${syncConfig.stripeResourceType}' resource in Stripe with ID: '${stripeResource.id}'.`,\n )\n\n dataRef.stripeID = stripeResource.id\n\n // NOTE: this is to prevent sync in the \"afterChange\" hook\n dataRef.skipSync = true\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`- Error creating Stripe document: ${msg}`)\n }\n }\n }\n\n if (operation === 'create') {\n if (logs)\n payload.logger.info(\n `A new '${collectionSlug}' document was created in Payload with ID: '${data?.id}', syncing with Stripe...`,\n )\n\n try {\n if (logs)\n payload.logger.info(\n `- Creating new '${syncConfig.stripeResourceType}' resource in Stripe...`,\n )\n\n // NOTE: Typed as \"any\" because the \"create\" method is not standard across all Stripe resources\n const stripeResource = await stripe?.[syncConfig.stripeResourceType]?.create(\n // @ts-expect-error\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${syncConfig.stripeResourceType}' resource in Stripe with ID: '${stripeResource.id}'.`,\n )\n\n dataRef.stripeID = stripeResource.id\n\n // IMPORTANT: this is to prevent sync in the \"afterChange\" hook\n dataRef.skipSync = true\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(\n `Failed to create new '${syncConfig.stripeResourceType}' resource in Stripe: ${msg}`,\n )\n }\n }\n }\n }\n }\n\n return dataRef\n}\n"],"names":["APIError","Stripe","deepen","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","createNewInStripe","args","collection","data","operation","pluginConfig","req","logs","sync","payload","dataRef","NODE_ENV","stripeID","skipSync","logger","info","slug","collectionSlug","syncConfig","find","conf","syncedFields","fields","reduce","acc","field","fieldPath","stripeProperty","id","stripeResource","stripeResourceType","create","error","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,YAAY,SAAQ;AAI3B,SAASC,MAAM,QAAQ,yBAAwB;AAE/C,MAAMC,kBAAkBC,QAAQC,GAAG,CAACC,iBAAiB;AACrD,uEAAuE;AACvE,MAAMC,SAAS,IAAIN,OAAOE,mBAAmB,IAAI;IAAEK,YAAY;AAAa;AAgB5E,OAAO,MAAMC,oBAA0D,O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CAAC,sBAAsB,EAAEG,IAAI,CAAC;oBAExF;gBACF;YACF;QACF;IACF;IAEA,OAAOvB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/hooks/createNewInStripe.ts"],"sourcesContent":["import type { CollectionBeforeValidateHook, CollectionConfig } from 'payload'\n\nimport { APIError } from 'payload'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<\n Parameters<CollectionBeforeValidateHook>[0],\n 'collection'\n> & {\n collection: CollectionConfig\n}\n\nexport type CollectionBeforeValidateHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const createNewInStripe: CollectionBeforeValidateHookWithArgs = async (args) => {\n const { collection, data, operation, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const payload = req?.payload\n\n const dataRef = data || {}\n\n if (process.env.NODE_ENV === 'test') {\n dataRef.stripeID = 'test'\n return dataRef\n }\n\n if (payload) {\n if (data?.skipSync) {\n if (logs) payload.logger.info(`Bypassing collection-level hooks.`)\n } else {\n // initialize as 'false' so that all Payload admin events sync to Stripe\n // then conditionally set to 'true' to for events that originate from webhooks\n // this will prevent webhook events from triggering an unnecessary sync / infinite loop\n dataRef.skipSync = false\n\n const { slug: collectionSlug } = collection || {}\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n // combine all fields of this object and match their respective values within the document\n let syncedFields = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[stripeProperty] = dataRef[fieldPath]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedFields = deepen(syncedFields)\n\n if (operation === 'update') {\n if (logs)\n payload.logger.info(\n `A '${collectionSlug}' document has changed in Payload with ID: '${data?.id}', syncing with Stripe...`,\n )\n\n // NOTE: the Stripe document will be created in the \"afterChange\" hook, so create a new stripe document here if no stripeID exists\n if (!dataRef.stripeID) {\n try {\n // NOTE: Typed as \"any\" because the \"create\" method is not standard across all Stripe resources\n const stripeResource = await stripe?.[syncConfig.stripeResourceType]?.create(\n // @ts-expect-error\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${syncConfig.stripeResourceType}' resource in Stripe with ID: '${stripeResource.id}'.`,\n )\n\n dataRef.stripeID = stripeResource.id\n\n // NOTE: this is to prevent sync in the \"afterChange\" hook\n dataRef.skipSync = true\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`- Error creating Stripe document: ${msg}`)\n }\n }\n }\n\n if (operation === 'create') {\n if (logs)\n payload.logger.info(\n `A new '${collectionSlug}' document was created in Payload with ID: '${data?.id}', syncing with Stripe...`,\n )\n\n try {\n if (logs)\n payload.logger.info(\n `- Creating new '${syncConfig.stripeResourceType}' resource in Stripe...`,\n )\n\n // NOTE: Typed as \"any\" because the \"create\" method is not standard across all Stripe resources\n const stripeResource = await stripe?.[syncConfig.stripeResourceType]?.create(\n // @ts-expect-error\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${syncConfig.stripeResourceType}' resource in Stripe with ID: '${stripeResource.id}'.`,\n )\n\n dataRef.stripeID = stripeResource.id\n\n // IMPORTANT: this is to prevent sync in the \"afterChange\" hook\n dataRef.skipSync = true\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(\n `Failed to create new '${syncConfig.stripeResourceType}' resource in Stripe: ${msg}`,\n )\n }\n }\n }\n }\n }\n\n return dataRef\n}\n"],"names":["APIError","Stripe","deepen","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","createNewInStripe","args","collection","data","operation","pluginConfig","req","logs","sync","payload","dataRef","NODE_ENV","stripeID","skipSync","logger","info","slug","collectionSlug","syncConfig","find","conf","syncedFields","fields","reduce","acc","field","fieldPath","stripeProperty","id","stripeResource","stripeResourceType","create","error","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAClC,OAAOC,YAAY,SAAQ;AAI3B,SAASC,MAAM,QAAQ,yBAAwB;AAE/C,MAAMC,kBAAkBC,QAAQC,GAAG,CAACC,iBAAiB;AACrD,uEAAuE;AACvE,MAAMC,SAAS,IAAIN,OAAOE,mBAAmB,IAAI;IAAEK,YAAY;AAAa;AAgB5E,OAAO,MAAMC,oBAA0D,OAAOC;IAC5E,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGL;IAE3D,MAAM,EAAEM,IAAI,EAAEC,IAAI,EAAE,GAAGH,gBAAgB,CAAC;IAExC,MAAMI,UAAUH,KAAKG;IAErB,MAAMC,UAAUP,QAAQ,CAAC;IAEzB,IAAIR,QAAQC,GAAG,CAACe,QAAQ,KAAK,QAAQ;QACnCD,QAAQE,QAAQ,GAAG;QACnB,OAAOF;IACT;IAEA,IAAID,SAAS;QACX,IAAIN,MAAMU,UAAU;YAClB,IAAIN,MAAME,QAAQK,MAAM,CAACC,IAAI,CAAC,CAAC,iCAAiC,CAAC;QACnE,OAAO;YACL,wEAAwE;YACxE,8EAA8E;YAC9E,uFAAuF;YACvFL,QAAQG,QAAQ,GAAG;YAEnB,MAAM,EAAEG,MAAMC,cAAc,EAAE,GAAGf,cAAc,CAAC;YAChD,MAAMgB,aAAaV,MAAMW,KAAK,CAACC,OAASA,KAAKlB,UAAU,KAAKe;YAE5D,IAAIC,YAAY;gBACd,0FAA0F;gBAC1F,IAAIG,eAAeH,WAAWI,MAAM,CAACC,M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BAG7E,+FAA+F;wBAC/F,MAAMD,iBAAiB,MAAM/B,QAAQ,CAACoB,WAAWY,kBAAkB,CAAC,EAAEC,OACpE,mBAAmB;wBACnBV;wBAGF,IAAId,MACFE,QAAQK,MAAM,CAACC,IAAI,CACjB,CAAC,4BAA4B,EAAEG,WAAWY,kBAAkB,CAAC,+BAA+B,EAAED,eAAeD,EAAE,CAAC,EAAE,CAAC;wBAGvHlB,QAAQE,QAAQ,GAAGiB,eAAeD,EAAE;wBAEpC,+DAA+D;wBAC/DlB,QAAQG,QAAQ,GAAG;oBACrB,EAAE,OAAOmB,OAAgB;wBACvB,MAAMC,MAAMD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGH;wBACrD,MAAM,IAAIzC,SACR,CAAC,sBAAsB,EAAE2B,WAAWY,kBAAkB,CAAC,sBAAsB,EAAEG,IAAI,CAAC;oBAExF;gBACF;YACF;QACF;IACF;IAEA,OAAOvB;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionAfterDeleteHook, CollectionConfig } from 'payload/types';
1
+ import type { CollectionAfterDeleteHook, CollectionConfig } from 'payload';
2
2
  import type { StripePluginConfig } from '../types.js';
3
3
  type HookArgsWithCustomCollection = Omit<Parameters<CollectionAfterDeleteHook>[0], 'collection'> & {
4
4
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"deleteFromStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/deleteFromStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAKhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAMrD,KAAK,4BAA4B,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG;IACjG,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG,CAC9C,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,gBAAgB,EAAE,iCAwC9B,CAAA"}
1
+ {"version":3,"file":"deleteFromStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/deleteFromStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAMrD,KAAK,4BAA4B,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG;IACjG,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG,CAC9C,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,gBAAgB,EAAE,iCAwC9B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { APIError } from 'payload/errors';
1
+ import { APIError } from 'payload';
2
2
  import Stripe from 'stripe';
3
3
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
4
4
  // api version can only be the latest, stripe recommends ts ignoring it
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/deleteFromStripe.ts"],"sourcesContent":["import type { CollectionAfterDeleteHook, CollectionConfig } from 'payload/types'\n\nimport { APIError } from 'payload/errors'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<Parameters<CollectionAfterDeleteHook>[0], 'collection'> & {\n collection: CollectionConfig\n}\n\nexport type CollectionAfterDeleteHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const deleteFromStripe: CollectionAfterDeleteHookWithArgs = async (args) => {\n const { collection, doc, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const { payload } = req\n const { slug: collectionSlug } = collection || {}\n\n if (logs)\n payload.logger.info(\n `Document with ID: '${doc?.id}' in collection: '${collectionSlug}' has been deleted, deleting from Stripe...`,\n )\n\n if (process.env.NODE_ENV !== 'test') {\n if (logs) payload.logger.info(`- Deleting Stripe document with ID: '${doc.stripeID}'...`)\n\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n try {\n const found = await stripe?.[syncConfig.stripeResourceType]?.retrieve(doc.stripeID)\n\n if (found) {\n await stripe?.[syncConfig.stripeResourceType]?.del(doc.stripeID)\n if (logs)\n payload.logger.info(\n `✅ Successfully deleted Stripe document with ID: '${doc.stripeID}'.`,\n )\n } else {\n if (logs)\n payload.logger.info(\n `- Stripe document with ID: '${doc.stripeID}' not found, skipping...`,\n )\n }\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(`Failed to delete Stripe document with ID: '${doc.stripeID}': ${msg}`)\n }\n }\n }\n}\n"],"names":["APIError","Stripe","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","deleteFromStripe","args","collection","doc","pluginConfig","req","logs","sync","payload","slug","collectionSlug","logger","info","id","NODE_ENV","stripeID","syncConfig","find","conf","found","stripeResourceType","retrieve","del","error","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,YAAY,SAAQ;AAI3B,MAAMC,kBAAkBC,QAAQC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AMD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGH;gBACrD,MAAM,IAAI/B,SAAS,CAAC,2CAA2C,EAAEW,IAAIY,QAAQ,CAAC,GAAG,EAAES,IAAI,CAAC;YAC1F;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/hooks/deleteFromStripe.ts"],"sourcesContent":["import type { CollectionAfterDeleteHook, CollectionConfig } from 'payload'\n\nimport { APIError } from 'payload'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<Parameters<CollectionAfterDeleteHook>[0], 'collection'> & {\n collection: CollectionConfig\n}\n\nexport type CollectionAfterDeleteHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const deleteFromStripe: CollectionAfterDeleteHookWithArgs = async (args) => {\n const { collection, doc, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const { payload } = req\n const { slug: collectionSlug } = collection || {}\n\n if (logs)\n payload.logger.info(\n `Document with ID: '${doc?.id}' in collection: '${collectionSlug}' has been deleted, deleting from Stripe...`,\n )\n\n if (process.env.NODE_ENV !== 'test') {\n if (logs) payload.logger.info(`- Deleting Stripe document with ID: '${doc.stripeID}'...`)\n\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n try {\n const found = await stripe?.[syncConfig.stripeResourceType]?.retrieve(doc.stripeID)\n\n if (found) {\n await stripe?.[syncConfig.stripeResourceType]?.del(doc.stripeID)\n if (logs)\n payload.logger.info(\n `✅ Successfully deleted Stripe document with ID: '${doc.stripeID}'.`,\n )\n } else {\n if (logs)\n payload.logger.info(\n `- Stripe document with ID: '${doc.stripeID}' not found, skipping...`,\n )\n }\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(`Failed to delete Stripe document with ID: '${doc.stripeID}': ${msg}`)\n }\n }\n }\n}\n"],"names":["APIError","Stripe","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","deleteFromStripe","args","collection","doc","pluginConfig","req","logs","sync","payload","slug","collectionSlug","logger","info","id","NODE_ENV","stripeID","syncConfig","find","conf","found","stripeResourceType","retrieve","del","error","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAClC,OAAOC,YAAY,SAAQ;AAI3B,MAAMC,kBAAkBC,QAAQC,GAAG,CAACC,iBAAiB;AACrD,uEAAuE;AACvE,MAAMC,SAAS,IAAIL,OAAOC,mBAAmB,IAAI;IAAEK,YAAY;AAAa;AAa5E,OAAO,MAAMC,mBAAsD,OAAOC;IACxE,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGJ;IAE/C,MAAM,EAAEK,IAAI,EAAEC,IAAI,EAAE,GAAGH,gBAAgB,CAAC;IAExC,MAAM,EAAEI,OAAO,EAAE,GAAGH;IACpB,MAAM,EAAEI,MAAMC,cAAc,EAAE,GAAGR,cAAc,CAAC;IAEhD,IAAII,MACFE,QAAQG,MAAM,CAACC,IAAI,CACjB,CAAC,mBAAmB,EAAET,KAAKU,GAAG,kBAAkB,EAAEH,eAAe,2CAA2C,CAAC;IAGjH,IAAIf,QAAQC,GAAG,CAACkB,QAAQ,KAAK,QAAQ;QACnC,IAAIR,MAAME,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,qCAAqC,EAAET,IAAIY,QAAQ,CAAC,IAAI,CAAC;QAExF,MAAMC,aAAaT,MAAMU,KAAK,CAACC,OAASA,KAAKhB,UAAU,KAAKQ;QAE5D,IAAIM,YAAY;YACd,IAAI;gBACF,MAAMG,QAAQ,MAAMrB,QAAQ,CAACkB,WAAWI,kBAAkB,CAAC,EAAEC,SAASlB,IAAIY,QAAQ;gBAElF,IAAII,OAAO;oBACT,MAAMrB,QAAQ,CAACkB,WAAWI,kBAAkB,CAAC,EAAEE,IAAInB,IAAIY,QAAQ;oBAC/D,IAAIT,MACFE,QAAQG,MAAM,CAACC,IAAI,CACjB,CAAC,iDAAiD,EAAET,IAAIY,QAAQ,CAAC,EAAE,CAAC;gBAE1E,OAAO;oBACL,IAAIT,MACFE,QAAQG,MAAM,CAACC,IAAI,CACjB,CAAC,4BAA4B,EAAET,IAAIY,QAAQ,CAAC,wBAAwB,CAAC;gBAE3E;YACF,EAAE,OAAOQ,OAAgB;gBACvB,MAAMC,MAAMD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGH;gBACrD,MAAM,IAAI/B,SAAS,CAAC,2CAA2C,EAAEW,IAAIY,QAAQ,CAAC,GAAG,EAAES,IAAI,CAAC;YAC1F;QACF;IACF;AACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload/types';
1
+ import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload';
2
2
  import type { StripePluginConfig } from '../types.js';
3
3
  type HookArgsWithCustomCollection = Omit<Parameters<CollectionBeforeChangeHook>[0], 'collection'> & {
4
4
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"syncExistingWithStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/syncExistingWithStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAKjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,KAAK,4BAA4B,GAAG,IAAI,CACtC,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EACzC,YAAY,CACb,GAAG;IACF,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,kCAAkC,GAAG,CAC/C,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,sBAAsB,EAAE,kCA8DpC,CAAA"}
1
+ {"version":3,"file":"syncExistingWithStripe.d.ts","sourceRoot":"","sources":["../../src/hooks/syncExistingWithStripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,KAAK,4BAA4B,GAAG,IAAI,CACtC,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EACzC,YAAY,CACb,GAAG;IACF,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,kCAAkC,GAAG,CAC/C,IAAI,EAAE,4BAA4B,GAAG;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC,KACE,IAAI,CAAA;AAET,eAAO,MAAM,sBAAsB,EAAE,kCA8DpC,CAAA"}
@@ -1,4 +1,4 @@
1
- import { APIError } from 'payload/errors';
1
+ import { APIError } from 'payload';
2
2
  import Stripe from 'stripe';
3
3
  import { deepen } from '../utilities/deepen.js';
4
4
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/syncExistingWithStripe.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload/types'\n\nimport { APIError } from 'payload/errors'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<\n Parameters<CollectionBeforeChangeHook>[0],\n 'collection'\n> & {\n collection: CollectionConfig\n}\n\nexport type CollectionBeforeChangeHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const syncExistingWithStripe: CollectionBeforeChangeHookWithArgs = async (args) => {\n const { collection, data, operation, originalDoc, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const { payload } = req\n\n const { slug: collectionSlug } = collection || {}\n\n if (process.env.NODE_ENV !== 'test' && !data.skipSync) {\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n if (operation === 'update') {\n // combine all fields of this object and match their respective values within the document\n let syncedFields = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[stripeProperty] = data[fieldPath]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedFields = deepen(syncedFields)\n\n if (logs)\n payload.logger.info(\n `A '${collectionSlug}' document has changed in Payload with ID: '${originalDoc?._id}', syncing with Stripe...`,\n )\n\n if (!data.stripeID) {\n // NOTE: the \"beforeValidate\" hook populates this\n if (logs) payload.logger.error(`- There is no Stripe ID for this document, skipping.`)\n } else {\n if (logs)\n payload.logger.info(`- Syncing to Stripe resource with ID: '${data.stripeID}'...`)\n\n try {\n const stripeResource = await stripe?.[syncConfig?.stripeResourceType]?.update(\n data.stripeID,\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully synced Stripe resource with ID: '${stripeResource.id}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(`Failed to sync document with ID: '${data.id}' to Stripe: ${msg}`)\n }\n }\n }\n }\n }\n\n // Set back to 'false' so that all changes continue to sync to Stripe, see note in './createNewInStripe.ts'\n data.skipSync = false\n\n return data\n}\n"],"names":["APIError","Stripe","deepen","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","syncExistingWithStripe","args","collection","data","operation","originalDoc","pluginConfig","req","logs","sync","payload","slug","collectionSlug","NODE_ENV","skipSync","syncConfig","find","conf","syncedFields","fields","reduce","acc","field","fieldPath","stripeProperty","logger","info","_id","stripeID","error","stripeResource","stripeResourceType","update","id","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,YAAY,SAAQ;AAI3B,SAASC,MAAM,QAAQ,yBAAwB;AAE/C,MAAMC,kBAAkBC,QAAQC,GAAG,CAACC,iBAAiB;AACrD,uEAAuE;AACvE,MAAMC,SAAS,IAAIN,OAAOE,mBAAmB,IAAI;IAAEK,YAAY;AAAa;AAgB5E,OAAO,MAAMC,yBAA6D,OAAOC;IAC/E,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGN;IAExE,MAAM,EAAEO,IAAI,EAAEC,IAAI,EAAE,GAAGH,gBAAgB,CAAC;IAExC,MAAM,EAAEI,OAAO,EAAE,GAAGH;IAEpB,MAAM,EAAEI,MAAMC,cAAc,EAAE,GAAGV,cAAc,CAAC;IAEhD,IAAIP,QAAQC,GAAG,CAACiB,QAAQ,KAAK,UAAU,CAACV,KAAKW,QAAQ,EAAE;QACrD,MAAMC,aAAaN,MAAMO,KAAK,CAACC,OAASA,KAAKf,UAAU,KAAKU;QAE5D,IAAIG,YAAY;YACd,IAAIX,cAAc,UAAU;gBAC1B,0FAA0F;gBAC1F,IAAIc,eAAeH,WAAWI,MAAM,CAACC,MAAM,CACzC,CAACC,KAAKC;oBACJ,MAAM,EAAEC,SAAS,EAAEC,cAAc,EAAE,GAAGF;oBAEtCD,GAAG,CAACG,eAAe,GAAGrB,IAAI,CAACoB,UAAU;oBACrC,OAAOF;gBACT,GACA,CAAC;gBAGHH,eAAezB,OAAOyB;gBAEtB,IAAIV,MACFE,QAAQe,MAAM,CAACC,IAAI,CACjB,CAAC,GAAG,EAAEd,eAAe,4CAA4C,EAAEP,aAAasB,IAAI,yBAAyB,CAAC;gBAGlH,IAAI,CAACxB,KAAKyB,QAAQ,EAAE;oBAClB,iDAAiD;oBACjD,IAAIpB,MAAME,QAAQe,MAAM,CAACI,KAAK,CAAC,CAAC,oDAAoD,CAAC;gBACvF,OAAO;oBACL,IAAIrB,MACFE,QAAQe,MAAM,CAACC,IAAI,CAAC,CAAC,uCAAuC,EAAEvB,KAAKyB,QAAQ,CAAC,IAAI,CAAC;oBAEnF,IAAI;wBACF,MAAME,iBAAiB,MAAMhC,QAAQ,CAACiB,YAAYgB,mBAAmB,EAAEC,OACrE7B,KAAKyB,QAAQ,EACbV;wBAGF,IAAIV,MACFE,QAAQe,MAAM,CAACC,IAAI,CACjB,CAAC,gDAAgD,EAAEI,eAAeG,EAAE,CAAC,EAAE,CAAC;oBAE9E,EAAE,OAAOJ,OAAgB;wBACvB,MAAMK,MAAML,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGP;wBACrD,MAAM,IAAItC,SAAS,CAAC,kCAAkC,EAAEY,KAAK8B,EAAE,CAAC,aAAa,EAAEC,IAAI,CAAC;oBACtF;gBACF;YACF;QACF;IACF;IAEA,2GAA2G;IAC3G/B,KAAKW,QAAQ,GAAG;IAEhB,OAAOX;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/hooks/syncExistingWithStripe.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload'\n\nimport { APIError } from 'payload'\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\nconst stripeSecretKey = process.env.STRIPE_SECRET_KEY\n// api version can only be the latest, stripe recommends ts ignoring it\nconst stripe = new Stripe(stripeSecretKey || '', { apiVersion: '2022-08-01' })\n\ntype HookArgsWithCustomCollection = Omit<\n Parameters<CollectionBeforeChangeHook>[0],\n 'collection'\n> & {\n collection: CollectionConfig\n}\n\nexport type CollectionBeforeChangeHookWithArgs = (\n args: HookArgsWithCustomCollection & {\n collection?: CollectionConfig\n pluginConfig?: StripePluginConfig\n },\n) => void\n\nexport const syncExistingWithStripe: CollectionBeforeChangeHookWithArgs = async (args) => {\n const { collection, data, operation, originalDoc, pluginConfig, req } = args\n\n const { logs, sync } = pluginConfig || {}\n\n const { payload } = req\n\n const { slug: collectionSlug } = collection || {}\n\n if (process.env.NODE_ENV !== 'test' && !data.skipSync) {\n const syncConfig = sync?.find((conf) => conf.collection === collectionSlug)\n\n if (syncConfig) {\n if (operation === 'update') {\n // combine all fields of this object and match their respective values within the document\n let syncedFields = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[stripeProperty] = data[fieldPath]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedFields = deepen(syncedFields)\n\n if (logs)\n payload.logger.info(\n `A '${collectionSlug}' document has changed in Payload with ID: '${originalDoc?._id}', syncing with Stripe...`,\n )\n\n if (!data.stripeID) {\n // NOTE: the \"beforeValidate\" hook populates this\n if (logs) payload.logger.error(`- There is no Stripe ID for this document, skipping.`)\n } else {\n if (logs)\n payload.logger.info(`- Syncing to Stripe resource with ID: '${data.stripeID}'...`)\n\n try {\n const stripeResource = await stripe?.[syncConfig?.stripeResourceType]?.update(\n data.stripeID,\n syncedFields,\n )\n\n if (logs)\n payload.logger.info(\n `✅ Successfully synced Stripe resource with ID: '${stripeResource.id}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n throw new APIError(`Failed to sync document with ID: '${data.id}' to Stripe: ${msg}`)\n }\n }\n }\n }\n }\n\n // Set back to 'false' so that all changes continue to sync to Stripe, see note in './createNewInStripe.ts'\n data.skipSync = false\n\n return data\n}\n"],"names":["APIError","Stripe","deepen","stripeSecretKey","process","env","STRIPE_SECRET_KEY","stripe","apiVersion","syncExistingWithStripe","args","collection","data","operation","originalDoc","pluginConfig","req","logs","sync","payload","slug","collectionSlug","NODE_ENV","skipSync","syncConfig","find","conf","syncedFields","fields","reduce","acc","field","fieldPath","stripeProperty","logger","info","_id","stripeID","error","stripeResource","stripeResourceType","update","id","msg","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAClC,OAAOC,YAAY,SAAQ;AAI3B,SAASC,MAAM,QAAQ,yBAAwB;AAE/C,MAAMC,kBAAkBC,QAAQC,GAAG,CAACC,iBAAiB;AACrD,uEAAuE;AACvE,MAAMC,SAAS,IAAIN,OAAOE,mBAAmB,IAAI;IAAEK,YAAY;AAAa;AAgB5E,OAAO,MAAMC,yBAA6D,OAAOC;IAC/E,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGN;IAExE,MAAM,EAAEO,IAAI,EAAEC,IAAI,EAAE,GAAGH,gBAAgB,CAAC;IAExC,MAAM,EAAEI,OAAO,EAAE,GAAGH;IAEpB,MAAM,EAAEI,MAAMC,cAAc,EAAE,GAAGV,cAAc,CAAC;IAEhD,IAAIP,QAAQC,GAAG,CAACiB,QAAQ,KAAK,UAAU,CAACV,KAAKW,QAAQ,EAAE;QACrD,MAAMC,aAAaN,MAAMO,KAAK,CAACC,OAASA,KAAKf,UAAU,KAAKU;QAE5D,IAAIG,YAAY;YACd,IAAIX,cAAc,UAAU;gBAC1B,0FAA0F;gBAC1F,IAAIc,eAAeH,WAAWI,MAAM,CAACC,MAAM,CACzC,CAACC,KAAKC;oBACJ,MAAM,EAAEC,SAAS,EAAEC,cAAc,EAAE,GAAGF;oBAEtCD,GAAG,CAACG,eAAe,GAAGrB,IAAI,CAACoB,UAAU;oBACrC,OAAOF;gBACT,GACA,CAAC;gBAGHH,eAAezB,OAAOyB;gBAEtB,IAAIV,MACFE,QAAQe,MAAM,CAACC,IAAI,CACjB,CAAC,GAAG,EAAEd,eAAe,4CAA4C,EAAEP,aAAasB,IAAI,yBAAyB,CAAC;gBAGlH,IAAI,CAACxB,KAAKyB,QAAQ,EAAE;oBAClB,iDAAiD;oBACjD,IAAIpB,MAAME,QAAQe,MAAM,CAACI,KAAK,CAAC,CAAC,oDAAoD,CAAC;gBACvF,OAAO;oBACL,IAAIrB,MACFE,QAAQe,MAAM,CAACC,IAAI,CAAC,CAAC,uCAAuC,EAAEvB,KAAKyB,QAAQ,CAAC,IAAI,CAAC;oBAEnF,IAAI;wBACF,MAAME,iBAAiB,MAAMhC,QAAQ,CAACiB,YAAYgB,mBAAmB,EAAEC,OACrE7B,KAAKyB,QAAQ,EACbV;wBAGF,IAAIV,MACFE,QAAQe,MAAM,CAACC,IAAI,CACjB,CAAC,gDAAgD,EAAEI,eAAeG,EAAE,CAAC,EAAE,CAAC;oBAE9E,EAAE,OAAOJ,OAAgB;wBACvB,MAAMK,MAAML,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGP;wBACrD,MAAM,IAAItC,SAAS,CAAC,kCAAkC,EAAEY,KAAK8B,EAAE,CAAC,aAAa,EAAEC,IAAI,CAAC;oBACtF;gBACF;YACF;QACF;IACF;IAEA,2GAA2G;IAC3G/B,KAAKW,QAAQ,GAAG;IAEhB,OAAOX;AACT,EAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config } from 'payload/config';
1
+ import type { Config } from 'payload';
2
2
  import type { StripePluginConfig } from './types.js';
3
3
  export { LinkToDoc } from './ui/LinkToDoc.js';
4
4
  export { stripeProxy } from './utilities/stripeProxy.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,gBAAgB,CAAA;AAEtD,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AASjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAmGjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AASjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAmGjB,CAAA"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload/config'\n\nimport type { SanitizedStripePluginConfig, StripePluginConfig } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\nimport { createNewInStripe } from './hooks/createNewInStripe.js'\nimport { deleteFromStripe } from './hooks/deleteFromStripe.js'\nimport { syncExistingWithStripe } from './hooks/syncExistingWithStripe.js'\nimport { stripeREST } from './routes/rest.js'\nimport { stripeWebhooks } from './routes/webhooks.js'\n\nexport { LinkToDoc } from './ui/LinkToDoc.js'\nexport { stripeProxy } from './utilities/stripeProxy.js'\n\nexport const stripePlugin =\n (incomingStripeConfig: StripePluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // set config defaults here\n const pluginConfig: SanitizedStripePluginConfig = {\n ...incomingStripeConfig,\n rest: incomingStripeConfig?.rest ?? false,\n sync: incomingStripeConfig?.sync || [],\n }\n\n // NOTE: env variables are never passed to the client, but we need to know if `stripeSecretKey` is a test key\n // unfortunately we must set the 'isTestKey' property on the config instead of using the following code:\n // const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');\n\n const endpoints: Endpoint[] = [\n ...(config?.endpoints || []),\n {\n handler: async (req) => {\n const res = await stripeWebhooks({\n config,\n pluginConfig,\n req,\n })\n\n return res\n },\n method: 'post',\n path: '/stripe/webhooks',\n },\n ]\n\n if (incomingStripeConfig?.rest) {\n endpoints.push({\n handler: async (req) => {\n const res = await stripeREST({\n pluginConfig,\n req,\n })\n\n return res\n },\n method: 'post' as Endpoint['method'],\n path: '/stripe/rest',\n })\n }\n\n return {\n ...config,\n collections: collections?.map((collection) => {\n const { hooks: existingHooks } = collection\n\n const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)\n\n if (syncConfig) {\n const fields = getFields({\n collection,\n pluginConfig,\n syncConfig,\n })\n return {\n ...collection,\n fields,\n hooks: {\n ...collection.hooks,\n afterDelete: [\n ...(existingHooks?.afterDelete || []),\n (args) =>\n deleteFromStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n beforeChange: [\n ...(existingHooks?.beforeChange || []),\n (args) =>\n syncExistingWithStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n beforeValidate: [\n ...(existingHooks?.beforeValidate || []),\n (args) =>\n createNewInStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n },\n }\n }\n\n return collection\n }),\n endpoints,\n }\n }\n"],"names":["getFields","createNewInStripe","deleteFromStripe","syncExistingWithStripe","stripeREST","stripeWebhooks","LinkToDoc","stripeProxy","stripePlugin","incomingStripeConfig","config","collections","pluginConfig","rest","sync","endpoints","handler","req","res","method","path","push","map","collection","hooks","existingHooks","syncConfig","find","slug","fields","afterDelete","args","beforeChange","beforeValidate"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,S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BACAL,OAAO;4BACL,GAAGD,WAAWC,KAAK;4BACnBM,aAAa;mCACPL,eAAeK,eAAe,EAAE;gCACpC,CAACC,OACC7B,iBAAiB;wCACf,GAAG6B,IAAI;wCACPR;wCACAX;oCACF;6BACH;4BACDoB,cAAc;mCACRP,eAAeO,gBAAgB,EAAE;gCACrC,CAACD,OACC5B,uBAAuB;wCACrB,GAAG4B,IAAI;wCACPR;wCACAX;oCACF;6BACH;4BACDqB,gBAAgB;mCACVR,eAAeQ,kBAAkB,EAAE;gCACvC,CAACF,OACC9B,kBAAkB;wCAChB,GAAG8B,IAAI;wCACPR;wCACAX;oCACF;6BACH;wBACH;oBACF;gBACF;gBAEA,OAAOW;YACT;YACAR;QACF;IACF,EAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload'\n\nimport type { SanitizedStripePluginConfig, StripePluginConfig } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\nimport { createNewInStripe } from './hooks/createNewInStripe.js'\nimport { deleteFromStripe } from './hooks/deleteFromStripe.js'\nimport { syncExistingWithStripe } from './hooks/syncExistingWithStripe.js'\nimport { stripeREST } from './routes/rest.js'\nimport { stripeWebhooks } from './routes/webhooks.js'\n\nexport { LinkToDoc } from './ui/LinkToDoc.js'\nexport { stripeProxy } from './utilities/stripeProxy.js'\n\nexport const stripePlugin =\n (incomingStripeConfig: StripePluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // set config defaults here\n const pluginConfig: SanitizedStripePluginConfig = {\n ...incomingStripeConfig,\n rest: incomingStripeConfig?.rest ?? false,\n sync: incomingStripeConfig?.sync || [],\n }\n\n // NOTE: env variables are never passed to the client, but we need to know if `stripeSecretKey` is a test key\n // unfortunately we must set the 'isTestKey' property on the config instead of using the following code:\n // const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');\n\n const endpoints: Endpoint[] = [\n ...(config?.endpoints || []),\n {\n handler: async (req) => {\n const res = await stripeWebhooks({\n config,\n pluginConfig,\n req,\n })\n\n return res\n },\n method: 'post',\n path: '/stripe/webhooks',\n },\n ]\n\n if (incomingStripeConfig?.rest) {\n endpoints.push({\n handler: async (req) => {\n const res = await stripeREST({\n pluginConfig,\n req,\n })\n\n return res\n },\n method: 'post' as Endpoint['method'],\n path: '/stripe/rest',\n })\n }\n\n return {\n ...config,\n collections: collections?.map((collection) => {\n const { hooks: existingHooks } = collection\n\n const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)\n\n if (syncConfig) {\n const fields = getFields({\n collection,\n pluginConfig,\n syncConfig,\n })\n return {\n ...collection,\n fields,\n hooks: {\n ...collection.hooks,\n afterDelete: [\n ...(existingHooks?.afterDelete || []),\n (args) =>\n deleteFromStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n beforeChange: [\n ...(existingHooks?.beforeChange || []),\n (args) =>\n syncExistingWithStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n beforeValidate: [\n ...(existingHooks?.beforeValidate || []),\n (args) =>\n createNewInStripe({\n ...args,\n collection,\n pluginConfig,\n }),\n ],\n },\n }\n }\n\n return collection\n }),\n endpoints,\n }\n }\n"],"names":["getFields","createNewInStripe","deleteFromStripe","syncExistingWithStripe","stripeREST","stripeWebhooks","LinkToDoc","stripeProxy","stripePlugin","incomingStripeConfig","config","collections","pluginConfig","rest","sync","endpoints","handler","req","res","method","path","push","map","collection","hooks","existingHooks","syncConfig","find","slug","fields","afterDelete","args","beforeChange","beforeValidate"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,wBAAuB;AACjD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,UAAU,QAAQ,m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ACDoB,cAAc;mCACRP,eAAeO,gBAAgB,EAAE;gCACrC,CAACD,OACC5B,uBAAuB;wCACrB,GAAG4B,IAAI;wCACPR;wCACAX;oCACF;6BACH;4BACDqB,gBAAgB;mCACVR,eAAeQ,kBAAkB,EAAE;gCACvC,CAACF,OACC9B,kBAAkB;wCAChB,GAAG8B,IAAI;wCACPR;wCACAX;oCACF;6BACH;wBACH;oBACF;gBACF;gBAEA,OAAOW;YACT;YACAR;QACF;IACF,EAAC"}
@@ -1,7 +1,7 @@
1
- import type { PayloadRequestWithData } from 'payload/types';
1
+ import type { PayloadRequest } from 'payload';
2
2
  import type { StripePluginConfig } from '../types.js';
3
3
  export declare const stripeREST: (args: {
4
4
  pluginConfig: StripePluginConfig;
5
- req: PayloadRequestWithData;
5
+ req: PayloadRequest;
6
6
  }) => Promise<any>;
7
7
  //# sourceMappingURL=rest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/routes/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAI3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,UAAU,SAAgB;IACrC,YAAY,EAAE,kBAAkB,CAAA;IAChC,GAAG,EAAE,sBAAsB,CAAA;CAC5B,KAAG,QAAQ,GAAG,CA+Cd,CAAA"}
1
+ {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/routes/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAA;AAKrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,UAAU,SAAgB;IACrC,YAAY,EAAE,kBAAkB,CAAA;IAChC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,GAAG,CAmDd,CAAA"}
@@ -1,10 +1,15 @@
1
- import { Forbidden } from 'payload/errors';
1
+ import { addDataAndFileToRequest } from '@payloadcms/next/utilities';
2
+ import { Forbidden } from 'payload';
2
3
  import { stripeProxy } from '../utilities/stripeProxy.js';
3
4
  export const stripeREST = async (args)=>{
4
5
  let responseStatus = 200;
5
6
  let responseJSON;
6
7
  const { pluginConfig, req } = args;
7
- const { data: { stripeArgs, stripeMethod }, payload, user } = req;
8
+ await addDataAndFileToRequest({
9
+ request: req
10
+ });
11
+ const requestWithData = req;
12
+ const { data: { stripeArgs, stripeMethod }, payload, user } = requestWithData;
8
13
  const { stripeSecretKey } = pluginConfig;
9
14
  try {
10
15
  if (!user) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/routes/rest.ts"],"sourcesContent":["import type { PayloadRequestWithData } from 'payload/types'\n\nimport { Forbidden } from 'payload/errors'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { stripeProxy } from '../utilities/stripeProxy.js'\n\nexport const stripeREST = async (args: {\n pluginConfig: StripePluginConfig\n req: PayloadRequestWithData\n}): Promise<any> => {\n let responseStatus = 200\n let responseJSON\n\n const { pluginConfig, req } = args\n\n const {\n data: {\n stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]\n stripeMethod, // example: 'subscriptions.list',\n },\n payload,\n user,\n } = req\n\n const { stripeSecretKey } = pluginConfig\n\n try {\n if (!user) {\n // TODO: make this customizable from the config\n throw new Forbidden(req.t)\n }\n\n responseJSON = await stripeProxy({\n // @ts-expect-error\n stripeArgs,\n // @ts-expect-error\n stripeMethod,\n stripeSecretKey,\n })\n\n const { status } = responseJSON\n responseStatus = status\n } catch (error: unknown) {\n const message = `An error has occurred in the Stripe plugin REST handler: '${JSON.stringify(\n error,\n )}'`\n payload.logger.error(message)\n responseStatus = 500\n responseJSON = {\n message,\n }\n }\n\n return Response.json(responseJSON, {\n status: responseStatus,\n })\n}\n"],"names":["Forbidden","stripeProxy","stripeREST","args","responseStatus","responseJSON","pluginConfig","req","data","stripeArgs","stripeMethod","payload","user","stripeSecretKey","t","status","error","message","JSON","stringify","logger","Response","json"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAI1C,SAASC,WAAW,QAAQ,8BAA6B;AAEzD,OAAO,MAAMC,aAAa,OAAOC;IAI/B,IAAIC,iBAAiB;IACrB,IAAIC;IAEJ,MAAM,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGJ;IAE9B,MAAM,EACJK,MAAM,EACJC,UAAU,EACVC,YAAY,EACb,EACDC,OAAO,EACPC,IAAI,EACL,GAAGL;IAEJ,MAAM,EAAEM,eAAe,EAAE,GAAGP;IAE5B,IAAI;QACF,IAAI,CAACM,MAAM;YACT,+CAA+C;YAC/C,MAAM,IAAIZ,UAAUO,IAAIO,CAAC;QAC3B;QAEAT,eAAe,MAAMJ,YAAY;YAC/B,mBAAmB;YACnBQ;YACA,mBAAmB;YACnBC;YACAG;QACF;QAEA,MAAM,EAAEE,MAAM,EAAE,GAAGV;QACnBD,iBAAiBW;IACnB,EAAE,OAAOC,OAAgB;QACvB,MAAMC,UAAU,CAAC,0DAA0D,EAAEC,KAAKC,SAAS,CACzFH,OACA,CAAC,CAAC;QACJL,QAAQS,MAAM,CAACJ,KAAK,CAACC;QACrBb,iBAAiB;QACjBC,eAAe;YACbY;QACF;IACF;IAEA,OAAOI,SAASC,IAAI,CAACjB,cAAc;QACjCU,QAAQX;IACV;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/routes/rest.ts"],"sourcesContent":["import type { PayloadRequest, PayloadRequestWithData } from 'payload'\n\nimport { addDataAndFileToRequest } from '@payloadcms/next/utilities'\nimport { Forbidden } from 'payload'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { stripeProxy } from '../utilities/stripeProxy.js'\n\nexport const stripeREST = async (args: {\n pluginConfig: StripePluginConfig\n req: PayloadRequest\n}): Promise<any> => {\n let responseStatus = 200\n let responseJSON\n\n const { pluginConfig, req } = args\n\n await addDataAndFileToRequest({ request: req })\n\n const requestWithData = req as PayloadRequestWithData\n\n const {\n data: {\n stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]\n stripeMethod, // example: 'subscriptions.list',\n },\n payload,\n user,\n } = requestWithData\n\n const { stripeSecretKey } = pluginConfig\n\n try {\n if (!user) {\n // TODO: make this customizable from the config\n throw new Forbidden(req.t)\n }\n\n responseJSON = await stripeProxy({\n // @ts-expect-error\n stripeArgs,\n // @ts-expect-error\n stripeMethod,\n stripeSecretKey,\n })\n\n const { status } = responseJSON\n responseStatus = status\n } catch (error: unknown) {\n const message = `An error has occurred in the Stripe plugin REST handler: '${JSON.stringify(\n error,\n )}'`\n payload.logger.error(message)\n responseStatus = 500\n responseJSON = {\n message,\n }\n }\n\n return Response.json(responseJSON, {\n status: responseStatus,\n })\n}\n"],"names":["addDataAndFileToRequest","Forbidden","stripeProxy","stripeREST","args","responseStatus","responseJSON","pluginConfig","req","request","requestWithData","data","stripeArgs","stripeMethod","payload","user","stripeSecretKey","t","status","error","message","JSON","stringify","logger","Response","json"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,uBAAuB,QAAQ,6BAA4B;AACpE,SAASC,SAAS,QAAQ,UAAS;AAInC,SAASC,WAAW,QAAQ,8BAA6B;AAEzD,OAAO,MAAMC,aAAa,OAAOC;IAI/B,IAAIC,iBAAiB;IACrB,IAAIC;IAEJ,MAAM,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGJ;IAE9B,MAAMJ,wBAAwB;QAAES,SAASD;IAAI;IAE7C,MAAME,kBAAkBF;IAExB,MAAM,EACJG,MAAM,EACJC,UAAU,EACVC,YAAY,EACb,EACDC,OAAO,EACPC,IAAI,EACL,GAAGL;IAEJ,MAAM,EAAEM,eAAe,EAAE,GAAGT;IAE5B,IAAI;QACF,IAAI,CAACQ,MAAM;YACT,+CAA+C;YAC/C,MAAM,IAAId,UAAUO,IAAIS,CAAC;QAC3B;QAEAX,eAAe,MAAMJ,YAAY;YAC/B,mBAAmB;YACnBU;YACA,mBAAmB;YACnBC;YACAG;QACF;QAEA,MAAM,EAAEE,MAAM,EAAE,GAAGZ;QACnBD,iBAAiBa;IACnB,EAAE,OAAOC,OAAgB;QACvB,MAAMC,UAAU,CAAC,0DAA0D,EAAEC,KAAKC,SAAS,CACzFH,OACA,CAAC,CAAC;QACJL,QAAQS,MAAM,CAACJ,KAAK,CAACC;QACrBf,iBAAiB;QACjBC,eAAe;YACbc;QACF;IACF;IAEA,OAAOI,SAASC,IAAI,CAACnB,cAAc;QACjCY,QAAQb;IACV;AACF,EAAC"}
@@ -1,9 +1,8 @@
1
- import type { Config as PayloadConfig } from 'payload/config';
2
- import type { PayloadRequestWithData } from 'payload/types';
1
+ import type { Config as PayloadConfig, PayloadRequest } from 'payload';
3
2
  import type { StripePluginConfig } from '../types.js';
4
3
  export declare const stripeWebhooks: (args: {
5
4
  config: PayloadConfig;
6
5
  pluginConfig: StripePluginConfig;
7
- req: PayloadRequestWithData;
6
+ req: PayloadRequest;
8
7
  }) => Promise<any>;
9
8
  //# sourceMappingURL=webhooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAI3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,cAAc,SAAgB;IACzC,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,kBAAkB,CAAA;IAChC,GAAG,EAAE,sBAAsB,CAAA;CAC5B,KAAG,QAAQ,GAAG,CAwEd,CAAA"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAItE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,cAAc,SAAgB;IACzC,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,kBAAkB,CAAA;IAChC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,GAAG,CA2Ed,CAAA"}
@@ -30,6 +30,7 @@ export const stripeWebhooks = async (args)=>{
30
30
  event,
31
31
  payload: req.payload,
32
32
  pluginConfig,
33
+ req,
33
34
  stripe
34
35
  });
35
36
  // Fire external webhook handlers if they exist
@@ -39,6 +40,7 @@ export const stripeWebhooks = async (args)=>{
39
40
  event,
40
41
  payload: req.payload,
41
42
  pluginConfig,
43
+ req,
42
44
  stripe
43
45
  });
44
46
  }
@@ -50,6 +52,7 @@ export const stripeWebhooks = async (args)=>{
50
52
  event,
51
53
  payload: req.payload,
52
54
  pluginConfig,
55
+ req,
53
56
  stripe
54
57
  });
55
58
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/routes/webhooks.ts"],"sourcesContent":["import type { Config as PayloadConfig } from 'payload/config'\nimport type { PayloadRequestWithData } from 'payload/types'\n\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { handleWebhooks } from '../webhooks/index.js'\n\nexport const stripeWebhooks = async (args: {\n config: PayloadConfig\n pluginConfig: StripePluginConfig\n req: PayloadRequestWithData\n}): Promise<any> => {\n const { config, pluginConfig, req } = args\n let returnStatus = 200\n\n const { stripeSecretKey, stripeWebhooksEndpointSecret, webhooks } = pluginConfig\n\n if (stripeWebhooksEndpointSecret) {\n const stripe = new Stripe(stripeSecretKey, {\n // api version can only be the latest, stripe recommends ts ignoring it\n apiVersion: '2022-08-01',\n 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, stripeWebhooksEndpointSecret)\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 (event) {\n handleWebhooks({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n stripe,\n })\n\n // Fire external webhook handlers if they exist\n if (typeof webhooks === 'function') {\n webhooks({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n stripe,\n })\n }\n\n if (typeof webhooks === 'object') {\n const webhookEventHandler = webhooks[event.type]\n if (typeof webhookEventHandler === 'function') {\n webhookEventHandler({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n stripe,\n })\n }\n }\n }\n }\n }\n\n return Response.json(\n { received: true },\n {\n status: returnStatus,\n },\n )\n}\n"],"names":["Stripe","handleWebhooks","stripeWebhooks","args","config","pluginConfig","req","returnStatus","stripeSecretKey","stripeWebhooksEndpointSecret","webhooks","stripe","apiVersion","appInfo","name","url","body","text","stripeSignature","headers","get","event","constructEvent","err","msg","Error","message","JSON","stringify","payload","logger","error","webhookEventHandler","type","Response","json","received","status"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,YAAY,SAAQ;AAI3B,SAASC,cAAc,QAAQ,uBAAsB;AAErD,OAAO,MAAMC,iBAAiB,OAAOC;IAKnC,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGH;IACtC,IAAII,eAAe;IAEnB,MA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sourcesContent":["import type { Config as PayloadConfig, PayloadRequest } from 'payload'\n\nimport Stripe from 'stripe'\n\nimport type { StripePluginConfig } from '../types.js'\n\nimport { handleWebhooks } from '../webhooks/index.js'\n\nexport const stripeWebhooks = async (args: {\n config: PayloadConfig\n pluginConfig: StripePluginConfig\n req: PayloadRequest\n}): Promise<any> => {\n const { config, pluginConfig, req } = args\n let returnStatus = 200\n\n const { stripeSecretKey, stripeWebhooksEndpointSecret, webhooks } = pluginConfig\n\n if (stripeWebhooksEndpointSecret) {\n const stripe = new Stripe(stripeSecretKey, {\n // api version can only be the latest, stripe recommends ts ignoring it\n apiVersion: '2022-08-01',\n 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, stripeWebhooksEndpointSecret)\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 (event) {\n handleWebhooks({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n req,\n stripe,\n })\n\n // Fire external webhook handlers if they exist\n if (typeof webhooks === 'function') {\n webhooks({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n req,\n stripe,\n })\n }\n\n if (typeof webhooks === 'object') {\n const webhookEventHandler = webhooks[event.type]\n if (typeof webhookEventHandler === 'function') {\n webhookEventHandler({\n config,\n event,\n payload: req.payload,\n pluginConfig,\n req,\n stripe,\n })\n }\n }\n }\n }\n }\n\n return Response.json(\n { received: true },\n {\n status: returnStatus,\n },\n )\n}\n"],"names":["Stripe","handleWebhooks","stripeWebhooks","args","config","pluginConfig","req","returnStatus","stripeSecretKey","stripeWebhooksEndpointSecret","webhooks","stripe","apiVersion","appInfo","name","url","body","text","stripeSignature","headers","get","event","constructEvent","err","msg","Error","message","JSON","stringify","payload","logger","error","webhookEventHandler","type","Response","json","received","status"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,YAAY,SAAQ;AAI3B,SAASC,cAAc,QAAQ,uBAAsB;AAErD,OAAO,MAAMC,iBAAiB,OAAOC;IAKnC,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGH;IACtC,IAAII,eAAe;IAEnB,MAAM,EAAEC,eAAe,EAAEC,4BAA4B,EAAEC,QAAQ,EAAE,GAAGL;IAEpE,IAAII,8BAA8B;QAChC,MAAME,SAAS,IAAIX,OAAOQ,iBAAiB;YACzC,uEAAuE;YACvEI,YAAY;YACZC,SAAS;gBACPC,MAAM;gBACNC,KAAK;YACP;QACF;QAEA,MAAMC,OAAO,MAAMV,IAAIW,IAAI;QAC3B,MAAMC,kBAAkBZ,IAAIa,OAAO,CAACC,GAAG,CAAC;QAExC,IAAIF,iBAAiB;YACnB,IAAIG;YAEJ,IAAI;gBACFA,QAAQV,OAAOD,QAAQ,CAACY,cAAc,CAACN,MAAME,iBAAiBT;YAChE,EAAE,OAAOc,KAAc;gBACrB,MAAMC,MAAcD,eAAeE,QAAQF,IAAIG,OAAO,GAAGC,KAAKC,SAAS,CAACL;gBACxEjB,IAAIuB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,iCAAiC,EAAEP,IAAI,CAAC;gBAClEjB,eAAe;YACjB;YAEA,IAAIc,OAAO;gBACTpB,eAAe;oBACbG;oBACAiB;oBACAQ,SAASvB,IAAIuB,OAAO;oBACpBxB;oBACAC;oBACAK;gBACF;gBAEA,+CAA+C;gBAC/C,IAAI,OAAOD,aAAa,YAAY;oBAClCA,SAAS;wBACPN;wBACAiB;wBACAQ,SAASvB,IAAIuB,OAAO;wBACpBxB;wBACAC;wBACAK;oBACF;gBACF;gBAEA,IAAI,OAAOD,aAAa,UAAU;oBAChC,MAAMsB,sBAAsBtB,QAAQ,CAACW,MAAMY,IAAI,CAAC;oBAChD,IAAI,OAAOD,wBAAwB,YAAY;wBAC7CA,oBAAoB;4BAClB5B;4BACAiB;4BACAQ,SAASvB,IAAIuB,OAAO;4BACpBxB;4BACAC;4BACAK;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOuB,SAASC,IAAI,CAClB;QAAEC,UAAU;IAAK,GACjB;QACEC,QAAQ9B;IACV;AAEJ,EAAC"}
package/dist/types.d.ts CHANGED
@@ -1,137 +1,11 @@
1
- /// <reference types="stripe/types/crypto/crypto.js" />
2
- /// <reference types="stripe/types/shared.js" />
3
- /// <reference types="stripe/types/Errors.js" />
4
- /// <reference types="stripe/types/OAuth.js" />
5
- /// <reference types="stripe/types/Webhooks.js" />
6
- /// <reference types="stripe/types/2022-08-01/AccountLinks.js" />
7
- /// <reference types="stripe/types/2022-08-01/Accounts.js" />
8
- /// <reference types="stripe/types/2022-08-01/ApplePayDomains.js" />
9
- /// <reference types="stripe/types/2022-08-01/ApplicationFees.js" />
10
- /// <reference types="stripe/types/2022-08-01/Applications.js" />
11
- /// <reference types="stripe/types/2022-08-01/Apps/Secrets.js" />
12
- /// <reference types="stripe/types/2022-08-01/Balance.js" />
13
- /// <reference types="stripe/types/2022-08-01/BalanceTransactions.js" />
14
- /// <reference types="stripe/types/2022-08-01/BankAccounts.js" />
15
- /// <reference types="stripe/types/2022-08-01/BillingPortal/Configurations.js" />
16
- /// <reference types="stripe/types/2022-08-01/BillingPortal/Sessions.js" />
17
- /// <reference types="stripe/types/2022-08-01/Capabilities.js" />
18
- /// <reference types="stripe/types/2022-08-01/Cards.js" />
19
- /// <reference types="stripe/types/2022-08-01/CashBalances.js" />
20
- /// <reference types="stripe/types/2022-08-01/Charges.js" />
21
- /// <reference types="stripe/types/2022-08-01/Checkout/Sessions.js" />
22
- /// <reference types="stripe/types/2022-08-01/ConnectCollectionTransfers.js" />
23
- /// <reference types="stripe/types/2022-08-01/CountrySpecs.js" />
24
- /// <reference types="stripe/types/2022-08-01/Coupons.js" />
25
- /// <reference types="stripe/types/2022-08-01/CreditNoteLineItems.js" />
26
- /// <reference types="stripe/types/2022-08-01/CreditNotes.js" />
27
- /// <reference types="stripe/types/2022-08-01/CustomerBalanceTransactions.js" />
28
- /// <reference types="stripe/types/2022-08-01/CustomerCashBalanceTransactions.js" />
29
- /// <reference types="stripe/types/2022-08-01/CustomerSources.js" />
30
- /// <reference types="stripe/types/2022-08-01/Customers.js" />
31
- /// <reference types="stripe/types/2022-08-01/Discounts.js" />
32
- /// <reference types="stripe/types/2022-08-01/Disputes.js" />
33
- /// <reference types="stripe/types/2022-08-01/EphemeralKeys.js" />
34
- /// <reference types="stripe/types/2022-08-01/Events.js" />
35
- /// <reference types="stripe/types/2022-08-01/ExchangeRates.js" />
36
- /// <reference types="stripe/types/2022-08-01/ExternalAccounts.js" />
37
- /// <reference types="stripe/types/2022-08-01/FeeRefunds.js" />
38
- /// <reference types="stripe/types/2022-08-01/FileLinks.js" />
39
- /// <reference types="stripe/types/2022-08-01/Files.js" />
40
- /// <reference types="stripe/types/2022-08-01/FinancialConnections/AccountOwners.js" />
41
- /// <reference types="stripe/types/2022-08-01/FinancialConnections/AccountOwnerships.js" />
42
- /// <reference types="stripe/types/2022-08-01/FinancialConnections/Accounts.js" />
43
- /// <reference types="stripe/types/2022-08-01/FinancialConnections/Sessions.js" />
44
- /// <reference types="stripe/types/2022-08-01/FundingInstructions.js" />
45
- /// <reference types="stripe/types/2022-08-01/Identity/VerificationReports.js" />
46
- /// <reference types="stripe/types/2022-08-01/Identity/VerificationSessions.js" />
47
- /// <reference types="stripe/types/2022-08-01/InvoiceItems.js" />
48
- /// <reference types="stripe/types/2022-08-01/InvoiceLineItems.js" />
49
- /// <reference types="stripe/types/2022-08-01/Invoices.js" />
50
- /// <reference types="stripe/types/2022-08-01/Issuing/Authorizations.js" />
51
- /// <reference types="stripe/types/2022-08-01/Issuing/Cardholders.js" />
52
- /// <reference types="stripe/types/2022-08-01/Issuing/Cards.js" />
53
- /// <reference types="stripe/types/2022-08-01/Issuing/Disputes.js" />
54
- /// <reference types="stripe/types/2022-08-01/Issuing/Transactions.js" />
55
- /// <reference types="stripe/types/2022-08-01/LineItems.js" />
56
- /// <reference types="stripe/types/2022-08-01/LoginLinks.js" />
57
- /// <reference types="stripe/types/2022-08-01/Mandates.js" />
58
- /// <reference types="stripe/types/2022-08-01/Orders.js" />
59
- /// <reference types="stripe/types/2022-08-01/PaymentIntents.js" />
60
- /// <reference types="stripe/types/2022-08-01/PaymentLinks.js" />
61
- /// <reference types="stripe/types/2022-08-01/PaymentMethods.js" />
62
- /// <reference types="stripe/types/2022-08-01/Payouts.js" />
63
- /// <reference types="stripe/types/2022-08-01/Persons.js" />
64
- /// <reference types="stripe/types/2022-08-01/Plans.js" />
65
- /// <reference types="stripe/types/2022-08-01/PlatformTaxFees.js" />
66
- /// <reference types="stripe/types/2022-08-01/Prices.js" />
67
- /// <reference types="stripe/types/2022-08-01/Products.js" />
68
- /// <reference types="stripe/types/2022-08-01/PromotionCodes.js" />
69
- /// <reference types="stripe/types/2022-08-01/Quotes.js" />
70
- /// <reference types="stripe/types/2022-08-01/Radar/EarlyFraudWarnings.js" />
71
- /// <reference types="stripe/types/2022-08-01/Radar/ValueListItems.js" />
72
- /// <reference types="stripe/types/2022-08-01/Radar/ValueLists.js" />
73
- /// <reference types="stripe/types/2022-08-01/Refunds.js" />
74
- /// <reference types="stripe/types/2022-08-01/Reporting/ReportRuns.js" />
75
- /// <reference types="stripe/types/2022-08-01/Reporting/ReportTypes.js" />
76
- /// <reference types="stripe/types/2022-08-01/ReserveTransactions.js" />
77
- /// <reference types="stripe/types/2022-08-01/Reviews.js" />
78
- /// <reference types="stripe/types/2022-08-01/SKUs.js" />
79
- /// <reference types="stripe/types/2022-08-01/SetupAttempts.js" />
80
- /// <reference types="stripe/types/2022-08-01/SetupIntents.js" />
81
- /// <reference types="stripe/types/2022-08-01/ShippingRates.js" />
82
- /// <reference types="stripe/types/2022-08-01/Sigma/ScheduledQueryRuns.js" />
83
- /// <reference types="stripe/types/2022-08-01/SourceMandateNotifications.js" />
84
- /// <reference types="stripe/types/2022-08-01/SourceTransactions.js" />
85
- /// <reference types="stripe/types/2022-08-01/Sources.js" />
86
- /// <reference types="stripe/types/2022-08-01/SubscriptionItems.js" />
87
- /// <reference types="stripe/types/2022-08-01/SubscriptionSchedules.js" />
88
- /// <reference types="stripe/types/2022-08-01/Subscriptions.js" />
89
- /// <reference types="stripe/types/2022-08-01/TaxCodes.js" />
90
- /// <reference types="stripe/types/2022-08-01/TaxDeductedAtSources.js" />
91
- /// <reference types="stripe/types/2022-08-01/TaxIds.js" />
92
- /// <reference types="stripe/types/2022-08-01/TaxRates.js" />
93
- /// <reference types="stripe/types/2022-08-01/Terminal/Configurations.js" />
94
- /// <reference types="stripe/types/2022-08-01/Terminal/ConnectionTokens.js" />
95
- /// <reference types="stripe/types/2022-08-01/Terminal/Locations.js" />
96
- /// <reference types="stripe/types/2022-08-01/Terminal/Readers.js" />
97
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Customers.js" />
98
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Issuing/Cards.js" />
99
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Refunds.js" />
100
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Terminal/Readers.js" />
101
- /// <reference types="stripe/types/2022-08-01/TestHelpers/TestClocks.js" />
102
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Treasury/InboundTransfers.js" />
103
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Treasury/OutboundPayments.js" />
104
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Treasury/OutboundTransfers.js" />
105
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Treasury/ReceivedCredits.js" />
106
- /// <reference types="stripe/types/2022-08-01/TestHelpers/Treasury/ReceivedDebits.js" />
107
- /// <reference types="stripe/types/2022-08-01/Tokens.js" />
108
- /// <reference types="stripe/types/2022-08-01/Topups.js" />
109
- /// <reference types="stripe/types/2022-08-01/TransferReversals.js" />
110
- /// <reference types="stripe/types/2022-08-01/Transfers.js" />
111
- /// <reference types="stripe/types/2022-08-01/Treasury/CreditReversals.js" />
112
- /// <reference types="stripe/types/2022-08-01/Treasury/DebitReversals.js" />
113
- /// <reference types="stripe/types/2022-08-01/Treasury/FinancialAccountFeatures.js" />
114
- /// <reference types="stripe/types/2022-08-01/Treasury/FinancialAccounts.js" />
115
- /// <reference types="stripe/types/2022-08-01/Treasury/InboundTransfers.js" />
116
- /// <reference types="stripe/types/2022-08-01/Treasury/OutboundPayments.js" />
117
- /// <reference types="stripe/types/2022-08-01/Treasury/OutboundTransfers.js" />
118
- /// <reference types="stripe/types/2022-08-01/Treasury/ReceivedCredits.js" />
119
- /// <reference types="stripe/types/2022-08-01/Treasury/ReceivedDebits.js" />
120
- /// <reference types="stripe/types/2022-08-01/Treasury/TransactionEntries.js" />
121
- /// <reference types="stripe/types/2022-08-01/Treasury/Transactions.js" />
122
- /// <reference types="stripe/types/2022-08-01/UsageRecordSummaries.js" />
123
- /// <reference types="stripe/types/2022-08-01/UsageRecords.js" />
124
- /// <reference types="stripe/types/2022-08-01/WebhookEndpoints.js" />
125
- /// <reference types="stripe/types/lib.js" />
126
- /// <reference types="stripe/types/net/net.js" />
127
- import type { Payload } from 'payload';
128
- import type { Config as PayloadConfig } from 'payload/config';
1
+ import type { Payload, Config as PayloadConfig, PayloadRequest } from 'payload';
129
2
  import type Stripe from 'stripe';
130
3
  export type StripeWebhookHandler<T = any> = (args: {
131
4
  config: PayloadConfig;
132
5
  event: T;
133
6
  payload: Payload;
134
7
  pluginConfig?: StripePluginConfig;
8
+ req: PayloadRequest;
135
9
  stripe: Stripe;
136
10
  }) => void;
137
11
  export type StripeWebhookHandlers = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":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IACzB,kBAAkB,EAAE,WAAW,GAAG,UAAU,CAAA;IAC5C,0BAA0B,EAAE,UAAU,GAAG,SAAS,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,qBAAqB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,MAAM,CAAA;IACvB,4BAA4B,CAAC,EAAE,MAAM,CAAA;IACrC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAA;IACnB,QAAQ,CAAC,EAAE,oBAAoB,GAAG,qBAAqB,CAAA;CACxD,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,GAAG;IAC7D,IAAI,EAAE,UAAU,EAAE,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE;IAC/B,UAAU,EAAE,GAAG,EAAE,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;CACxB,KAAK,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Config as PayloadConfig } from 'payload/config'\nimport type Stripe from 'stripe'\n\nexport type StripeWebhookHandler<T = any> = (args: {\n config: PayloadConfig\n event: T\n payload: Payload\n pluginConfig?: StripePluginConfig\n stripe: Stripe\n}) => void\n\nexport type StripeWebhookHandlers = {\n [webhookName: string]: StripeWebhookHandler\n}\n\nexport type FieldSyncConfig = {\n fieldPath: string\n stripeProperty: string\n}\n\nexport type SyncConfig = {\n collection: string\n fields: FieldSyncConfig[]\n stripeResourceType: 'customers' | 'products' // TODO: get this from Stripe types\n stripeResourceTypeSingular: 'customer' | 'product' // TODO: there must be a better way to do this\n}\n\nexport type StripePluginConfig = {\n isTestKey?: boolean\n logs?: boolean\n /** @default false */\n rest?: boolean\n stripeSecretKey: string\n stripeWebhooksEndpointSecret?: string\n sync?: SyncConfig[]\n webhooks?: StripeWebhookHandler | StripeWebhookHandlers\n}\n\nexport type SanitizedStripePluginConfig = StripePluginConfig & {\n sync: SyncConfig[] // convert to required\n}\n\nexport type StripeProxy = (args: {\n stripeArgs: any[]\n stripeMethod: string\n stripeSecretKey: string\n}) => Promise<{\n data?: any\n message?: string\n status: number\n}>\n"],"names":[],"rangeMappings":"","mappings":"AA2CA,WAQE"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Payload, Config as PayloadConfig, PayloadRequest } from 'payload'\nimport type Stripe from 'stripe'\n\nexport type StripeWebhookHandler<T = any> = (args: {\n config: PayloadConfig\n event: T\n payload: Payload\n pluginConfig?: StripePluginConfig\n req: PayloadRequest\n stripe: Stripe\n}) => void\n\nexport type StripeWebhookHandlers = {\n [webhookName: string]: StripeWebhookHandler\n}\n\nexport type FieldSyncConfig = {\n fieldPath: string\n stripeProperty: string\n}\n\nexport type SyncConfig = {\n collection: string\n fields: FieldSyncConfig[]\n stripeResourceType: 'customers' | 'products' // TODO: get this from Stripe types\n stripeResourceTypeSingular: 'customer' | 'product' // TODO: there must be a better way to do this\n}\n\nexport type StripePluginConfig = {\n isTestKey?: boolean\n logs?: boolean\n /** @default false */\n rest?: boolean\n stripeSecretKey: string\n stripeWebhooksEndpointSecret?: string\n sync?: SyncConfig[]\n webhooks?: StripeWebhookHandler | StripeWebhookHandlers\n}\n\nexport type SanitizedStripePluginConfig = StripePluginConfig & {\n sync: SyncConfig[] // convert to required\n}\n\nexport type StripeProxy = (args: {\n stripeArgs: any[]\n stripeMethod: string\n stripeSecretKey: string\n}) => Promise<{\n data?: any\n message?: string\n status: number\n}>\n"],"names":[],"rangeMappings":"","mappings":"AA2CA,WAQE"}
@@ -1,4 +1,3 @@
1
- import type { CustomComponent } from 'payload/config';
2
- import type { UIField } from 'payload/types';
1
+ import type { CustomComponent, UIField } from 'payload';
3
2
  export declare const LinkToDoc: CustomComponent<UIField>;
4
3
  //# sourceMappingURL=LinkToDoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkToDoc.d.ts","sourceRoot":"","sources":["../../src/ui/LinkToDoc.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAO5C,eAAO,MAAM,SAAS,EAAE,eAAe,CAAC,OAAO,CAwC9C,CAAA"}
1
+ {"version":3,"file":"LinkToDoc.d.ts","sourceRoot":"","sources":["../../src/ui/LinkToDoc.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKvD,eAAO,MAAM,SAAS,EAAE,eAAe,CAAC,OAAO,CAwC9C,CAAA"}
@@ -1,8 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
4
- // import CopyToClipboard from 'payload/dist/admin/components/elements/CopyToClipboard'
5
- import { useFormFields } from '@payloadcms/ui/forms/Form';
3
+ import { CopyToClipboard, useFieldProps, useFormFields } from '@payloadcms/ui';
6
4
  import React from 'react';
7
5
  export const LinkToDoc = ()=>{
8
6
  const { custom } = useFieldProps();
@@ -14,14 +12,19 @@ export const LinkToDoc = ()=>{
14
12
  if (stripeID) {
15
13
  return /*#__PURE__*/ _jsxs("div", {
16
14
  children: [
17
- /*#__PURE__*/ _jsx("div", {
18
- children: /*#__PURE__*/ _jsx("span", {
19
- className: "label",
20
- style: {
21
- color: '#9A9A9A'
22
- },
23
- children: "View in Stripe"
24
- })
15
+ /*#__PURE__*/ _jsxs("div", {
16
+ children: [
17
+ /*#__PURE__*/ _jsx("span", {
18
+ className: "label",
19
+ style: {
20
+ color: '#9A9A9A'
21
+ },
22
+ children: "View in Stripe"
23
+ }),
24
+ /*#__PURE__*/ _jsx(CopyToClipboard, {
25
+ value: href
26
+ })
27
+ ]
25
28
  }),
26
29
  /*#__PURE__*/ _jsx("div", {
27
30
  style: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/LinkToDoc.tsx"],"sourcesContent":["'use client'\nimport type { CustomComponent } from 'payload/config'\nimport type { UIField } from 'payload/types'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n// import CopyToClipboard from 'payload/dist/admin/components/elements/CopyToClipboard'\nimport { useFormFields } from '@payloadcms/ui/forms/Form'\nimport React from 'react'\n\nexport const LinkToDoc: CustomComponent<UIField> = () => {\n const { custom } = useFieldProps()\n const { isTestKey, nameOfIDField, stripeResourceType } = custom\n\n const field = useFormFields(([fields]) => (fields && fields?.[nameOfIDField]) || null)\n const { value: stripeID } = field || {}\n\n const stripeEnv = isTestKey ? 'test/' : ''\n const href = `https://dashboard.stripe.com/${stripeEnv}${stripeResourceType}/${stripeID}`\n\n if (stripeID) {\n return (\n <div>\n <div>\n <span\n className=\"label\"\n style={{\n color: '#9A9A9A',\n }}\n >\n View in Stripe\n </span>\n {/* <CopyToClipboard value={href} /> */}\n </div>\n <div\n style={{\n fontWeight: '600',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n <a href={href} rel=\"noreferrer noopener\" target=\"_blank\">\n {href}\n </a>\n </div>\n </div>\n )\n }\n\n return null\n}\n"],"names":["useFieldProps","useFormFields","React","LinkToDoc","custom","isTestKey","nameOfIDField","stripeResourceType","field","fields","value","stripeID","stripeEnv","href","div","span","className","style","color","fontWeight","overflow","textOverflow","a","rel","target"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,SAASA,aAAa,QAAQ,0CAAyC;AACvE,uFAAuF;AACvF,SAASC,aAAa,QAAQ,4BAA2B;AACzD,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,YAAsC;IACjD,MAAM,EAAEC,MAAM,EAAE,GAAGJ;IACnB,MAAM,EAAEK,SAAS,EAAEC,aAAa,EAAEC,kBAAkB,EAAE,GAAGH;IAEzD,MAAMI,QAAQP,cAAc,CAAC,CAACQ,OAAO,GAAK,AAACA,UAAUA,QAAQ,CAACH,cAAc,IAAK;IACjF,MAAM,EAAEI,OAAOC,QAAQ,EAAE,GAAGH,SAAS,CAAC;IAEtC,MAAMI,YAAYP,YAAY,UAAU;IACxC,MAAMQ,OAAO,CAAC,6BAA6B,EAAED,UAAU,EAAEL,mBAAmB,CAAC,EAAEI,SAAS,CAAC;IAEzF,IAAIA,UAAU;QACZ,qBACE,MAACG;;8BACC,KAACA;8BACC,cAAA,KAACC;wBACCC,WAAU;wBACVC,OAAO;4BACLC,OAAO;wBACT;kCACD;;;8BAKH,KAACJ;oBACCG,OAAO;wBACLE,YAAY;wBACZC,UAAU;wBACVC,cAAc;oBAChB;8BAEA,cAAA,KAACC;wBAAET,MAAMA;wBAAMU,KAAI;wBAAsBC,QAAO;kCAC7CX;;;;;IAKX;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/ui/LinkToDoc.tsx"],"sourcesContent":["'use client'\nimport type { CustomComponent, UIField } from 'payload'\n\nimport { CopyToClipboard, useFieldProps, useFormFields } from '@payloadcms/ui'\nimport React from 'react'\n\nexport const LinkToDoc: CustomComponent<UIField> = () => {\n const { custom } = useFieldProps()\n const { isTestKey, nameOfIDField, stripeResourceType } = custom\n\n const field = useFormFields(([fields]) => (fields && fields?.[nameOfIDField]) || null)\n const { value: stripeID } = field || {}\n\n const stripeEnv = isTestKey ? 'test/' : ''\n const href = `https://dashboard.stripe.com/${stripeEnv}${stripeResourceType}/${stripeID}`\n\n if (stripeID) {\n return (\n <div>\n <div>\n <span\n className=\"label\"\n style={{\n color: '#9A9A9A',\n }}\n >\n View in Stripe\n </span>\n <CopyToClipboard value={href} />\n </div>\n <div\n style={{\n fontWeight: '600',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n <a href={href} rel=\"noreferrer noopener\" target=\"_blank\">\n {href}\n </a>\n </div>\n </div>\n )\n }\n\n return null\n}\n"],"names":["CopyToClipboard","useFieldProps","useFormFields","React","LinkToDoc","custom","isTestKey","nameOfIDField","stripeResourceType","field","fields","value","stripeID","stripeEnv","href","div","span","className","style","color","fontWeight","overflow","textOverflow","a","rel","target"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,eAAe,EAAEC,aAAa,EAAEC,aAAa,QAAQ,iBAAgB;AAC9E,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,YAAsC;IACjD,MAAM,EAAEC,MAAM,EAAE,GAAGJ;IACnB,MAAM,EAAEK,SAAS,EAAEC,aAAa,EAAEC,kBAAkB,EAAE,GAAGH;IAEzD,MAAMI,QAAQP,cAAc,CAAC,CAACQ,OAAO,GAAK,AAACA,UAAUA,QAAQ,CAACH,cAAc,IAAK;IACjF,MAAM,EAAEI,OAAOC,QAAQ,EAAE,GAAGH,SAAS,CAAC;IAEtC,MAAMI,YAAYP,YAAY,UAAU;IACxC,MAAMQ,OAAO,CAAC,6BAA6B,EAAED,UAAU,EAAEL,mBAAmB,CAAC,EAAEI,SAAS,CAAC;IAEzF,IAAIA,UAAU;QACZ,qBACE,MAACG;;8BACC,MAACA;;sCACC,KAACC;4BACCC,WAAU;4BACVC,OAAO;gCACLC,OAAO;4BACT;sCACD;;sCAGD,KAACnB;4BAAgBW,OAAOG;;;;8BAE1B,KAACC;oBACCG,OAAO;wBACLE,YAAY;wBACZC,UAAU;wBACVC,cAAc;oBAChB;8BAEA,cAAA,KAACC;wBAAET,MAAMA;wBAAMU,KAAI;wBAAsBC,QAAO;kCAC7CX;;;;;IAKX;IAEA,OAAO;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deepen.d.ts","sourceRoot":"","sources":["../../src/utilities/deepen.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,QAAS,OAAO,MAAM,EAAE,GAAG,CAAC,KAAG,OAAO,MAAM,EAAE,GAAG,CAiBnE,CAAA"}
1
+ {"version":3,"file":"deepen.d.ts","sourceRoot":"","sources":["../../src/utilities/deepen.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,QAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAiBnE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-stripe",
3
- "version": "3.0.0-canary.cee5702",
3
+ "version": "3.0.0-canary.ee0375f",
4
4
  "description": "Stripe plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -24,13 +24,13 @@
24
24
  "exports": {
25
25
  ".": {
26
26
  "import": "./dist/index.js",
27
- "require": "./dist/index.js",
28
- "types": "./dist/index.d.ts"
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
29
  },
30
- "./*": {
31
- "import": "./dist/exports/*.js",
32
- "require": "./dist/exports/*.js",
33
- "types": "./dist/exports/*.d.ts"
30
+ "./types": {
31
+ "import": "./dist/exports/types.js",
32
+ "types": "./dist/exports/types.d.ts",
33
+ "default": "./dist/exports/types.js"
34
34
  }
35
35
  },
36
36
  "main": "./dist/index.js",
@@ -41,8 +41,8 @@
41
41
  "dependencies": {
42
42
  "lodash.get": "^4.4.2",
43
43
  "stripe": "^10.2.0",
44
- "uuid": "^9.0.0",
45
- "@payloadcms/ui": "3.0.0-canary.cee5702"
44
+ "uuid": "10.0.0",
45
+ "@payloadcms/ui": "3.0.0-canary.ee0375f"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/express": "^4.17.9",
@@ -51,15 +51,15 @@
51
51
  "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
52
52
  "@types/uuid": "^9.0.8",
53
53
  "@payloadcms/eslint-config": "1.1.1",
54
- "@payloadcms/translations": "3.0.0-canary.cee5702",
55
- "@payloadcms/next": "3.0.0-canary.cee5702",
56
- "@payloadcms/ui": "3.0.0-canary.cee5702",
57
- "payload": "3.0.0-canary.cee5702"
54
+ "@payloadcms/next": "3.0.0-canary.ee0375f",
55
+ "@payloadcms/translations": "3.0.0-canary.ee0375f",
56
+ "@payloadcms/ui": "3.0.0-canary.ee0375f",
57
+ "payload": "3.0.0-canary.ee0375f"
58
58
  },
59
59
  "peerDependencies": {
60
- "@payloadcms/translations": "3.0.0-canary.cee5702",
61
- "@payloadcms/ui": "3.0.0-canary.cee5702",
62
- "payload": "3.0.0-canary.cee5702"
60
+ "@payloadcms/translations": "3.0.0-canary.ee0375f",
61
+ "@payloadcms/ui": "3.0.0-canary.ee0375f",
62
+ "payload": "3.0.0-canary.ee0375f"
63
63
  },
64
64
  "publishConfig": {
65
65
  "registry": "https://registry.npmjs.org/"
@@ -70,8 +70,8 @@
70
70
  "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2"
71
71
  },
72
72
  "scripts": {
73
- "build": "pnpm copyfiles && pnpm build:swc && pnpm build:types",
74
- "build:swc": "swc ./src -d ./dist --config-file .swcrc",
73
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
74
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
75
75
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
76
76
  "clean": "rimraf {dist,*.tsbuildinfo}",
77
77
  "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",