@payloadcms/plugin-stripe 0.0.17 → 0.0.19
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/README.md +36 -36
- package/dist/extendWebpackConfig.d.ts +0 -1
- package/dist/extendWebpackConfig.js +28 -28
- package/dist/extendWebpackConfig.js.map +1 -0
- package/dist/hooks/createNewInStripe.d.ts +0 -1
- package/dist/hooks/createNewInStripe.js +124 -82
- package/dist/hooks/createNewInStripe.js.map +1 -0
- package/dist/hooks/deleteFromStripe.d.ts +0 -1
- package/dist/hooks/deleteFromStripe.js +87 -44
- package/dist/hooks/deleteFromStripe.js.map +1 -0
- package/dist/hooks/syncExistingWithStripe.d.ts +0 -1
- package/dist/hooks/syncExistingWithStripe.js +93 -55
- package/dist/hooks/syncExistingWithStripe.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +161 -109
- package/dist/index.js.map +1 -0
- package/dist/mocks/serverModule.d.ts +2 -0
- package/dist/mocks/serverModule.js +6 -0
- package/dist/mocks/serverModule.js.map +1 -0
- package/dist/routes/rest.d.ts +1 -2
- package/dist/routes/rest.js +76 -35
- package/dist/routes/rest.js.map +1 -0
- package/dist/routes/webhooks.d.ts +2 -3
- package/dist/routes/webhooks.js +94 -59
- package/dist/routes/webhooks.js.map +1 -0
- package/dist/types.d.ts +11 -12
- package/dist/types.js +2 -5
- package/dist/types.js.map +1 -0
- package/dist/ui/LinkToDoc.d.ts +2 -3
- package/dist/ui/LinkToDoc.js +31 -43
- package/dist/ui/LinkToDoc.js.map +1 -0
- package/dist/utilities/deepen.d.ts +0 -1
- package/dist/utilities/deepen.js +17 -20
- package/dist/utilities/deepen.js.map +1 -0
- package/dist/utilities/stripeProxy.d.ts +0 -1
- package/dist/utilities/stripeProxy.js +88 -52
- package/dist/utilities/stripeProxy.js.map +1 -0
- package/dist/webhooks/handleCreatedOrUpdated.d.ts +1 -2
- package/dist/webhooks/handleCreatedOrUpdated.js +196 -125
- package/dist/webhooks/handleCreatedOrUpdated.js.map +1 -0
- package/dist/webhooks/handleDeleted.d.ts +0 -1
- package/dist/webhooks/handleDeleted.js +102 -53
- package/dist/webhooks/handleDeleted.js.map +1 -0
- package/dist/webhooks/index.d.ts +0 -1
- package/dist/webhooks/index.js +89 -55
- package/dist/webhooks/index.js.map +1 -0
- package/package.json +28 -13
- package/types.d.ts +1 -1
- package/types.js +1 -1
- package/dist/admin.d.ts +0 -4
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js +0 -44
- package/dist/extendWebpackConfig.d.ts.map +0 -1
- package/dist/fields/getFields.d.ts +0 -12
- package/dist/fields/getFields.d.ts.map +0 -1
- package/dist/fields/getFields.js +0 -56
- package/dist/hooks/createNewInStripe.d.ts.map +0 -1
- package/dist/hooks/deleteFromStripe.d.ts.map +0 -1
- package/dist/hooks/syncExistingWithStripe.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/routes/rest.d.ts.map +0 -1
- package/dist/routes/webhooks.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/ui/LinkToDoc.d.ts.map +0 -1
- package/dist/utilities/deepen.d.ts.map +0 -1
- package/dist/utilities/stripeProxy.d.ts.map +0 -1
- package/dist/webhooks/handleCreatedOrUpdated.d.ts.map +0 -1
- package/dist/webhooks/handleDeleted.d.ts.map +0 -1
- package/dist/webhooks/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,124 +1,176 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
const _express = /*#__PURE__*/ _interop_require_default(require("express"));
|
|
12
|
-
const _extendWebpackConfig = require("./extendWebpackConfig");
|
|
13
|
-
const _getFields = require("./fields/getFields");
|
|
14
|
-
const _createNewInStripe = require("./hooks/createNewInStripe");
|
|
15
|
-
const _deleteFromStripe = require("./hooks/deleteFromStripe");
|
|
16
|
-
const _syncExistingWithStripe = require("./hooks/syncExistingWithStripe");
|
|
17
|
-
const _rest = require("./routes/rest");
|
|
18
|
-
const _webhooks = require("./routes/webhooks");
|
|
19
|
-
function _interop_require_default(obj) {
|
|
20
|
-
return obj && obj.__esModule ? obj : {
|
|
21
|
-
default: obj
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
22
10
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
var express_1 = __importDefault(require("express"));
|
|
63
|
+
var extendWebpackConfig_1 = require("./extendWebpackConfig");
|
|
64
|
+
var createNewInStripe_1 = require("./hooks/createNewInStripe");
|
|
65
|
+
var deleteFromStripe_1 = require("./hooks/deleteFromStripe");
|
|
66
|
+
var syncExistingWithStripe_1 = require("./hooks/syncExistingWithStripe");
|
|
67
|
+
var rest_1 = require("./routes/rest");
|
|
68
|
+
var webhooks_1 = require("./routes/webhooks");
|
|
69
|
+
var LinkToDoc_1 = require("./ui/LinkToDoc");
|
|
70
|
+
var stripePlugin = function (incomingStripeConfig) {
|
|
71
|
+
return function (config) {
|
|
72
|
+
var _a;
|
|
73
|
+
var collections = config.collections;
|
|
26
74
|
// set config defaults here
|
|
27
|
-
|
|
28
|
-
...incomingStripeConfig,
|
|
75
|
+
var stripeConfig = __assign(__assign({}, incomingStripeConfig), {
|
|
29
76
|
// TODO: in the next major version, default this to `false`
|
|
30
|
-
rest: incomingStripeConfig
|
|
31
|
-
sync: incomingStripeConfig?.sync || []
|
|
32
|
-
};
|
|
77
|
+
rest: (_a = incomingStripeConfig === null || incomingStripeConfig === void 0 ? void 0 : incomingStripeConfig.rest) !== null && _a !== void 0 ? _a : true, sync: (incomingStripeConfig === null || incomingStripeConfig === void 0 ? void 0 : incomingStripeConfig.sync) || [] });
|
|
33
78
|
// NOTE: env variables are never passed to the client, but we need to know if `stripeSecretKey` is a test key
|
|
34
79
|
// unfortunately we must set the 'isTestKey' property on the config instead of using the following code:
|
|
35
80
|
// const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');
|
|
36
|
-
return {
|
|
37
|
-
...config,
|
|
38
|
-
admin: {
|
|
39
|
-
...config.admin,
|
|
40
|
-
webpack: (0, _extendWebpackConfig.extendWebpackConfig)(config)
|
|
41
|
-
},
|
|
42
|
-
collections: collections?.map((collection)=>{
|
|
43
|
-
const { hooks: existingHooks } = collection;
|
|
44
|
-
const syncConfig = stripeConfig.sync?.find((sync)=>sync.collection === collection.slug);
|
|
45
|
-
if (syncConfig) {
|
|
46
|
-
const fields = (0, _getFields.getFields)({
|
|
47
|
-
collection,
|
|
48
|
-
stripeConfig,
|
|
49
|
-
syncConfig
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
...collection,
|
|
53
|
-
fields,
|
|
54
|
-
hooks: {
|
|
55
|
-
...collection.hooks,
|
|
56
|
-
afterDelete: [
|
|
57
|
-
...existingHooks?.afterDelete || [],
|
|
58
|
-
async (args)=>(0, _deleteFromStripe.deleteFromStripe)({
|
|
59
|
-
...args,
|
|
60
|
-
collection,
|
|
61
|
-
stripeConfig
|
|
62
|
-
})
|
|
63
|
-
],
|
|
64
|
-
beforeChange: [
|
|
65
|
-
...existingHooks?.beforeChange || [],
|
|
66
|
-
async (args)=>(0, _syncExistingWithStripe.syncExistingWithStripe)({
|
|
67
|
-
...args,
|
|
68
|
-
collection,
|
|
69
|
-
stripeConfig
|
|
70
|
-
})
|
|
71
|
-
],
|
|
72
|
-
beforeValidate: [
|
|
73
|
-
...existingHooks?.beforeValidate || [],
|
|
74
|
-
async (args)=>(0, _createNewInStripe.createNewInStripe)({
|
|
75
|
-
...args,
|
|
76
|
-
collection,
|
|
77
|
-
stripeConfig
|
|
78
|
-
})
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return collection;
|
|
84
|
-
}),
|
|
85
|
-
endpoints: [
|
|
86
|
-
...config?.endpoints || [],
|
|
81
|
+
return __assign(__assign({}, config), { admin: __assign(__assign({}, config.admin), { webpack: (0, extendWebpackConfig_1.extendWebpackConfig)(config) }), endpoints: __spreadArray(__spreadArray(__spreadArray([], ((config === null || config === void 0 ? void 0 : config.endpoints) || []), true), [
|
|
87
82
|
{
|
|
83
|
+
path: '/stripe/webhooks',
|
|
84
|
+
method: 'post',
|
|
85
|
+
root: true,
|
|
88
86
|
handler: [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
res,
|
|
98
|
-
stripeConfig
|
|
87
|
+
express_1.default.raw({ type: 'application/json' }),
|
|
88
|
+
function (req, res, next) {
|
|
89
|
+
(0, webhooks_1.stripeWebhooks)({
|
|
90
|
+
req: req,
|
|
91
|
+
res: res,
|
|
92
|
+
next: next,
|
|
93
|
+
config: config,
|
|
94
|
+
stripeConfig: stripeConfig,
|
|
99
95
|
});
|
|
100
|
-
}
|
|
96
|
+
},
|
|
101
97
|
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
...incomingStripeConfig?.rest ? [
|
|
98
|
+
}
|
|
99
|
+
], false), ((incomingStripeConfig === null || incomingStripeConfig === void 0 ? void 0 : incomingStripeConfig.rest)
|
|
100
|
+
? [
|
|
107
101
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
path: '/stripe/rest',
|
|
103
|
+
method: 'post',
|
|
104
|
+
handler: function (req, res, next) {
|
|
105
|
+
(0, rest_1.stripeREST)({
|
|
106
|
+
req: req,
|
|
107
|
+
res: res,
|
|
108
|
+
next: next,
|
|
109
|
+
stripeConfig: stripeConfig,
|
|
114
110
|
});
|
|
115
111
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
: []), true), collections: collections === null || collections === void 0 ? void 0 : collections.map(function (collection) {
|
|
115
|
+
var _a;
|
|
116
|
+
var existingHooks = collection.hooks;
|
|
117
|
+
var syncConfig = (_a = stripeConfig.sync) === null || _a === void 0 ? void 0 : _a.find(function (sync) { return sync.collection === collection.slug; });
|
|
118
|
+
if (syncConfig) {
|
|
119
|
+
return __assign(__assign({}, collection), { hooks: __assign(__assign({}, collection.hooks), { beforeValidate: __spreadArray(__spreadArray([], ((existingHooks === null || existingHooks === void 0 ? void 0 : existingHooks.beforeValidate) || []), true), [
|
|
120
|
+
function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
return [2 /*return*/, (0, createNewInStripe_1.createNewInStripe)(__assign(__assign({}, args), { collection: collection, stripeConfig: stripeConfig }))];
|
|
123
|
+
});
|
|
124
|
+
}); },
|
|
125
|
+
], false), beforeChange: __spreadArray(__spreadArray([], ((existingHooks === null || existingHooks === void 0 ? void 0 : existingHooks.beforeChange) || []), true), [
|
|
126
|
+
function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
return [2 /*return*/, (0, syncExistingWithStripe_1.syncExistingWithStripe)(__assign(__assign({}, args), { collection: collection, stripeConfig: stripeConfig }))];
|
|
129
|
+
});
|
|
130
|
+
}); },
|
|
131
|
+
], false), afterDelete: __spreadArray(__spreadArray([], ((existingHooks === null || existingHooks === void 0 ? void 0 : existingHooks.afterDelete) || []), true), [
|
|
132
|
+
function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
return [2 /*return*/, (0, deleteFromStripe_1.deleteFromStripe)(__assign(__assign({}, args), { collection: collection, stripeConfig: stripeConfig }))];
|
|
135
|
+
});
|
|
136
|
+
}); },
|
|
137
|
+
], false) }), fields: __spreadArray(__spreadArray([], collection.fields, true), [
|
|
138
|
+
{
|
|
139
|
+
name: 'stripeID',
|
|
140
|
+
label: 'Stripe ID',
|
|
141
|
+
type: 'text',
|
|
142
|
+
saveToJWT: true,
|
|
143
|
+
admin: {
|
|
144
|
+
position: 'sidebar',
|
|
145
|
+
readOnly: true,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'skipSync',
|
|
150
|
+
label: 'Skip Sync',
|
|
151
|
+
type: 'checkbox',
|
|
152
|
+
admin: {
|
|
153
|
+
position: 'sidebar',
|
|
154
|
+
readOnly: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'docUrl',
|
|
159
|
+
type: 'ui',
|
|
160
|
+
admin: {
|
|
161
|
+
position: 'sidebar',
|
|
162
|
+
components: {
|
|
163
|
+
Field: function (args) {
|
|
164
|
+
return (0, LinkToDoc_1.LinkToDoc)(__assign(__assign({}, args), { isTestKey: stripeConfig.isTestKey, stripeResourceType: syncConfig.stripeResourceType, nameOfIDField: 'stripeID' }));
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
], false) });
|
|
170
|
+
}
|
|
171
|
+
return collection;
|
|
172
|
+
}) });
|
|
122
173
|
};
|
|
123
|
-
|
|
124
|
-
|
|
174
|
+
};
|
|
175
|
+
exports.default = stripePlugin;
|
|
176
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA6B;AAI7B,6DAA2D;AAC3D,+DAA6D;AAC7D,6DAA2D;AAC3D,yEAAuE;AACvE,sCAA0C;AAC1C,8CAAkD;AAElD,4CAA0C;AAE1C,IAAM,YAAY,GAChB,UAAC,oBAAkC;IACnC,OAAA,UAAC,MAAc;;QACL,IAAA,WAAW,GAAK,MAAM,YAAX,CAAW;QAE9B,2BAA2B;QAC3B,IAAM,YAAY,yBACb,oBAAoB;YACvB,2DAA2D;YAC3D,IAAI,E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B,KAAK,EAAE;oCACL,QAAQ,EAAE,SAAS;oCACnB,QAAQ,EAAE,IAAI;iCACf;6BACF;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,IAAI;gCACV,KAAK,EAAE;oCACL,QAAQ,EAAE,SAAS;oCACnB,UAAU,EAAE;wCACV,KAAK,EAAE,UAAA,IAAI;4CACT,OAAA,IAAA,qBAAS,wBACJ,IAAI,KACP,SAAS,EAAE,YAAY,CAAC,SAAS,EACjC,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,EACjD,aAAa,EAAE,UAAU,IACzB;wCALF,CAKE;qCACL;iCACF;6BACF;qCAEJ;iBACF;gBAED,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,IACH;IACH,CAAC;AA3ID,CA2IC,CAAA;AAEH,kBAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverModule.js","sourceRoot":"","sources":["../../src/mocks/serverModule.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,GAAG,EAAE,cAAO,CAAC;IACb,GAAG,EAAE,cAAO,CAAC;CACd,CAAA"}
|
package/dist/routes/rest.d.ts
CHANGED
|
@@ -2,9 +2,8 @@ import type { Response } from 'express';
|
|
|
2
2
|
import type { PayloadRequest } from 'payload/types';
|
|
3
3
|
import type { StripeConfig } from '../types';
|
|
4
4
|
export declare const stripeREST: (args: {
|
|
5
|
-
next: any;
|
|
6
5
|
req: PayloadRequest;
|
|
7
6
|
res: Response;
|
|
7
|
+
next: any;
|
|
8
8
|
stripeConfig: StripeConfig;
|
|
9
9
|
}) => Promise<any>;
|
|
10
|
-
//# sourceMappingURL=rest.d.ts.map
|
package/dist/routes/rest.js
CHANGED
|
@@ -1,38 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
value:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
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 };
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
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*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
exports.stripeREST = stripeREST;
|
|
79
|
+
//# sourceMappingURL=rest.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -3,10 +3,9 @@ import type { Config as PayloadConfig } from 'payload/config';
|
|
|
3
3
|
import type { PayloadRequest } from 'payload/dist/types';
|
|
4
4
|
import type { StripeConfig } from '../types';
|
|
5
5
|
export declare const stripeWebhooks: (args: {
|
|
6
|
-
config: PayloadConfig;
|
|
7
|
-
next: any;
|
|
8
6
|
req: PayloadRequest;
|
|
9
7
|
res: Response;
|
|
8
|
+
next: any;
|
|
9
|
+
config: PayloadConfig;
|
|
10
10
|
stripeConfig: StripeConfig;
|
|
11
11
|
}) => Promise<any>;
|
|
12
|
-
//# sourceMappingURL=webhooks.d.ts.map
|