strapi-plugin-payone-provider 5.6.19 → 5.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-payone-provider",
3
- "version": "5.6.19",
3
+ "version": "5.7.19",
4
4
  "description": "Strapi plugin for Payone payment gateway integration",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -20,7 +20,7 @@ module.exports = {
20
20
  enableGooglePay: false,
21
21
  enableApplePay: false,
22
22
  enableSofort: false,
23
- enableSepaDirectDebit: false
23
+ enableSepaDirectDebit: false,
24
24
  }
25
25
  },
26
26
  validator(config) {
@@ -49,7 +49,7 @@ module.exports = {
49
49
  enableGooglePay: yup.boolean().optional(),
50
50
  enableApplePay: yup.boolean().optional(),
51
51
  enableSofort: yup.boolean().optional(),
52
- enableSepaDirectDebit: yup.boolean().optional()
52
+ enableSepaDirectDebit: yup.boolean().optional(),
53
53
  })
54
54
  .defined()
55
55
  });
@@ -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
 
@@ -391,5 +392,38 @@ module.exports = ({ strapi }) => ({
391
392
  ctx.status = 200;
392
393
  ctx.body = "TSOK";
393
394
  ctx.type = "text/plain";
395
+ },
396
+
397
+ async hash384(ctx) {
398
+ try {
399
+ // Get settings
400
+ const settings = await getPayoneService(strapi).getSettings();
401
+ const hmacKey = settings?.key || "";
402
+
403
+ if (!hmacKey) {
404
+ ctx.throw(400, "Payone key is not configured in plugin settings");
405
+ }
406
+
407
+ // Validate required settings
408
+ if (!settings?.aid || !settings?.mid || !settings?.portalid || !settings?.mode) {
409
+ ctx.throw(400, "Required settings (aid, mid, portalid, mode) are not configured");
410
+ }
411
+
412
+ // Construct the string from settings values
413
+ // Format: ${aid}UTF-8${mid}${mode}${portalid}creditcardcheckJSONyes
414
+ const textToHash = `${settings.aid}UTF-8${settings.mid}${settings.mode}${settings.portalid}creditcardcheckJSONyes`;
415
+
416
+ // Create HMAC SHA-384 hash
417
+ const hmac = crypto.createHmac("sha384", hmacKey);
418
+ hmac.update(textToHash);
419
+ const hash = hmac.digest("hex");
420
+
421
+ ctx.body = {
422
+ hash,
423
+ text: textToHash
424
+ };
425
+ } catch (error) {
426
+ handleError(ctx, error);
427
+ }
394
428
  }
395
429
  });
@@ -99,6 +99,14 @@ module.exports = {
99
99
  config: {
100
100
  policies: ["admin::isAuthenticatedAdmin"]
101
101
  }
102
+ },
103
+ {
104
+ method: "POST",
105
+ path: "/hash384",
106
+ handler: "payone.hash384",
107
+ config: {
108
+ policies: ["admin::isAuthenticatedAdmin"]
109
+ }
102
110
  }
103
111
  ]
104
112
  },
@@ -178,7 +186,15 @@ module.exports = {
178
186
  auth: false
179
187
  }
180
188
  },
181
-
189
+ {
190
+ method: "POST",
191
+ path: "/hash384",
192
+ handler: "payone.hash384",
193
+ config: {
194
+ policies: ["plugin::strapi-plugin-payone-provider.is-auth"],
195
+ auth: false
196
+ }
197
+ },
182
198
  {
183
199
  method: "POST",
184
200
  path: "/transaction-status",
@@ -187,8 +203,7 @@ module.exports = {
187
203
  // policies: ["plugin::strapi-plugin-payone-provider.is-payone-notification"],
188
204
  auth: false
189
205
  }
190
- },
191
-
206
+ }
192
207
  ]
193
208
  }
194
209
  };