strapi-plugin-payone-provider 5.7.23 → 5.7.25
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/package.json +1 -1
- package/server/controllers/payone.js +34 -0
- package/server/routes/index.js +17 -1
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const crypto = require("crypto");
|
|
3
4
|
const PLUGIN_NAME = "strapi-plugin-payone-provider";
|
|
4
5
|
const { rowsToCsv, csvToRows, TRANSACTION_ATTRS } = require("../utils/csvTransactions");
|
|
5
6
|
|
|
@@ -415,4 +416,37 @@ module.exports = ({ strapi }) => ({
|
|
|
415
416
|
handleError(ctx, error);
|
|
416
417
|
}
|
|
417
418
|
},
|
|
419
|
+
|
|
420
|
+
async hash384(ctx) {
|
|
421
|
+
try {
|
|
422
|
+
// Get settings
|
|
423
|
+
const settings = await getPayoneService(strapi).getSettings();
|
|
424
|
+
const hmacKey = settings?.key || "";
|
|
425
|
+
|
|
426
|
+
if (!hmacKey) {
|
|
427
|
+
ctx.throw(400, "Payone key is not configured in plugin settings");
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Validate required settings
|
|
431
|
+
if (!settings?.aid || !settings?.mid || !settings?.portalid || !settings?.mode) {
|
|
432
|
+
ctx.throw(400, "Required settings (aid, mid, portalid, mode) are not configured");
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Construct the string from settings values
|
|
436
|
+
// Format: ${aid}UTF-8${mid}${mode}${portalid}creditcardcheckJSONyes
|
|
437
|
+
const textToHash = `${settings.aid}UTF-8${settings.mid}${settings.mode}${settings.portalid}creditcardcheckJSONyes`;
|
|
438
|
+
|
|
439
|
+
// Create HMAC SHA-384 hash
|
|
440
|
+
const hmac = crypto.createHmac("sha384", hmacKey);
|
|
441
|
+
hmac.update(textToHash);
|
|
442
|
+
const hash = hmac.digest("hex");
|
|
443
|
+
|
|
444
|
+
ctx.body = {
|
|
445
|
+
hash,
|
|
446
|
+
text: textToHash
|
|
447
|
+
};
|
|
448
|
+
} catch (error) {
|
|
449
|
+
handleError(ctx, error);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
418
452
|
});
|
package/server/routes/index.js
CHANGED
|
@@ -100,7 +100,14 @@ module.exports = {
|
|
|
100
100
|
policies: ["admin::isAuthenticatedAdmin"]
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
|
|
103
|
+
{
|
|
104
|
+
method: "POST",
|
|
105
|
+
path: "/hash384",
|
|
106
|
+
handler: "payone.hash384",
|
|
107
|
+
config: {
|
|
108
|
+
policies: ["admin::isAuthenticatedAdmin"]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
104
111
|
]
|
|
105
112
|
},
|
|
106
113
|
|
|
@@ -188,6 +195,15 @@ module.exports = {
|
|
|
188
195
|
auth: false
|
|
189
196
|
}
|
|
190
197
|
},
|
|
198
|
+
{
|
|
199
|
+
method: "POST",
|
|
200
|
+
path: "/hash384",
|
|
201
|
+
handler: "payone.hash384",
|
|
202
|
+
config: {
|
|
203
|
+
policies: ["plugin::strapi-plugin-payone-provider.is-auth"],
|
|
204
|
+
auth: false
|
|
205
|
+
}
|
|
206
|
+
},
|
|
191
207
|
{
|
|
192
208
|
method: "POST",
|
|
193
209
|
path: "/transaction-status",
|