strapi-plugin-payone-provider 5.7.22 → 5.7.24

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.
@@ -2,7 +2,10 @@ import * as React from "react";
2
2
  import JsonView from "@uiw/react-json-view";
3
3
  import { githubDarkTheme } from "@uiw/react-json-view/githubDark";
4
4
  import { Box, Flex, Typography } from "@strapi/design-system";
5
- import { getCardTypeName } from "../../../../utils/transactionTableUtils";
5
+ import {
6
+ getCardTypeName,
7
+ isCreditCard
8
+ } from "../../../../utils/transactionTableUtils";
6
9
 
7
10
  const TransactionDetails = ({ transaction }) => {
8
11
  return (
@@ -30,7 +33,7 @@ const TransactionDetails = ({ transaction }) => {
30
33
  display: "grid",
31
34
  gridTemplateColumns: "repeat(auto-fit,minmax(400px,1fr))",
32
35
  gap: "16px",
33
- marginBottom: "1.5rem",
36
+ marginBottom: "1.5rem"
34
37
  }}
35
38
  >
36
39
  <Flex direction="column" gap={2} alignItems={"stretch"}>
@@ -47,8 +50,10 @@ const TransactionDetails = ({ transaction }) => {
47
50
  Name:
48
51
  </Typography>
49
52
  <Typography variant="pi" textColor="neutral800">
50
- {transaction.raw_request?.firstname || transaction.body?.raw_request?.firstname }{" "}
51
- {transaction.raw_request?.lastname || transaction.body?.raw_request?.lastname}
53
+ {transaction.raw_request?.firstname ||
54
+ transaction.body?.raw_request?.firstname}{" "}
55
+ {transaction.raw_request?.lastname ||
56
+ transaction.body?.raw_request?.lastname}
52
57
  </Typography>
53
58
  </Flex>
54
59
  <Flex gap={3}>
@@ -56,7 +61,9 @@ const TransactionDetails = ({ transaction }) => {
56
61
  Email:
57
62
  </Typography>
58
63
  <Typography variant="pi" textColor="neutral800">
59
- {transaction.raw_request?.email || transaction.body?.raw_request?.email || "N/A"}
64
+ {transaction.raw_request?.email ||
65
+ transaction.body?.raw_request?.email ||
66
+ "N/A"}
60
67
  </Typography>
61
68
  </Flex>
62
69
  <Flex gap={3}>
@@ -64,7 +71,9 @@ const TransactionDetails = ({ transaction }) => {
64
71
  Phone:
65
72
  </Typography>
66
73
  <Typography variant="pi" textColor="neutral800">
67
- {transaction.raw_request?.telephonenumber || transaction.body?.raw_request?.telephonenumber || "N/A"}
74
+ {transaction.raw_request?.telephonenumber ||
75
+ transaction.body?.raw_request?.telephonenumber ||
76
+ "N/A"}
68
77
  </Typography>
69
78
  </Flex>
70
79
  <Flex gap={3}>
@@ -72,8 +81,13 @@ const TransactionDetails = ({ transaction }) => {
72
81
  Address:
73
82
  </Typography>
74
83
  <Typography variant="pi" textColor="neutral800">
75
- {transaction.raw_request?.street || transaction.body?.raw_request?.street}, {transaction.raw_request?.zip || transaction.body?.raw_request?.zip}{" "}
76
- {transaction.raw_request?.city || transaction.body?.raw_request?.city}
84
+ {transaction.raw_request?.street ||
85
+ transaction.body?.raw_request?.street}
86
+ ,{" "}
87
+ {transaction.raw_request?.zip ||
88
+ transaction.body?.raw_request?.zip}{" "}
89
+ {transaction.raw_request?.city ||
90
+ transaction.body?.raw_request?.city}
77
91
  </Typography>
78
92
  </Flex>
79
93
  </Flex>
@@ -94,7 +108,7 @@ const TransactionDetails = ({ transaction }) => {
94
108
  {transaction.txid || "N/A"}
95
109
  </Typography>
96
110
  </Flex>
97
- {transaction.raw_request?.clearingtype === "cc" || transaction.body?.raw_request?.clearingtype === "cc" && (
111
+ {isCreditCard(transaction) && (
98
112
  <>
99
113
  <Flex gap={3}>
100
114
  <Typography
@@ -105,22 +119,27 @@ const TransactionDetails = ({ transaction }) => {
105
119
  Card Type:
106
120
  </Typography>
107
121
  <Typography variant="pi" textColor="neutral800">
108
- {getCardTypeName(transaction.raw_request?.cardtype || transaction.body?.raw_request?.cardtype)}
109
- </Typography>
110
- </Flex>
111
- <Flex gap={3}>
112
- <Typography
113
- variant="pi"
114
- textColor="neutral600"
115
- fontWeight="medium"
116
- >
117
- Card Number:
118
- </Typography>
119
- <Typography variant="pi" textColor="neutral800">
120
- **** **** ****{" "}
121
- {transaction.raw_request?.cardpan?.slice(-4) || transaction.body?.raw_request?.cardpan?.slice(-4) || "****"}
122
+ {getCardTypeName(transaction)}
122
123
  </Typography>
123
124
  </Flex>
125
+ {(transaction.raw_request?.cardFirstname ||
126
+ transaction.body?.raw_request?.cardFirstname) && (
127
+ <Flex gap={3}>
128
+ <Typography
129
+ variant="pi"
130
+ textColor="neutral600"
131
+ fontWeight="medium"
132
+ >
133
+ Name on Card:
134
+ </Typography>
135
+ <Typography variant="pi" textColor="neutral800">
136
+ {transaction.raw_request?.cardFirstname ||
137
+ transaction.body?.raw_request?.cardFirstname}{" "}
138
+ {transaction.raw_request?.cardLastname ||
139
+ transaction.body?.raw_request?.cardLastname}
140
+ </Typography>
141
+ </Flex>
142
+ )}
124
143
  </>
125
144
  )}
126
145
  <Flex gap={3}>
@@ -128,7 +147,9 @@ const TransactionDetails = ({ transaction }) => {
128
147
  Mode:
129
148
  </Typography>
130
149
  <Typography variant="pi" textColor="neutral800">
131
- {transaction.raw_request?.mode || transaction.body?.raw_request?.mode || "N/A"}
150
+ {transaction.raw_request?.mode ||
151
+ transaction.body?.raw_request?.mode ||
152
+ "N/A"}
132
153
  </Typography>
133
154
  </Flex>
134
155
  </Flex>
@@ -9,6 +9,7 @@ import {
9
9
  Button,
10
10
  } from "@strapi/design-system";
11
11
  import { ChevronDownIcon, ChevronUpIcon } from "../icons";
12
+ import { isCreditCard, getCardTypeName } from "../../../../utils/transactionTableUtils";
12
13
 
13
14
  const TransactionHistoryItem = ({ transaction }) => {
14
15
  const [isExpanded, setIsExpanded] = React.useState(false);
@@ -302,7 +303,7 @@ const TransactionHistoryItem = ({ transaction }) => {
302
303
  </Typography>
303
304
  </Flex>
304
305
 
305
- {transaction.raw_request?.clearingtype === "cc" && (
306
+ {isCreditCard(transaction) && (
306
307
  <>
307
308
  <Flex justifyContent="space-between" gap={3}>
308
309
  <Typography
@@ -341,6 +342,21 @@ const TransactionHistoryItem = ({ transaction }) => {
341
342
  {transaction.raw_request?.cardexpiredate}
342
343
  </Typography>
343
344
  </Flex>
345
+ {transaction.raw_request?.cardFirstname && (
346
+ <Flex justifyContent="space-between" gap={3}>
347
+ <Typography
348
+ variant="pi"
349
+ textColor="neutral600"
350
+ fontWeight="medium"
351
+ >
352
+ Name on Card:
353
+ </Typography>
354
+ <Typography variant="pi" textColor="neutral800">
355
+ {transaction.raw_request?.cardFirstname}{" "}
356
+ {transaction.raw_request?.cardLastname}
357
+ </Typography>
358
+ </Flex>
359
+ )}
344
360
  </>
345
361
  )}
346
362
 
@@ -1,4 +1,3 @@
1
-
2
1
  export const getStatusColor = (status) => {
3
2
  switch (status) {
4
3
  case "APPROVED":
@@ -26,12 +25,11 @@ export const formatDate = (dateString) => {
26
25
  month: "2-digit",
27
26
  day: "2-digit",
28
27
  hour: "2-digit",
29
- minute: "2-digit",
28
+ minute: "2-digit"
30
29
  });
31
30
  };
32
31
 
33
32
  export const getPaymentMethodName = (clearingtype, wallettype) => {
34
-
35
33
  switch (clearingtype) {
36
34
  case "cc" || "card" | "c":
37
35
  return "Credit Card";
@@ -46,7 +44,20 @@ export const getPaymentMethodName = (clearingtype, wallettype) => {
46
44
  }
47
45
  };
48
46
 
49
- export const getCardTypeName = (cardtype) => {
47
+ export const isCreditCard = (transaction) => {
48
+ const clearingtype =
49
+ transaction.raw_request?.clearingtype ||
50
+ transaction.body?.raw_request?.clearingtype;
51
+ return clearingtype === "cc";
52
+ };
53
+
54
+ export const getCardTypeName = (transaction) => {
55
+ if (!isCreditCard(transaction)) return null;
56
+
57
+ const cardtype =
58
+ transaction.raw_request?.cardtype ||
59
+ transaction.body?.raw_request?.cardtype;
60
+
50
61
  switch (cardtype) {
51
62
  case "V":
52
63
  return "Visa";
@@ -58,4 +69,3 @@ export const getCardTypeName = (cardtype) => {
58
69
  return cardtype || "Unknown";
59
70
  }
60
71
  };
61
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-payone-provider",
3
- "version": "5.7.22",
3
+ "version": "5.7.24",
4
4
  "description": "Strapi plugin for Payone payment gateway integration",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -42,4 +42,4 @@
42
42
  "kind": "plugin",
43
43
  "displayName": "Strapi Payone Provider"
44
44
  }
45
- }
45
+ }
@@ -415,4 +415,37 @@ module.exports = ({ strapi }) => ({
415
415
  handleError(ctx, error);
416
416
  }
417
417
  },
418
+
419
+ async hash384(ctx) {
420
+ try {
421
+ // Get settings
422
+ const settings = await getPayoneService(strapi).getSettings();
423
+ const hmacKey = settings?.key || "";
424
+
425
+ if (!hmacKey) {
426
+ ctx.throw(400, "Payone key is not configured in plugin settings");
427
+ }
428
+
429
+ // Validate required settings
430
+ if (!settings?.aid || !settings?.mid || !settings?.portalid || !settings?.mode) {
431
+ ctx.throw(400, "Required settings (aid, mid, portalid, mode) are not configured");
432
+ }
433
+
434
+ // Construct the string from settings values
435
+ // Format: ${aid}UTF-8${mid}${mode}${portalid}creditcardcheckJSONyes
436
+ const textToHash = `${settings.aid}UTF-8${settings.mid}${settings.mode}${settings.portalid}creditcardcheckJSONyes`;
437
+
438
+ // Create HMAC SHA-384 hash
439
+ const hmac = crypto.createHmac("sha384", hmacKey);
440
+ hmac.update(textToHash);
441
+ const hash = hmac.digest("hex");
442
+
443
+ ctx.body = {
444
+ hash,
445
+ text: textToHash
446
+ };
447
+ } catch (error) {
448
+ handleError(ctx, error);
449
+ }
450
+ }
418
451
  });
@@ -100,7 +100,14 @@ module.exports = {
100
100
  policies: ["admin::isAuthenticatedAdmin"]
101
101
  }
102
102
  },
103
- // legacy hosted-iFrame endpoints removed
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",
@@ -48,6 +48,8 @@ const addPaymentMethodParams = (params, logger) => {
48
48
  'cardexpiredate', 'cardtype', 'wallettype',
49
49
  'bankcountry', 'iban', 'bic', 'bankaccountholder', 'onlinebanktransfertype',
50
50
  'recurrence', 'financingtype', 'invoicetype',
51
+ // Cardholder name fields (credit card)
52
+ 'cardFirstname', 'cardLastname',
51
53
  // Common defaults
52
54
  'salutation', 'gender', 'telephonenumber', 'ip', 'language', 'customer_is_present',
53
55
  // Payment method tokens