@payloadcms/plugin-stripe 0.0.19 → 3.0.0-alpha.67

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 (71) hide show
  1. package/README.md +3 -285
  2. package/dist/admin.d.ts +4 -0
  3. package/dist/admin.d.ts.map +1 -0
  4. package/dist/admin.js +34 -0
  5. package/dist/admin.js.map +1 -0
  6. package/dist/fields/getFields.d.ts +12 -0
  7. package/dist/fields/getFields.d.ts.map +1 -0
  8. package/dist/fields/getFields.js +46 -0
  9. package/dist/fields/getFields.js.map +1 -0
  10. package/dist/hooks/createNewInStripe.d.ts +7 -2
  11. package/dist/hooks/createNewInStripe.d.ts.map +1 -0
  12. package/dist/hooks/createNewInStripe.js +70 -124
  13. package/dist/hooks/createNewInStripe.js.map +1 -1
  14. package/dist/hooks/deleteFromStripe.d.ts +7 -2
  15. package/dist/hooks/deleteFromStripe.d.ts.map +1 -0
  16. package/dist/hooks/deleteFromStripe.js +30 -87
  17. package/dist/hooks/deleteFromStripe.js.map +1 -1
  18. package/dist/hooks/syncExistingWithStripe.d.ts +7 -2
  19. package/dist/hooks/syncExistingWithStripe.d.ts.map +1 -0
  20. package/dist/hooks/syncExistingWithStripe.js +42 -94
  21. package/dist/hooks/syncExistingWithStripe.js.map +1 -1
  22. package/dist/index.d.ts +5 -3
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +88 -166
  25. package/dist/index.js.map +1 -1
  26. package/dist/payload-stripe-plugin.postman_collection.json +301 -0
  27. package/dist/routes/rest.d.ts +4 -6
  28. package/dist/routes/rest.d.ts.map +1 -0
  29. package/dist/routes/rest.js +33 -76
  30. package/dist/routes/rest.js.map +1 -1
  31. package/dist/routes/webhooks.d.ts +4 -6
  32. package/dist/routes/webhooks.d.ts.map +1 -0
  33. package/dist/routes/webhooks.js +49 -94
  34. package/dist/routes/webhooks.js.map +1 -1
  35. package/dist/types.d.ts +138 -11
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +2 -2
  38. package/dist/types.js.map +1 -1
  39. package/dist/ui/LinkToDoc.d.ts +4 -7
  40. package/dist/ui/LinkToDoc.d.ts.map +1 -0
  41. package/dist/ui/LinkToDoc.js +29 -31
  42. package/dist/ui/LinkToDoc.js.map +1 -1
  43. package/dist/utilities/deepen.d.ts +1 -0
  44. package/dist/utilities/deepen.d.ts.map +1 -0
  45. package/dist/utilities/deepen.js +9 -16
  46. package/dist/utilities/deepen.js.map +1 -1
  47. package/dist/utilities/stripeProxy.d.ts +2 -1
  48. package/dist/utilities/stripeProxy.d.ts.map +1 -0
  49. package/dist/utilities/stripeProxy.js +37 -88
  50. package/dist/utilities/stripeProxy.js.map +1 -1
  51. package/dist/webhooks/handleCreatedOrUpdated.d.ts +3 -2
  52. package/dist/webhooks/handleCreatedOrUpdated.d.ts.map +1 -0
  53. package/dist/webhooks/handleCreatedOrUpdated.js +115 -196
  54. package/dist/webhooks/handleCreatedOrUpdated.js.map +1 -1
  55. package/dist/webhooks/handleDeleted.d.ts +2 -1
  56. package/dist/webhooks/handleDeleted.d.ts.map +1 -0
  57. package/dist/webhooks/handleDeleted.js +44 -102
  58. package/dist/webhooks/handleDeleted.js.map +1 -1
  59. package/dist/webhooks/index.d.ts +2 -1
  60. package/dist/webhooks/index.d.ts.map +1 -0
  61. package/dist/webhooks/index.js +46 -90
  62. package/dist/webhooks/index.js.map +1 -1
  63. package/package.json +50 -45
  64. package/types.d.ts +1 -1
  65. package/types.js +1 -1
  66. package/dist/extendWebpackConfig.d.ts +0 -3
  67. package/dist/extendWebpackConfig.js +0 -31
  68. package/dist/extendWebpackConfig.js.map +0 -1
  69. package/dist/mocks/serverModule.d.ts +0 -2
  70. package/dist/mocks/serverModule.js +0 -6
  71. package/dist/mocks/serverModule.js.map +0 -1
