@payloadcms/plugin-stripe 3.0.0-alpha.67 → 3.0.0-alpha.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.d.ts +2 -2
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +7 -7
- package/dist/admin.js.map +1 -1
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/fields/getFields.d.ts +3 -3
- package/dist/fields/getFields.d.ts.map +1 -1
- package/dist/fields/getFields.js +2 -2
- package/dist/fields/getFields.js.map +1 -1
- package/dist/hooks/createNewInStripe.d.ts +2 -2
- package/dist/hooks/createNewInStripe.d.ts.map +1 -1
- package/dist/hooks/createNewInStripe.js +2 -2
- package/dist/hooks/createNewInStripe.js.map +1 -1
- package/dist/hooks/deleteFromStripe.d.ts +2 -2
- package/dist/hooks/deleteFromStripe.d.ts.map +1 -1
- package/dist/hooks/deleteFromStripe.js +2 -2
- package/dist/hooks/deleteFromStripe.js.map +1 -1
- package/dist/hooks/syncExistingWithStripe.d.ts +2 -2
- package/dist/hooks/syncExistingWithStripe.d.ts.map +1 -1
- package/dist/hooks/syncExistingWithStripe.js +2 -2
- package/dist/hooks/syncExistingWithStripe.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/routes/rest.d.ts +2 -2
- package/dist/routes/rest.d.ts.map +1 -1
- package/dist/routes/rest.js +2 -2
- package/dist/routes/rest.js.map +1 -1
- package/dist/routes/webhooks.d.ts +2 -2
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/webhooks.js +8 -8
- package/dist/routes/webhooks.js.map +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/webhooks/handleCreatedOrUpdated.d.ts +2 -2
- package/dist/webhooks/handleCreatedOrUpdated.d.ts.map +1 -1
- package/dist/webhooks/handleCreatedOrUpdated.js +2 -2
- package/dist/webhooks/handleCreatedOrUpdated.js.map +1 -1
- package/dist/webhooks/handleDeleted.d.ts +2 -2
- package/dist/webhooks/handleDeleted.d.ts.map +1 -1
- package/dist/webhooks/handleDeleted.js +2 -2
- package/dist/webhooks/handleDeleted.js.map +1 -1
- package/dist/webhooks/index.js +6 -6
- package/dist/webhooks/index.js.map +1 -1
- package/package.json +11 -13
- package/dist/payload-stripe-plugin.postman_collection.json +0 -301
- package/types.d.ts +0 -1
- package/types.js +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -131,23 +131,23 @@ export type StripeWebhookHandler<T = any> = (args: {
|
|
|
131
131
|
config: PayloadConfig;
|
|
132
132
|
event: T;
|
|
133
133
|
payload: Payload;
|
|
134
|
+
pluginConfig?: StripePluginConfig;
|
|
134
135
|
stripe: Stripe;
|
|
135
|
-
stripeConfig?: StripeConfig;
|
|
136
136
|
}) => void;
|
|
137
|
-
export
|
|
137
|
+
export type StripeWebhookHandlers = {
|
|
138
138
|
[webhookName: string]: StripeWebhookHandler;
|
|
139
|
-
}
|
|
140
|
-
export
|
|
139
|
+
};
|
|
140
|
+
export type FieldSyncConfig = {
|
|
141
141
|
fieldPath: string;
|
|
142
142
|
stripeProperty: string;
|
|
143
|
-
}
|
|
144
|
-
export
|
|
143
|
+
};
|
|
144
|
+
export type SyncConfig = {
|
|
145
145
|
collection: string;
|
|
146
146
|
fields: FieldSyncConfig[];
|
|
147
147
|
stripeResourceType: 'customers' | 'products';
|
|
148
148
|
stripeResourceTypeSingular: 'customer' | 'product';
|
|
149
|
-
}
|
|
150
|
-
export
|
|
149
|
+
};
|
|
150
|
+
export type StripePluginConfig = {
|
|
151
151
|
isTestKey?: boolean;
|
|
152
152
|
logs?: boolean;
|
|
153
153
|
rest?: boolean;
|
|
@@ -155,8 +155,8 @@ export interface StripeConfig {
|
|
|
155
155
|
stripeWebhooksEndpointSecret?: string;
|
|
156
156
|
sync?: SyncConfig[];
|
|
157
157
|
webhooks?: StripeWebhookHandler | StripeWebhookHandlers;
|
|
158
|
-
}
|
|
159
|
-
export type
|
|
158
|
+
};
|
|
159
|
+
export type SanitizedStripePluginConfig = StripePluginConfig & {
|
|
160
160
|
sync: SyncConfig[];
|
|
161
161
|
};
|
|
162
162
|
export type StripeProxy = (args: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE;IACjD,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,CAAC,CAAA;IACR,OAAO,EAAE,OAAO,CAAA;IAChB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC7D,O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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
|
|
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 // @deprecated this will default as `false` in the next major version release\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,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SanitizedStripePluginConfig, StripeWebhookHandler } from '../types.js';
|
|
2
2
|
type HandleCreatedOrUpdated = (args: Parameters<StripeWebhookHandler>[0] & {
|
|
3
3
|
resourceType: string;
|
|
4
|
-
syncConfig:
|
|
4
|
+
syncConfig: SanitizedStripePluginConfig['sync'][0];
|
|
5
5
|
}) => void;
|
|
6
6
|
export declare const handleCreatedOrUpdated: HandleCreatedOrUpdated;
|
|
7
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleCreatedOrUpdated.d.ts","sourceRoot":"","sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"handleCreatedOrUpdated.d.ts","sourceRoot":"","sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIpF,KAAK,sBAAsB,GAAG,CAC5B,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG;IAC1C,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;CACnD,KACE,IAAI,CAAA;AAET,eAAO,MAAM,sBAAsB,EAAE,sBAsLpC,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
2
|
import { deepen } from '../utilities/deepen.js';
|
|
3
3
|
export const handleCreatedOrUpdated = async (args)=>{
|
|
4
|
-
const { config: payloadConfig, event, payload,
|
|
5
|
-
const { logs } =
|
|
4
|
+
const { config: payloadConfig, event, payload, pluginConfig, resourceType, syncConfig } = args;
|
|
5
|
+
const { logs } = pluginConfig || {};
|
|
6
6
|
const stripeDoc = event?.data?.object || {};
|
|
7
7
|
const { id: stripeID, object: eventObject } = stripeDoc;
|
|
8
8
|
// NOTE: the Stripe API does not nest fields, everything is an object at the top level
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"sourcesContent":["import { v4 as uuid } from 'uuid'\n\nimport type { SanitizedStripeConfig, StripeWebhookHandler } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\ntype HandleCreatedOrUpdated = (\n args: Parameters<StripeWebhookHandler>[0] & {\n resourceType: string\n syncConfig: SanitizedStripeConfig['sync'][0]\n },\n) => void\n\nexport const handleCreatedOrUpdated: HandleCreatedOrUpdated = async (args) => {\n const { config: payloadConfig, event, payload, resourceType, stripeConfig, syncConfig } = args\n\n const { logs } = stripeConfig || {}\n\n const stripeDoc: any = event?.data?.object || {}\n\n const { id: stripeID, object: eventObject } = stripeDoc\n\n // NOTE: the Stripe API does not nest fields, everything is an object at the top level\n // if the event object and resource type don't match, this change was not top-level\n const isNestedChange = eventObject !== resourceType\n\n // let stripeID = docID;\n // if (isNestedChange) {\n // const parentResource = stripeDoc[resourceType];\n // stripeID = parentResource;\n // }\n\n if (isNestedChange) {\n if (logs)\n payload.logger.info(\n `- This change occurred on a nested field of ${resourceType}. Nested fields are not yet supported in auto-sync but can be manually setup.`,\n )\n }\n\n if (!isNestedChange) {\n if (logs)\n payload.logger.info(\n `- A new document was created or updated in Stripe, now syncing to Payload...`,\n )\n\n const collectionSlug = syncConfig?.collection\n\n const isAuthCollection = Boolean(\n payloadConfig?.collections?.find((collection) => collection.slug === collectionSlug)?.auth,\n )\n\n // First, search for an existing document in Payload\n const payloadQuery = await payload.find({\n collection: collectionSlug,\n where: {\n stripeID: {\n equals: stripeID,\n },\n },\n })\n\n const foundDoc = payloadQuery.docs[0] as any\n\n // combine all properties of the Stripe doc and match their respective fields within the document\n let syncedData = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[fieldPath] = stripeDoc[stripeProperty]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedData = deepen({\n ...syncedData,\n skipSync: true,\n stripeID,\n })\n\n if (!foundDoc) {\n if (logs)\n payload.logger.info(\n `- No existing '${collectionSlug}' document found with Stripe ID: '${stripeID}', creating new...`,\n )\n\n // auth docs must use unique emails\n let authDoc = null\n\n if (isAuthCollection) {\n try {\n if (stripeDoc?.email) {\n const authQuery = await payload.find({\n collection: collectionSlug,\n where: {\n email: {\n equals: stripeDoc.email,\n },\n },\n })\n\n authDoc = authQuery.docs[0] as any\n\n if (authDoc) {\n if (logs)\n payload.logger.info(\n `- Account already exists with e-mail: ${stripeDoc.email}, updating now...`,\n )\n\n // account exists by email, so update it instead\n try {\n await payload.update({\n id: authDoc.id,\n collection: collectionSlug,\n data: syncedData,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully updated '${collectionSlug}' document in Payload with ID: '${authDoc.id}.'`,\n )\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : err\n if (logs)\n payload.logger.error(\n `- Error updating existing '${collectionSlug}' document: ${msg}`,\n )\n }\n }\n } else {\n if (logs)\n payload.logger.error(\n `No email was provided from Stripe, cannot create new '${collectionSlug}' document.`,\n )\n }\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs)\n payload.logger.error(`Error looking up '${collectionSlug}' document in Payload: ${msg}`)\n }\n }\n\n if (!isAuthCollection || (isAuthCollection && !authDoc)) {\n try {\n if (logs)\n payload.logger.info(\n `- Creating new '${collectionSlug}' document in Payload with Stripe ID: '${stripeID}'.`,\n )\n\n // generate a strong, unique password for the new user\n const password: string = uuid()\n\n await payload.create({\n collection: collectionSlug,\n data: {\n ...syncedData,\n password,\n passwordConfirm: password,\n },\n disableVerificationEmail: isAuthCollection ? true : undefined,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${collectionSlug}' document in Payload with Stripe ID: '${stripeID}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`Error creating new document in Payload: ${msg}`)\n }\n }\n } else {\n if (logs)\n payload.logger.info(\n `- Existing '${collectionSlug}' document found in Payload with Stripe ID: '${stripeID}', updating now...`,\n )\n\n try {\n await payload.update({\n id: foundDoc.id,\n collection: collectionSlug,\n data: syncedData,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully updated '${collectionSlug}' document in Payload from Stripe ID: '${stripeID}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs)\n payload.logger.error(`Error updating '${collectionSlug}' document in Payload: ${msg}`)\n }\n }\n }\n}\n"],"names":["v4","uuid","deepen","handleCreatedOrUpdated","args","config","payloadConfig","event","payload","resourceType","stripeConfig","syncConfig","logs","stripeDoc","data","object","id","stripeID","eventObject","isNestedChange","logger","info","collectionSlug","collection","isAuthCollection","Boolean","collections","find","slug","auth","payloadQuery","where","equals","foundDoc","docs","syncedData","fields","reduce","acc","field","fieldPath","stripeProperty","skipSync","authDoc","email","authQuery","update","err","msg","Error","message","error","password","create","passwordConfirm","disableVerificationEmail","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,MAAM,QAAQ,yBAAwB;AAS/C,OAAO,MAAMC,yBAAiD,OAAOC;IACnE,MAAM,EAAEC,QAAQC,aAAa,EAAEC,KAAK,EAAEC,OAAO,EAAEC,YAAY,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGP;IAE1F,MAAM,EAAEQ,IAAI,EAAE,GAAGF,gBAAgB,CAAC;IAElC,MAAMG,YAAiBN,OAAOO,MAAMC,UAAU,CAAC;IAE/C,MAAM,EAAEC,IAAIC,QAAQ,EAAEF,QAAQG,WAAW,EAAE,GAAG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AAuC,EAAEL,SAAS,EAAE,CAAC;oBAG3F,sDAAsD;oBACtD,MAAMmC,WAAmBnD;oBAEzB,MAAMO,QAAQ6C,MAAM,CAAC;wBACnB9B,YAAYD;wBACZR,MAAM;4BACJ,GAAGqB,UAAU;4BACbiB;4BACAE,iBAAiBF;wBACnB;wBACAG,0BAA0B/B,mBAAmB,OAAOgC;oBACtD;oBAEA,IAAI5C,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,4BAA4B,EAAEC,eAAe,uCAAuC,EAAEL,SAAS,EAAE,CAAC;gBAEzG,EAAE,OAAOkC,OAAgB;oBACvB,MAAMH,MAAMG,iBAAiBF,QAAQE,MAAMD,OAAO,GAAGC;oBACrD,IAAIvC,MAAMJ,QAAQY,MAAM,CAAC+B,KAAK,CAAC,CAAC,wCAAwC,EAAEH,IAAI,CAAC;gBACjF;YACF;QACF,OAAO;YACL,IAAIpC,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,YAAY,EAAEC,eAAe,6CAA6C,EAAEL,SAAS,kBAAkB,CAAC;YAG7G,IAAI;gBACF,MAAMT,QAAQsC,MAAM,CAAC;oBACnB9B,IAAIiB,SAASjB,EAAE;oBACfO,YAAYD;oBACZR,MAAMqB;gBACR;gBAEA,IAAIvB,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,wBAAwB,EAAEC,eAAe,uCAAuC,EAAEL,SAAS,EAAE,CAAC;YAErG,EAAE,OAAOkC,OAAgB;gBACvB,MAAMH,MAAMG,iBAAiBF,QAAQE,MAAMD,OAAO,GAAGC;gBACrD,IAAIvC,MACFJ,QAAQY,MAAM,CAAC+B,KAAK,CAAC,CAAC,gBAAgB,EAAE7B,eAAe,uBAAuB,EAAE0B,IAAI,CAAC;YACzF;QACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"sourcesContent":["import { v4 as uuid } from 'uuid'\n\nimport type { SanitizedStripePluginConfig, StripeWebhookHandler } from '../types.js'\n\nimport { deepen } from '../utilities/deepen.js'\n\ntype HandleCreatedOrUpdated = (\n args: Parameters<StripeWebhookHandler>[0] & {\n resourceType: string\n syncConfig: SanitizedStripePluginConfig['sync'][0]\n },\n) => void\n\nexport const handleCreatedOrUpdated: HandleCreatedOrUpdated = async (args) => {\n const { config: payloadConfig, event, payload, pluginConfig, resourceType, syncConfig } = args\n\n const { logs } = pluginConfig || {}\n\n const stripeDoc: any = event?.data?.object || {}\n\n const { id: stripeID, object: eventObject } = stripeDoc\n\n // NOTE: the Stripe API does not nest fields, everything is an object at the top level\n // if the event object and resource type don't match, this change was not top-level\n const isNestedChange = eventObject !== resourceType\n\n // let stripeID = docID;\n // if (isNestedChange) {\n // const parentResource = stripeDoc[resourceType];\n // stripeID = parentResource;\n // }\n\n if (isNestedChange) {\n if (logs)\n payload.logger.info(\n `- This change occurred on a nested field of ${resourceType}. Nested fields are not yet supported in auto-sync but can be manually setup.`,\n )\n }\n\n if (!isNestedChange) {\n if (logs)\n payload.logger.info(\n `- A new document was created or updated in Stripe, now syncing to Payload...`,\n )\n\n const collectionSlug = syncConfig?.collection\n\n const isAuthCollection = Boolean(\n payloadConfig?.collections?.find((collection) => collection.slug === collectionSlug)?.auth,\n )\n\n // First, search for an existing document in Payload\n const payloadQuery = await payload.find({\n collection: collectionSlug,\n where: {\n stripeID: {\n equals: stripeID,\n },\n },\n })\n\n const foundDoc = payloadQuery.docs[0] as any\n\n // combine all properties of the Stripe doc and match their respective fields within the document\n let syncedData = syncConfig.fields.reduce(\n (acc, field) => {\n const { fieldPath, stripeProperty } = field\n\n acc[fieldPath] = stripeDoc[stripeProperty]\n return acc\n },\n {} as Record<string, any>,\n )\n\n syncedData = deepen({\n ...syncedData,\n skipSync: true,\n stripeID,\n })\n\n if (!foundDoc) {\n if (logs)\n payload.logger.info(\n `- No existing '${collectionSlug}' document found with Stripe ID: '${stripeID}', creating new...`,\n )\n\n // auth docs must use unique emails\n let authDoc = null\n\n if (isAuthCollection) {\n try {\n if (stripeDoc?.email) {\n const authQuery = await payload.find({\n collection: collectionSlug,\n where: {\n email: {\n equals: stripeDoc.email,\n },\n },\n })\n\n authDoc = authQuery.docs[0] as any\n\n if (authDoc) {\n if (logs)\n payload.logger.info(\n `- Account already exists with e-mail: ${stripeDoc.email}, updating now...`,\n )\n\n // account exists by email, so update it instead\n try {\n await payload.update({\n id: authDoc.id,\n collection: collectionSlug,\n data: syncedData,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully updated '${collectionSlug}' document in Payload with ID: '${authDoc.id}.'`,\n )\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : err\n if (logs)\n payload.logger.error(\n `- Error updating existing '${collectionSlug}' document: ${msg}`,\n )\n }\n }\n } else {\n if (logs)\n payload.logger.error(\n `No email was provided from Stripe, cannot create new '${collectionSlug}' document.`,\n )\n }\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs)\n payload.logger.error(`Error looking up '${collectionSlug}' document in Payload: ${msg}`)\n }\n }\n\n if (!isAuthCollection || (isAuthCollection && !authDoc)) {\n try {\n if (logs)\n payload.logger.info(\n `- Creating new '${collectionSlug}' document in Payload with Stripe ID: '${stripeID}'.`,\n )\n\n // generate a strong, unique password for the new user\n const password: string = uuid()\n\n await payload.create({\n collection: collectionSlug,\n data: {\n ...syncedData,\n password,\n passwordConfirm: password,\n },\n disableVerificationEmail: isAuthCollection ? true : undefined,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully created new '${collectionSlug}' document in Payload with Stripe ID: '${stripeID}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`Error creating new document in Payload: ${msg}`)\n }\n }\n } else {\n if (logs)\n payload.logger.info(\n `- Existing '${collectionSlug}' document found in Payload with Stripe ID: '${stripeID}', updating now...`,\n )\n\n try {\n await payload.update({\n id: foundDoc.id,\n collection: collectionSlug,\n data: syncedData,\n })\n\n if (logs)\n payload.logger.info(\n `✅ Successfully updated '${collectionSlug}' document in Payload from Stripe ID: '${stripeID}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs)\n payload.logger.error(`Error updating '${collectionSlug}' document in Payload: ${msg}`)\n }\n }\n }\n}\n"],"names":["v4","uuid","deepen","handleCreatedOrUpdated","args","config","payloadConfig","event","payload","pluginConfig","resourceType","syncConfig","logs","stripeDoc","data","object","id","stripeID","eventObject","isNestedChange","logger","info","collectionSlug","collection","isAuthCollection","Boolean","collections","find","slug","auth","payloadQuery","where","equals","foundDoc","docs","syncedData","fields","reduce","acc","field","fieldPath","stripeProperty","skipSync","authDoc","email","authQuery","update","err","msg","Error","message","error","password","create","passwordConfirm","disableVerificationEmail","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,MAAM,QAAQ,yBAAwB;AAS/C,OAAO,MAAMC,yBAAiD,OAAOC;IACnE,MAAM,EAAEC,QAAQC,aAAa,EAAEC,KAAK,EAAEC,OAAO,EAAEC,YAAY,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGP;IAE1F,MAAM,EAAEQ,IAAI,EAAE,GAAGH,gBAAgB,CAAC;IAElC,MAAMI,YAAiBN,OAAOO,MAAMC,UAAU,CAAC;IAE/C,MAAM,EAAEC,IAAIC,QAAQ,EAAEF,QAAQG,WAAW,EAAE,GAAGL;IAE9C,sFAAsF;IACtF,mFAAmF;IACnF,MAAMM,iBAAiBD,gBAAgBR;IAEvC,wBAAwB;IACxB,wBAAwB;IACxB,oDAAoD;IACpD,+BAA+B;IAC/B,IAAI;IAEJ,IAAIS,gBAAgB;QAClB,IAAIP,MACFJ,QAAQY,MAAM,CAACC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G,0BAA0B/B,mBAAmB,OAAOgC;oBACtD;oBAEA,IAAI5C,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,4BAA4B,EAAEC,eAAe,uCAAuC,EAAEL,SAAS,EAAE,CAAC;gBAEzG,EAAE,OAAOkC,OAAgB;oBACvB,MAAMH,MAAMG,iBAAiBF,QAAQE,MAAMD,OAAO,GAAGC;oBACrD,IAAIvC,MAAMJ,QAAQY,MAAM,CAAC+B,KAAK,CAAC,CAAC,wCAAwC,EAAEH,IAAI,CAAC;gBACjF;YACF;QACF,OAAO;YACL,IAAIpC,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,YAAY,EAAEC,eAAe,6CAA6C,EAAEL,SAAS,kBAAkB,CAAC;YAG7G,IAAI;gBACF,MAAMT,QAAQsC,MAAM,CAAC;oBACnB9B,IAAIiB,SAASjB,EAAE;oBACfO,YAAYD;oBACZR,MAAMqB;gBACR;gBAEA,IAAIvB,MACFJ,QAAQY,MAAM,CAACC,IAAI,CACjB,CAAC,wBAAwB,EAAEC,eAAe,uCAAuC,EAAEL,SAAS,EAAE,CAAC;YAErG,EAAE,OAAOkC,OAAgB;gBACvB,MAAMH,MAAMG,iBAAiBF,QAAQE,MAAMD,OAAO,GAAGC;gBACrD,IAAIvC,MACFJ,QAAQY,MAAM,CAAC+B,KAAK,CAAC,CAAC,gBAAgB,EAAE7B,eAAe,uBAAuB,EAAE0B,IAAI,CAAC;YACzF;QACF;IACF;AACF,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SanitizedStripePluginConfig, StripeWebhookHandler } from '../types.js';
|
|
2
2
|
type HandleDeleted = (args: Parameters<StripeWebhookHandler>[0] & {
|
|
3
3
|
resourceType: string;
|
|
4
|
-
syncConfig:
|
|
4
|
+
syncConfig: SanitizedStripePluginConfig['sync'][0];
|
|
5
5
|
}) => void;
|
|
6
6
|
export declare const handleDeleted: HandleDeleted;
|
|
7
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleDeleted.d.ts","sourceRoot":"","sources":["../../src/webhooks/handleDeleted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"handleDeleted.d.ts","sourceRoot":"","sources":["../../src/webhooks/handleDeleted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEpF,KAAK,aAAa,GAAG,CACnB,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG;IAC1C,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;CACnD,KACE,IAAI,CAAA;AAET,eAAO,MAAM,aAAa,EAAE,aAyE3B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const handleDeleted = async (args)=>{
|
|
2
|
-
const { event, payload,
|
|
3
|
-
const { logs } =
|
|
2
|
+
const { event, payload, pluginConfig, resourceType, syncConfig } = args;
|
|
3
|
+
const { logs } = pluginConfig || {};
|
|
4
4
|
const collectionSlug = syncConfig?.collection;
|
|
5
5
|
const { id: stripeID, object: eventObject } = event?.data?.object || {};
|
|
6
6
|
// if the event object and resource type don't match, this deletion was not top-level
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webhooks/handleDeleted.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/webhooks/handleDeleted.ts"],"sourcesContent":["import type { SanitizedStripePluginConfig, StripeWebhookHandler } from '../types.js'\n\ntype HandleDeleted = (\n args: Parameters<StripeWebhookHandler>[0] & {\n resourceType: string\n syncConfig: SanitizedStripePluginConfig['sync'][0]\n },\n) => void\n\nexport const handleDeleted: HandleDeleted = async (args) => {\n const { event, payload, pluginConfig, resourceType, syncConfig } = args\n\n const { logs } = pluginConfig || {}\n\n const collectionSlug = syncConfig?.collection\n\n const {\n id: stripeID,\n object: eventObject, // use this to determine if this is a nested field\n }: any = event?.data?.object || {}\n\n // if the event object and resource type don't match, this deletion was not top-level\n const isNestedDelete = eventObject !== resourceType\n\n if (isNestedDelete) {\n if (logs)\n payload.logger.info(\n `- This deletion occurred on a nested field of ${resourceType}. Nested fields are not yet supported.`,\n )\n }\n\n if (!isNestedDelete) {\n if (logs)\n payload.logger.info(\n `- A '${resourceType}' resource was deleted in Stripe, now deleting '${collectionSlug}' document in Payload with Stripe ID: '${stripeID}'...`,\n )\n\n try {\n const payloadQuery = await payload.find({\n collection: collectionSlug,\n where: {\n stripeID: {\n equals: stripeID,\n },\n },\n })\n\n const foundDoc = payloadQuery.docs[0] as any\n\n if (!foundDoc) {\n if (logs)\n payload.logger.info(\n `- Nothing to delete, no existing document found with Stripe ID: '${stripeID}'.`,\n )\n }\n\n if (foundDoc) {\n if (logs) payload.logger.info(`- Deleting Payload document with ID: '${foundDoc.id}'...`)\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n payload.delete({\n id: foundDoc.id,\n collection: collectionSlug,\n })\n\n // NOTE: the `afterDelete` hook will trigger, which will attempt to delete the document from Stripe and safely error out\n // There is no known way of preventing this from happening. In other hooks we use the `skipSync` field, but here the document is already deleted.\n if (logs)\n payload.logger.info(\n `- ✅ Successfully deleted Payload document with ID: '${foundDoc.id}'.`,\n )\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`Error deleting document: ${msg}`)\n }\n }\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : error\n if (logs) payload.logger.error(`Error deleting document: ${msg}`)\n }\n }\n}\n"],"names":["handleDeleted","args","event","payload","pluginConfig","resourceType","syncConfig","logs","collectionSlug","collection","id","stripeID","object","eventObject","data","isNestedDelete","logger","info","payloadQuery","find","where","equals","foundDoc","docs","delete","error","msg","Error","message"],"rangeMappings":";;;;;;;;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AAwH;oBACxH,iJAAiJ;oBACjJ,IAAID,MACFJ,QAAQa,MAAM,CAACC,IAAI,CACjB,CAAC,oDAAoD,EAAEK,SAASZ,EAAE,CAAC,EAAE,CAAC;gBAE5E,EAAE,OAAOe,OAAgB;oBACvB,MAAMC,MAAMD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGH;oBACrD,IAAIlB,MAAMJ,QAAQa,MAAM,CAACS,KAAK,CAAC,CAAC,yBAAyB,EAAEC,IAAI,CAAC;gBAClE;YACF;QACF,EAAE,OAAOD,OAAgB;YACvB,MAAMC,MAAMD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGH;YACrD,IAAIlB,MAAMJ,QAAQa,MAAM,CAACS,KAAK,CAAC,CAAC,yBAAyB,EAAEC,IAAI,CAAC;QAClE;IACF;AACF,EAAC"}
|
package/dist/webhooks/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { handleCreatedOrUpdated } from './handleCreatedOrUpdated.js';
|
|
2
2
|
import { handleDeleted } from './handleDeleted.js';
|
|
3
3
|
export const handleWebhooks = (args)=>{
|
|
4
|
-
const { event, payload,
|
|
5
|
-
if (
|
|
4
|
+
const { event, payload, pluginConfig } = args;
|
|
5
|
+
if (pluginConfig?.logs) payload.logger.info(`🪝 Received Stripe '${event.type}' webhook event with ID: '${event.id}'.`);
|
|
6
6
|
// could also traverse into event.data.object.object to get the type, but that seems unreliable
|
|
7
7
|
// use cli: `stripe resources` to see all available resources
|
|
8
8
|
const resourceType = event.type.split('.')[0];
|
|
9
9
|
const method = event.type.split('.').pop();
|
|
10
|
-
const syncConfig =
|
|
10
|
+
const syncConfig = pluginConfig?.sync?.find((sync)=>sync.stripeResourceTypeSingular === resourceType);
|
|
11
11
|
if (syncConfig) {
|
|
12
12
|
switch(method){
|
|
13
13
|
case 'created':
|
|
14
14
|
{
|
|
15
15
|
void handleCreatedOrUpdated({
|
|
16
16
|
...args,
|
|
17
|
+
pluginConfig,
|
|
17
18
|
resourceType,
|
|
18
|
-
stripeConfig,
|
|
19
19
|
syncConfig
|
|
20
20
|
});
|
|
21
21
|
break;
|
|
@@ -24,8 +24,8 @@ export const handleWebhooks = (args)=>{
|
|
|
24
24
|
{
|
|
25
25
|
void handleCreatedOrUpdated({
|
|
26
26
|
...args,
|
|
27
|
+
pluginConfig,
|
|
27
28
|
resourceType,
|
|
28
|
-
stripeConfig,
|
|
29
29
|
syncConfig
|
|
30
30
|
});
|
|
31
31
|
break;
|
|
@@ -34,8 +34,8 @@ export const handleWebhooks = (args)=>{
|
|
|
34
34
|
{
|
|
35
35
|
void handleDeleted({
|
|
36
36
|
...args,
|
|
37
|
+
pluginConfig,
|
|
37
38
|
resourceType,
|
|
38
|
-
stripeConfig,
|
|
39
39
|
syncConfig
|
|
40
40
|
});
|
|
41
41
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webhooks/index.ts"],"sourcesContent":["import type { StripeWebhookHandler } from '../types.js'\n\nimport { handleCreatedOrUpdated } from './handleCreatedOrUpdated.js'\nimport { handleDeleted } from './handleDeleted.js'\n\nexport const handleWebhooks: StripeWebhookHandler = (args) => {\n const { event, payload,
|
|
1
|
+
{"version":3,"sources":["../../src/webhooks/index.ts"],"sourcesContent":["import type { StripeWebhookHandler } from '../types.js'\n\nimport { handleCreatedOrUpdated } from './handleCreatedOrUpdated.js'\nimport { handleDeleted } from './handleDeleted.js'\n\nexport const handleWebhooks: StripeWebhookHandler = (args) => {\n const { event, payload, pluginConfig } = args\n\n if (pluginConfig?.logs)\n payload.logger.info(`🪝 Received Stripe '${event.type}' webhook event with ID: '${event.id}'.`)\n\n // could also traverse into event.data.object.object to get the type, but that seems unreliable\n // use cli: `stripe resources` to see all available resources\n const resourceType = event.type.split('.')[0]\n const method = event.type.split('.').pop()\n\n const syncConfig = pluginConfig?.sync?.find(\n (sync) => sync.stripeResourceTypeSingular === resourceType,\n )\n\n if (syncConfig) {\n switch (method) {\n case 'created': {\n void handleCreatedOrUpdated({\n ...args,\n pluginConfig,\n resourceType,\n syncConfig,\n })\n break\n }\n case 'updated': {\n void handleCreatedOrUpdated({\n ...args,\n pluginConfig,\n resourceType,\n syncConfig,\n })\n break\n }\n case 'deleted': {\n void handleDeleted({\n ...args,\n pluginConfig,\n resourceType,\n syncConfig,\n })\n break\n }\n default: {\n break\n }\n }\n }\n}\n"],"names":["handleCreatedOrUpdated","handleDeleted","handleWebhooks","args","event","payload","pluginConfig","logs","logger","info","type","id","resourceType","split","method","pop","syncConfig","sync","find","stripeResourceTypeSingular"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,aAAa,QAAQ,qBAAoB;AAElD,OAAO,MAAMC,iBAAuC,CAACC;IACnD,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,YAAY,EAAE,GAAGH;IAEzC,IAAIG,cAAcC,MAChBF,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,oBAAoB,EAAEL,MAAMM,IAAI,CAAC,0BAA0B,EAAEN,MAAMO,EAAE,CAAC,EAAE,CAAC;IAEhG,+FAA+F;IAC/F,6DAA6D;IAC7D,MAAMC,eAAeR,MAAMM,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7C,MAAMC,SAASV,MAAMM,IAAI,CAACG,KAAK,CAAC,KAAKE,GAAG;IAExC,MAAMC,aAAaV,cAAcW,MAAMC,KACrC,CAACD,OAASA,KAAKE,0BAA0B,KAAKP;IAGhD,IAAII,YAAY;QACd,OAAQF;YACN,KAAK;gBAAW;oBACd,KAAKd,uBAAuB;wBAC1B,GAAGG,IAAI;wBACPG;wBACAM;wBACAI;oBACF;oBACA;gBACF;YACA,KAAK;gBAAW;oBACd,KAAKhB,uBAAuB;wBAC1B,GAAGG,IAAI;wBACPG;wBACAM;wBACAI;oBACF;oBACA;gBACF;YACA,KAAK;gBAAW;oBACd,KAAKf,cAAc;wBACjB,GAAGE,IAAI;wBACPG;wBACAM;wBACAI;oBACF;oBACA;gBACF;YACA;gBAAS;oBACP;gBACF;QACF;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-stripe",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.69",
|
|
4
4
|
"description": "Stripe plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "packages/plugin-stripe"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"author": "dev@payloadcms.com",
|
|
22
|
+
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
@@ -31,31 +31,29 @@
|
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
"types.js",
|
|
36
|
-
"types.d.ts"
|
|
34
|
+
"dist"
|
|
37
35
|
],
|
|
38
36
|
"dependencies": {
|
|
39
37
|
"lodash.get": "^4.4.2",
|
|
40
38
|
"stripe": "^10.2.0",
|
|
41
39
|
"uuid": "^9.0.0",
|
|
42
|
-
"@payloadcms/ui": "3.0.0-alpha.
|
|
40
|
+
"@payloadcms/ui": "3.0.0-alpha.69"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
45
43
|
"@types/express": "^4.17.9",
|
|
46
44
|
"@types/lodash.get": "^4.4.7",
|
|
47
45
|
"@types/react": "18.2.74",
|
|
48
46
|
"@types/uuid": "^9.0.0",
|
|
49
|
-
"@payloadcms/next": "3.0.0-alpha.67",
|
|
50
|
-
"@payloadcms/translations": "3.0.0-alpha.67",
|
|
51
|
-
"payload": "3.0.0-alpha.67",
|
|
52
47
|
"@payloadcms/eslint-config": "1.1.1",
|
|
53
|
-
"@payloadcms/
|
|
48
|
+
"@payloadcms/next": "3.0.0-alpha.69",
|
|
49
|
+
"@payloadcms/translations": "3.0.0-alpha.69",
|
|
50
|
+
"@payloadcms/ui": "3.0.0-alpha.69",
|
|
51
|
+
"payload": "3.0.0-alpha.69"
|
|
54
52
|
},
|
|
55
53
|
"peerDependencies": {
|
|
56
|
-
"@payloadcms/translations": "3.0.0-alpha.
|
|
57
|
-
"@payloadcms/ui": "3.0.0-alpha.
|
|
58
|
-
"payload": "3.0.0-alpha.
|
|
54
|
+
"@payloadcms/translations": "3.0.0-alpha.69",
|
|
55
|
+
"@payloadcms/ui": "3.0.0-alpha.69",
|
|
56
|
+
"payload": "3.0.0-alpha.69"
|
|
59
57
|
},
|
|
60
58
|
"publishConfig": {
|
|
61
59
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"info": {
|
|
3
|
-
"name": "Payload Stripe Plugin",
|
|
4
|
-
"_exporter_id": "4309346",
|
|
5
|
-
"_postman_id": "130686e1-ddd9-40f1-b031-68ec1a6413ee",
|
|
6
|
-
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
7
|
-
},
|
|
8
|
-
"item": [
|
|
9
|
-
{
|
|
10
|
-
"name": "Get All Subscriptions",
|
|
11
|
-
"request": {
|
|
12
|
-
"body": {
|
|
13
|
-
"mode": "raw",
|
|
14
|
-
"raw": "{\n \"stripeMethod\": \"subscriptions.list\",\n \"stripeArgs\": {\n \"customer\": \"cus_MGgt3Tuj3D66f2\"\n }\n}"
|
|
15
|
-
},
|
|
16
|
-
"header": [
|
|
17
|
-
{
|
|
18
|
-
"key": "Content-Type",
|
|
19
|
-
"type": "text",
|
|
20
|
-
"value": "application/json"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"key": "Authorization",
|
|
24
|
-
"type": "text",
|
|
25
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"method": "POST",
|
|
29
|
-
"url": {
|
|
30
|
-
"host": ["localhost"],
|
|
31
|
-
"path": ["api", "stripe", "rest"],
|
|
32
|
-
"port": "3000",
|
|
33
|
-
"raw": "localhost:3000/api/stripe/rest"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"response": []
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "Get All Products",
|
|
40
|
-
"request": {
|
|
41
|
-
"body": {
|
|
42
|
-
"mode": "raw",
|
|
43
|
-
"raw": "{\n \"stripeMethod\": \"products.list\",\n \"stripeArgs\": [{\n \"limit\": 100\n }]\n}"
|
|
44
|
-
},
|
|
45
|
-
"header": [
|
|
46
|
-
{
|
|
47
|
-
"key": "Content-Type",
|
|
48
|
-
"type": "text",
|
|
49
|
-
"value": "application/json"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"key": "Authorization",
|
|
53
|
-
"type": "text",
|
|
54
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
"method": "POST",
|
|
58
|
-
"url": {
|
|
59
|
-
"host": ["localhost"],
|
|
60
|
-
"path": ["api", "stripe", "rest"],
|
|
61
|
-
"port": "3000",
|
|
62
|
-
"raw": "localhost:3000/api/stripe/rest"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"response": []
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "Get Product",
|
|
69
|
-
"protocolProfileBehavior": {
|
|
70
|
-
"disableBodyPruning": true
|
|
71
|
-
},
|
|
72
|
-
"request": {
|
|
73
|
-
"body": {
|
|
74
|
-
"mode": "raw",
|
|
75
|
-
"raw": "{\n \"stripeMethod\": \"subscriptions.list\",\n \"stripeArgs\": {\n \"customer\": \"cus_MGgt3Tuj3D66f2\"\n }\n}"
|
|
76
|
-
},
|
|
77
|
-
"header": [
|
|
78
|
-
{
|
|
79
|
-
"key": "Content-Type",
|
|
80
|
-
"type": "text",
|
|
81
|
-
"value": "application/json"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"key": "Authorization",
|
|
85
|
-
"type": "text",
|
|
86
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"method": "GET",
|
|
90
|
-
"url": {
|
|
91
|
-
"host": ["localhost"],
|
|
92
|
-
"path": ["api", "products", "6344664c003348299a226249"],
|
|
93
|
-
"port": "3000",
|
|
94
|
-
"raw": "localhost:3000/api/products/6344664c003348299a226249"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
"response": []
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"name": "Update Product",
|
|
101
|
-
"request": {
|
|
102
|
-
"body": {
|
|
103
|
-
"mode": "raw",
|
|
104
|
-
"raw": "{\n \"name\": \"Reactions\",\n \"price\": {\n \"stripePriceID\": \"price_1LXXU9H77M76aDnomGU5iIZu\"\n },\n \"stripeID\": \"prod_MG3bPl2yQGQK4x\",\n \"skipSync\": true\n}"
|
|
105
|
-
},
|
|
106
|
-
"header": [
|
|
107
|
-
{
|
|
108
|
-
"key": "Content-Type",
|
|
109
|
-
"type": "text",
|
|
110
|
-
"value": "application/json"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"key": "Authorization",
|
|
114
|
-
"type": "text",
|
|
115
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
"method": "PATCH",
|
|
119
|
-
"url": {
|
|
120
|
-
"host": ["localhost"],
|
|
121
|
-
"path": ["api", "products", "6344664c003348299a226249"],
|
|
122
|
-
"port": "3000",
|
|
123
|
-
"raw": "localhost:3000/api/products/6344664c003348299a226249"
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"response": []
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"name": "Create Product",
|
|
130
|
-
"request": {
|
|
131
|
-
"body": {
|
|
132
|
-
"mode": "raw",
|
|
133
|
-
"raw": "{\n \"name\": \"Test\",\n \"price\": {\n \"stripePriceID\": \"price_1LXXU9H77M76aDnomGU5iIZu\"\n },\n \"stripeID\": \"prod_MG3bPl2yQGQK4x\",\n \"skipSync\": true\n}"
|
|
134
|
-
},
|
|
135
|
-
"header": [
|
|
136
|
-
{
|
|
137
|
-
"key": "Content-Type",
|
|
138
|
-
"type": "text",
|
|
139
|
-
"value": "application/json"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"key": "Authorization",
|
|
143
|
-
"type": "text",
|
|
144
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"method": "POST",
|
|
148
|
-
"url": {
|
|
149
|
-
"host": ["localhost"],
|
|
150
|
-
"path": ["api", "products"],
|
|
151
|
-
"port": "3000",
|
|
152
|
-
"raw": "localhost:3000/api/products"
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
"response": []
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"name": "Create Stripe Customer",
|
|
159
|
-
"request": {
|
|
160
|
-
"body": {
|
|
161
|
-
"mode": "raw",
|
|
162
|
-
"raw": "{\n \"stripeMethod\": \"customers.create\",\n \"stripeArgs\": {\n \"email\": \"cta@hulu.com\",\n \"name\": \"Hulu\"\n }\n}"
|
|
163
|
-
},
|
|
164
|
-
"header": [
|
|
165
|
-
{
|
|
166
|
-
"key": "Content-Type",
|
|
167
|
-
"type": "text",
|
|
168
|
-
"value": "application/json"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"key": "Authorization",
|
|
172
|
-
"type": "text",
|
|
173
|
-
"value": "JWT {{PAYLOAD_API_TOKEN}}"
|
|
174
|
-
}
|
|
175
|
-
],
|
|
176
|
-
"method": "POST",
|
|
177
|
-
"url": {
|
|
178
|
-
"host": ["localhost"],
|
|
179
|
-
"path": ["api", "stripe", "rest"],
|
|
180
|
-
"port": "3000",
|
|
181
|
-
"raw": "localhost:3000/api/stripe/rest"
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
"response": []
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
"name": "Login",
|
|
188
|
-
"event": [
|
|
189
|
-
{
|
|
190
|
-
"listen": "test",
|
|
191
|
-
"script": {
|
|
192
|
-
"exec": [
|
|
193
|
-
"let jsonData = pm.response.json();",
|
|
194
|
-
"pm.environment.set(\"PAYLOAD_API_TOKEN\", jsonData.token);"
|
|
195
|
-
],
|
|
196
|
-
"type": "text/javascript"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
],
|
|
200
|
-
"request": {
|
|
201
|
-
"body": {
|
|
202
|
-
"mode": "raw",
|
|
203
|
-
"options": {
|
|
204
|
-
"raw": {
|
|
205
|
-
"language": "json"
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
"raw": "{\n\t\"email\": \"jacob@trbl.design\",\n\t\"password\": \"test\"\n}"
|
|
209
|
-
},
|
|
210
|
-
"description": "\t",
|
|
211
|
-
"header": [
|
|
212
|
-
{
|
|
213
|
-
"disabled": true,
|
|
214
|
-
"key": "Authorization",
|
|
215
|
-
"value": ""
|
|
216
|
-
}
|
|
217
|
-
],
|
|
218
|
-
"method": "POST",
|
|
219
|
-
"url": {
|
|
220
|
-
"host": ["localhost"],
|
|
221
|
-
"path": ["api", "users", "login"],
|
|
222
|
-
"port": "3000",
|
|
223
|
-
"raw": "localhost:3000/api/users/login"
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
"response": []
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"name": "Refresh Token",
|
|
230
|
-
"protocolProfileBehavior": {
|
|
231
|
-
"disabledSystemHeaders": {}
|
|
232
|
-
},
|
|
233
|
-
"request": {
|
|
234
|
-
"body": {
|
|
235
|
-
"mode": "raw",
|
|
236
|
-
"options": {
|
|
237
|
-
"raw": {
|
|
238
|
-
"language": "json"
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
"raw": "{\n \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImphY29ic2ZsZXRjaEBnbWFpbC5jb20iLCJpZCI6IjYwODJlZjUxMzg5ZmM2MmYzNWI2MmM2ZiIsImNvbGxlY3Rpb24iOiJ1c2VycyIsImZpcnN0TmFtZSI6IkphY29iIiwibGFzdE5hbWUiOiJGbGV0Y2hlciIsIm9yZ2FuaXphdGlvbiI6IjYwN2RiNGNmYjYzMGIyNWI5YzkzNmMzNSIsImlhdCI6MTYzMTExMDk3NSwiZXhwIjoxNjMyOTI1Mzc1fQ.OL9l8jFNaCZCU-ZDQpH-EJauaRM-5JT4_Y3J_-aC-aY\"\n}"
|
|
242
|
-
},
|
|
243
|
-
"header": [],
|
|
244
|
-
"method": "POST",
|
|
245
|
-
"url": {
|
|
246
|
-
"host": ["localhost"],
|
|
247
|
-
"path": ["api", "users", "refresh-token"],
|
|
248
|
-
"port": "3000",
|
|
249
|
-
"raw": "localhost:3000/api/users/refresh-token"
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
"response": []
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
"name": "Me",
|
|
256
|
-
"event": [
|
|
257
|
-
{
|
|
258
|
-
"listen": "test",
|
|
259
|
-
"script": {
|
|
260
|
-
"exec": [
|
|
261
|
-
"let jsonData = pm.response.json();",
|
|
262
|
-
"pm.environment.set(\"PAYLOAD_API_TOKEN\", jsonData.token);"
|
|
263
|
-
],
|
|
264
|
-
"type": "text/javascript"
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
],
|
|
268
|
-
"protocolProfileBehavior": {
|
|
269
|
-
"disableBodyPruning": true
|
|
270
|
-
},
|
|
271
|
-
"request": {
|
|
272
|
-
"body": {
|
|
273
|
-
"mode": "raw",
|
|
274
|
-
"raw": ""
|
|
275
|
-
},
|
|
276
|
-
"description": "\t",
|
|
277
|
-
"header": [
|
|
278
|
-
{
|
|
279
|
-
"disabled": true,
|
|
280
|
-
"key": "Authorization",
|
|
281
|
-
"value": ""
|
|
282
|
-
}
|
|
283
|
-
],
|
|
284
|
-
"method": "GET",
|
|
285
|
-
"url": {
|
|
286
|
-
"host": ["localhost"],
|
|
287
|
-
"path": ["api", "users", "me"],
|
|
288
|
-
"port": "3000",
|
|
289
|
-
"query": [
|
|
290
|
-
{
|
|
291
|
-
"key": "depth",
|
|
292
|
-
"value": "1"
|
|
293
|
-
}
|
|
294
|
-
],
|
|
295
|
-
"raw": "localhost:3000/api/users/me?depth=1"
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
"response": []
|
|
299
|
-
}
|
|
300
|
-
]
|
|
301
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/types'
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/types')
|