@@ -1,79 +1,36 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.stripeREST = void 0;
40
- var errors_1 = require("payload/errors");
41
- var stripeProxy_1 = require("../utilities/stripeProxy");
42
- var stripeREST = function (args) { return __awaiter(void 0, void 0, void 0, function () {
43
- var req, res, stripeConfig, payload, user, _a, stripeMethod, stripeArgs, stripeSecretKey, pluginRes, status_1, error_1, message;
44
- return __generator(this, function (_b) {
45
- switch (_b.label) {
46
- case 0:
47
- req = args.req, res = args.res, stripeConfig = args.stripeConfig;
48
- payload = req.payload, user = req.user, _a = req.body, stripeMethod = _a.stripeMethod, stripeArgs = _a.stripeArgs;
49
- stripeSecretKey = stripeConfig.stripeSecretKey;
50
- _b.label = 1;
51
- case 1:
52
- _b.trys.push([1, 3, , 4]);
53
- if (!user) {
54
- // TODO: make this customizable from the config
55
- throw new errors_1.Forbidden();
56
- }
57
- return [4 /*yield*/, (0, stripeProxy_1.stripeProxy)({
58
- stripeSecretKey: stripeSecretKey,
59
- stripeMethod: stripeMethod,
60
- stripeArgs: stripeArgs,
61
- })];
62
- case 2:
63
- pluginRes = _b.sent();
64
- status_1 = pluginRes.status;
65
- res.status(status_1).json(pluginRes);
66
- return [3 /*break*/, 4];
67
- case 3:
68
- error_1 = _b.sent();
69
- message = "An error has occurred in the Stripe plugin REST handler: '".concat(error_1, "'");
70
- payload.logger.error(message);
71
- return [2 /*return*/, res.status(500).json({
72
- message: message,
73
- })];
74
- case 4: return [2 /*return*/];
1
+ import { Forbidden } from 'payload/errors';
2
+ import { stripeProxy } from '../utilities/stripeProxy.js';
3
+ export const stripeREST = async (args)=>{
4
+ let responseStatus = 200;
5
+ let responseJSON;
6
+ const { req, stripeConfig } = args;
7
+ const { data: { stripeArgs, stripeMethod }, payload, user } = req;
8
+ const { stripeSecretKey } = stripeConfig;
9
+ try {
10
+ if (!user) {
11
+ // TODO: make this customizable from the config
12
+ throw new Forbidden(req.t);
75
13
  }
14
+ responseJSON = await stripeProxy({
15
+ // @ts-expect-error
16
+ stripeArgs,
17
+ // @ts-expect-error
18
+ stripeMethod,
19
+ stripeSecretKey
20
+ });
21
+ const { status } = responseJSON;
22
+ responseStatus = status;
23
+ } catch (error) {
24
+ const message = `An error has occurred in the Stripe plugin REST handler: '${JSON.stringify(error)}'`;
25
+ payload.logger.error(message);
26
+ responseStatus = 500;
27
+ responseJSON = {
28
+ message
29
+ };
30
+ }
31
+ return Response.json(responseJSON, {
32
+ status: responseStatus
76
33
  });
77
- }); };
78
- exports.stripeREST = stripeREST;
34
+ };
35
+
79
36
  //# sourceMappingURL=rest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/routes/rest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA0C;AAI1C,wDAAsD;AAE/C,IAAM,UAAU,GAAG,UAAO,IAKhC;;;;;gBACS,GAAG,GAAwB,IAAI,IAA5B,EAAE,GAAG,GAAmB,IAAI,IAAvB,EAAE,YAAY,GAAK,IAAI,aAAT,CAAS;gBAGrC,OAAO,GAML,GAAG,QANE,EACP,IAAI,GAKF,GAAG,KALD,EACJ,KAIE,GAAG,KADJ,EAFC,YAAY,kBAAA,EACZ,UAAU,gBAAA,CAEP;gBAEC,eAAe,GAAK,YAAY,gBAAjB,CAAiB;;;;gBAGtC,IAAI,CAAC,IAAI,EAAE;oBACT,+CAA+C;oBAC/C,MAAM,IAAI,kBAAS,EAAE,CAAA;iBACtB;gBAEiB,qBAAM,IAAA,yBAAW,EAAC;wBAClC,eAAe,iBAAA;wBACf,YAAY,cAAA;wBACZ,UAAU,YAAA;qBACX,CAAC,EAAA;;gBAJI,SAAS,GAAG,SAIhB;gBAEM,WAAW,SAAS,OAAd,CAAc;gBAE5B,GAAG,CAAC,MAAM,CAAC,QAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;;;;gBAE5B,OAAO,GAAG,oEAA6D,OAAK,MAAG,CAAA;gBACrF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBAC7B,sBAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;wBAC1B,OAAO,SAAA;qBACR,CAAC,EAAA;;;;KAEL,CAAA;AAzCY,QAAA,UAAU,cAyCtB"}
1
+ {"version":3,"sources":["../../src/routes/rest.ts"],"sourcesContent":["import type { PayloadRequestWithData } from 'payload/types'\n\nimport { Forbidden } from 'payload/errors'\n\nimport type { StripeConfig } from '../types.js'\n\nimport { stripeProxy } from '../utilities/stripeProxy.js'\n\nexport const stripeREST = async (args: {\n req: PayloadRequestWithData\n stripeConfig: StripeConfig\n}): Promise<any> => {\n let responseStatus = 200\n let responseJSON\n\n const { req, stripeConfig } = 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 } = stripeConfig\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","req","stripeConfig","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,GAAG,EAAEC,YAAY,EAAE,GAAGJ;IAE9B,MAAM,EACJK,MAAM,EACJC,UAAU,EACVC,YAAY,EACb,EACDC,OAAO,EACPC,IAAI,EACL,GAAGN;IAEJ,MAAM,EAAEO,eAAe,EAAE,GAAGN;IAE5B,IAAI;QACF,IAAI,CAACK,MAAM;YACT,+CAA+C;YAC/C,MAAM,IAAIZ,UAAUM,IAAIQ,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,11 +1,9 @@
1
- import type { Response } from 'express';
2
1
  import type { Config as PayloadConfig } from 'payload/config';
3
- import type { PayloadRequest } from 'payload/dist/types';
4
- import type { StripeConfig } from '../types';
2
+ import type { PayloadRequestWithData } from 'payload/types';
3
+ import type { StripeConfig } from '../types.js';
5
4
  export declare const stripeWebhooks: (args: {
6
- req: PayloadRequest;
7
- res: Response;
8
- next: any;
9
5
  config: PayloadConfig;
6
+ req: PayloadRequestWithData;
10
7
  stripeConfig: StripeConfig;
11
8
  }) => Promise<any>;
9
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +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,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,eAAO,MAAM,cAAc,SAAgB;IACzC,MAAM,EAAE,aAAa,CAAA;IACrB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,QAAQ,GAAG,CAwEd,CAAA"}
@@ -1,112 +1,67 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
1
+ import Stripe from 'stripe';
2
+ import { handleWebhooks } from '../webhooks/index.js';
3
+ export const stripeWebhooks = async (args)=>{
4
+ const { config, req, stripeConfig } = args;
5
+ let returnStatus = 200;
6
+ const { stripeSecretKey, stripeWebhooksEndpointSecret, webhooks } = stripeConfig;
7
+ if (stripeWebhooksEndpointSecret) {
8
+ const stripe = new Stripe(stripeSecretKey, {
9
+ // api version can only be the latest, stripe recommends ts ignoring it
10
+ apiVersion: '2022-08-01',
11
+ appInfo: {
12
+ name: 'Stripe Payload Plugin',
13
+ url: 'https://payloadcms.com'
32
14
  }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.stripeWebhooks = void 0;
43
- var stripe_1 = __importDefault(require("stripe"));
44
- var webhooks_1 = require("../webhooks");
45
- var stripeWebhooks = function (args) { return __awaiter(void 0, void 0, void 0, function () {
46
- var req, res, config, stripeConfig, stripeSecretKey, stripeWebhooksEndpointSecret, webhooks, stripe, stripeSignature, event_1, msg, webhookEventHandler;
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- req = args.req, res = args.res, config = args.config, stripeConfig = args.stripeConfig;
51
- stripeSecretKey = stripeConfig.stripeSecretKey, stripeWebhooksEndpointSecret = stripeConfig.stripeWebhooksEndpointSecret, webhooks = stripeConfig.webhooks;
52
- if (!stripeWebhooksEndpointSecret) return [3 /*break*/, 2];
53
- stripe = new stripe_1.default(stripeSecretKey, {
54
- apiVersion: '2022-08-01',
55
- appInfo: {
56
- name: 'Stripe Payload Plugin',
57
- url: 'https://payloadcms.com',
58
- },
15
+ });
16
+ const body = await req.text();
17
+ const stripeSignature = req.headers.get('stripe-signature');
18
+ if (stripeSignature) {
19
+ let event;
20
+ try {
21
+ event = stripe.webhooks.constructEvent(body, stripeSignature, stripeWebhooksEndpointSecret);
22
+ } catch (err) {
23
+ const msg = err instanceof Error ? err.message : JSON.stringify(err);
24
+ req.payload.logger.error(`Error constructing Stripe event: ${msg}`);
25
+ returnStatus = 400;
26
+ }
27
+ if (event) {
28
+ handleWebhooks({
29
+ config,
30
+ event,
31
+ payload: req.payload,
32
+ stripe,
33
+ stripeConfig
59
34
  });
60
- stripeSignature = req.headers['stripe-signature'];
61
- if (!stripeSignature) return [3 /*break*/, 2];
62
- try {
63
- event_1 = stripe.webhooks.constructEvent(req.body, stripeSignature, stripeWebhooksEndpointSecret);
64
- }
65
- catch (err) {
66
- msg = err instanceof Error ? err.message : err;
67
- req.payload.logger.error("Error constructing Stripe event: ".concat(msg));
68
- res.status(400);
69
- }
70
- if (!event_1) return [3 /*break*/, 2];
71
- return [4 /*yield*/, (0, webhooks_1.handleWebhooks)({
72
- payload: req.payload,
73
- event: event_1,
74
- stripe: stripe,
75
- config: config,
76
- stripeConfig: stripeConfig,
77
- })
78
- // Fire external webhook handlers if they exist
79
- ];
80
- case 1:
81
- _a.sent();
82
35
  // Fire external webhook handlers if they exist
83
36
  if (typeof webhooks === 'function') {
84
37
  webhooks({
38
+ config,
39
+ event,
85
40
  payload: req.payload,
86
- event: event_1,
87
- stripe: stripe,
88
- config: config,
89
- stripeConfig: stripeConfig,
41
+ stripe,
42
+ stripeConfig
90
43
  });
91
44
  }
92
45
  if (typeof webhooks === 'object') {
93
- webhookEventHandler = webhooks[event_1.type];
46
+ const webhookEventHandler = webhooks[event.type];
94
47
  if (typeof webhookEventHandler === 'function') {
95
48
  webhookEventHandler({
49
+ config,
50
+ event,
96
51
  payload: req.payload,
97
- event: event_1,
98
- stripe: stripe,
99
- config: config,
100
- stripeConfig: stripeConfig,
52
+ stripe,
53
+ stripeConfig
101
54
  });
102
55
  }
103
56
  }
104
- _a.label = 2;
105
- case 2:
106
- res.json({ received: true });
107
- return [2 /*return*/];
57
+ }
108
58
  }
59
+ }
60
+ return Response.json({
61
+ received: true
62
+ }, {
63
+ status: returnStatus
109
64
  });
110
- }); };
111
- exports.stripeWebhooks = stripeWebhooks;
65
+ };
66
+
112
67
  //# sourceMappingURL=webhooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/routes/webhooks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,kDAA2B;AAG3B,wCAA4C;AAErC,IAAM,cAAc,GAAG,UAAO,IAMpC;;;;;gBACS,GAAG,GAAgC,IAAI,IAApC,EAAE,GAAG,GAA2B,IAAI,IAA/B,EAAE,MAAM,GAAmB,IAAI,OAAvB,EAAE,YAAY,GAAK,IAAI,aAAT,CAAS;gBAEvC,eAAe,GAA6C,YAAY,gBAAzD,EAAE,4BAA4B,GAAe,YAAY,6BAA3B,EAAE,QAAQ,GAAK,YAAY,SAAjB,CAAiB;qBAE5E,4BAA4B,EAA5B,wBAA4B;gBACxB,MAAM,GAAG,IAAI,gBAAM,CAAC,eAAe,EAAE;oBACzC,UAAU,EAAE,YAAY;oBACxB,OAAO,EAAE;wBACP,IAAI,EAAE,uBAAuB;wBAC7B,GAAG,EAAE,wBAAwB;qBAC9B;iBACF,CAAC,CAAA;gBAEI,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;qBAEnD,eAAe,EAAf,wBAAe;gBAGjB,IAAI;oBACF,OAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,cAAc,CACpC,GAAG,CAAC,IAAI,EACR,eAAe,EACf,4BAA4B,CAC7B,CAAA;iBACF;gBAAC,OAAO,GAAY,EAAE;oBACf,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;oBACpD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAAoC,GAAG,CAAE,CAAC,CAAA;oBACnE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;iBAChB;qBAEG,OAAK,EAAL,wBAAK;gBACP,qBAAM,IAAA,yBAAc,EAAC;wBACnB,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,KAAK,SAAA;wBACL,MAAM,QAAA;wBACN,MAAM,QAAA;wBACN,YAAY,cAAA;qBACb,CAAC;oBAEF,+CAA+C;kBAF7C;;gBANF,SAME,CAAA;gBAEF,+CAA+C;gBAC/C,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;oBAClC,QAAQ,CAAC;wBACP,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,KAAK,SAAA;wBACL,MAAM,QAAA;wBACN,MAAM,QAAA;wBACN,YAAY,cAAA;qBACb,CAAC,CAAA;iBACH;gBAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;oBAC1B,mBAAmB,GAAG,QAAQ,CAAC,OAAK,CAAC,IAAI,CAAC,CAAA;oBAChD,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;wBAC7C,mBAAmB,CAAC;4BAClB,OAAO,EAAE,GAAG,CAAC,OAAO;4BACpB,KAAK,SAAA;4BACL,MAAM,QAAA;4BACN,MAAM,QAAA;4BACN,YAAY,cAAA;yBACb,CAAC,CAAA;qBACH;iBACF;;;gBAKP,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;KAC7B,CAAA;AA1EY,QAAA,cAAc,kBA0E1B"}
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 { StripeConfig } from '../types.js'\n\nimport { handleWebhooks } from '../webhooks/index.js'\n\nexport const stripeWebhooks = async (args: {\n config: PayloadConfig\n req: PayloadRequestWithData\n stripeConfig: StripeConfig\n}): Promise<any> => {\n const { config, req, stripeConfig } = args\n let returnStatus = 200\n\n const { stripeSecretKey, stripeWebhooksEndpointSecret, webhooks } = stripeConfig\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 stripe,\n stripeConfig,\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 stripe,\n stripeConfig,\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 stripe,\n stripeConfig,\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","req","stripeConfig","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,GAAG,EAAEC,YAAY,EAAE,GAAGH;IACtC,IAAII,eAAe;IAEnB,MAAM,EAAEC,eAAe,EAAEC,4BAA4B,EAAEC,QAAQ,EAAE,GAAGJ;IAEpE,IAAIG,8BAA8B;QAChC,MAAME,SAAS,IAAIX,OAAOQ,iBAAiB;YACzC,uEAAuE;YACvEI,YAAY;YACZC,SAAS;gBACPC,MAAM;gBACNC,KAAK;YACP;QACF;QAEA,MAAMC,OAAO,MAAMX,IAAIY,IAAI;QAC3B,MAAMC,kBAAkBb,IAAIc,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;gBACxElB,IAAIwB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,iCAAiC,EAAEP,IAAI,CAAC;gBAClEjB,eAAe;YACjB;YAEA,IAAIc,OAAO;gBACTpB,eAAe;oBACbG;oBACAiB;oBACAQ,SAASxB,IAAIwB,OAAO;oBACpBlB;oBACAL;gBACF;gBAEA,+CAA+C;gBAC/C,IAAI,OAAOI,aAAa,YAAY;oBAClCA,SAAS;wBACPN;wBACAiB;wBACAQ,SAASxB,IAAIwB,OAAO;wBACpBlB;wBACAL;oBACF;gBACF;gBAEA,IAAI,OAAOI,aAAa,UAAU;oBAChC,MAAMsB,sBAAsBtB,QAAQ,CAACW,MAAMY,IAAI,CAAC;oBAChD,IAAI,OAAOD,wBAAwB,YAAY;wBAC7CA,oBAAoB;4BAClB5B;4BACAiB;4BACAQ,SAASxB,IAAIwB,OAAO;4BACpBlB;4BACAL;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAO4B,SAASC,IAAI,CAClB;QAAEC,UAAU;IAAK,GACjB;QACEC,QAAQ9B;IACV;AAEJ,EAAC"}
package/dist/types.d.ts CHANGED
@@ -1,11 +1,137 @@
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" />
1
127
  import type { Payload } from 'payload';
2
128
  import type { Config as PayloadConfig } from 'payload/config';
3
129
  import type Stripe from 'stripe';
4
130
  export type StripeWebhookHandler<T = any> = (args: {
5
- payload: Payload;
131
+ config: PayloadConfig;
6
132
  event: T;
133
+ payload: Payload;
7
134
  stripe: Stripe;
8
- config: PayloadConfig;
9
135
  stripeConfig?: StripeConfig;
10
136
  }) => void;
11
137
  export interface StripeWebhookHandlers {
@@ -17,28 +143,29 @@ export interface FieldSyncConfig {
17
143
  }
18
144
  export interface SyncConfig {
19
145
  collection: string;
146
+ fields: FieldSyncConfig[];
20
147
  stripeResourceType: 'customers' | 'products';
21
148
  stripeResourceTypeSingular: 'customer' | 'product';
22
- fields: FieldSyncConfig[];
23
149
  }
24
150
  export interface StripeConfig {
25
- stripeSecretKey: string;
26
151
  isTestKey?: boolean;
27
- stripeWebhooksEndpointSecret?: string;
152
+ logs?: boolean;
28
153
  rest?: boolean;
29
- webhooks?: StripeWebhookHandler | StripeWebhookHandlers;
154
+ stripeSecretKey: string;
155
+ stripeWebhooksEndpointSecret?: string;
30
156
  sync?: SyncConfig[];
31
- logs?: boolean;
157
+ webhooks?: StripeWebhookHandler | StripeWebhookHandlers;
32
158
  }
33
159
  export type SanitizedStripeConfig = StripeConfig & {
34
160
  sync: SyncConfig[];
35
161
  };
36
162
  export type StripeProxy = (args: {
37
- stripeSecretKey: string;
38
- stripeMethod: string;
39
163
  stripeArgs: any[];
164
+ stripeMethod: string;
165
+ stripeSecretKey: string;
40
166
  }) => Promise<{
41
- status: number;
42
- message?: string;
43
167
  data?: any;
168
+ message?: string;
169
+ status: number;
44
170
  }>;
171
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,KAAK,IAAI,CAAA;AAEV,MAAM,WAAW,qBAAqB;IACpC,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAAA;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,kBAAkB,EAAE,WAAW,GAAG,UAAU,CAAA;IAC5C,0BAA0B,EAAE,UAAU,GAAG,SAAS,CAAA;CACnD;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,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;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,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 CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export { };
2
+
3
3
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
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 stripe: Stripe\n stripeConfig?: StripeConfig\n}) => void\n\nexport interface StripeWebhookHandlers {\n [webhookName: string]: StripeWebhookHandler\n}\n\nexport interface FieldSyncConfig {\n fieldPath: string\n stripeProperty: string\n}\n\nexport interface 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 interface StripeConfig {\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 SanitizedStripeConfig = StripeConfig & {\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,4 @@
1
- import React from 'react';
2
- import { UIField } from 'payload/dist/fields/config/types';
3
- export declare const LinkToDoc: React.FC<UIField & {
4
- isTestKey: boolean;
5
- stripeResourceType: string;
6
- nameOfIDField: string;
7
- }>;
1
+ import type { CustomComponent } from 'payload/config';
2
+ import type { UIField } from 'payload/types';
3
+ export declare const LinkToDoc: CustomComponent<UIField>;
4
+ //# sourceMappingURL=LinkToDoc.d.ts.map
@@ -0,0 +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"}