strapi-plugin-payone-provider 5.6.13 → 5.6.14
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/admin/src/index.js +14 -20
- package/admin/src/pages/App/components/AppHeader.jsx +16 -17
- package/admin/src/pages/App/components/AppTabs.jsx +14 -15
- package/admin/src/pages/App/components/ApplePayBtn.jsx +9 -14
- package/admin/src/pages/App/components/ApplePayConfig.jsx +25 -26
- package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +4 -4
- package/admin/src/pages/App/components/DocsPanel.jsx +8 -21
- package/admin/src/pages/App/components/GooglePayConfig.jsx +16 -14
- package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +4 -4
- package/admin/src/pages/App/components/GooglePaybutton.jsx +6 -5
- package/admin/src/pages/App/components/configuration/ConfigurationFields.jsx +39 -47
- package/admin/src/pages/App/components/configuration/ConfigurationPanel.jsx +5 -4
- package/admin/src/pages/App/components/configuration/TestConnection.jsx +19 -36
- package/admin/src/pages/App/components/payment-actions/ApplePayPanel.jsx +4 -4
- package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +12 -19
- package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +15 -23
- package/admin/src/pages/App/components/payment-actions/CardDetailsInput.jsx +20 -19
- package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +13 -24
- package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +8 -6
- package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +6 -10
- package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +12 -19
- package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +15 -22
- package/admin/src/pages/App/components/transaction-history/FiltersPanel.jsx +83 -84
- package/admin/src/pages/App/components/transaction-history/HistoryPanel.jsx +7 -17
- package/admin/src/pages/App/components/transaction-history/ImportExportBar.jsx +153 -0
- package/admin/src/pages/App/components/transaction-history/TransactionTable.jsx +22 -15
- package/admin/src/pages/hooks/usePluginTranslations.js +12 -0
- package/admin/src/pages/utils/api.js +27 -0
- package/admin/src/translations/de.json +235 -0
- package/admin/src/translations/en.json +235 -0
- package/admin/src/translations/fr.json +235 -0
- package/admin/src/translations/ru.json +235 -0
- package/admin/src/utils/prefixPluginTranslations.js +13 -0
- package/package.json +2 -2
- package/server/controllers/payone.js +70 -0
- package/server/routes/index.js +16 -0
- package/server/services/payone.js +8 -0
- package/server/services/transactionService.js +80 -1
- package/server/utils/csvTransactions.js +82 -0
|
@@ -176,8 +176,87 @@ const getTransactionHistory = async (
|
|
|
176
176
|
};
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
const EXPORT_MAX = 10000;
|
|
180
|
+
|
|
181
|
+
const getTransactionsForExport = async (
|
|
182
|
+
strapi,
|
|
183
|
+
{ filters = {}, sort_by, sort_order }
|
|
184
|
+
) => {
|
|
185
|
+
const where = buildWhereFromFilters(filters);
|
|
186
|
+
const sortField =
|
|
187
|
+
sort_by && ALLOWED_SORT_FIELDS.includes(sort_by) ? sort_by : "createdAt";
|
|
188
|
+
const order = sort_order === "asc" ? "asc" : "desc";
|
|
189
|
+
|
|
190
|
+
const queryOptions = {
|
|
191
|
+
orderBy: { [sortField]: order },
|
|
192
|
+
limit: EXPORT_MAX,
|
|
193
|
+
};
|
|
194
|
+
if (where !== undefined) queryOptions.where = where;
|
|
195
|
+
|
|
196
|
+
const data = await strapi.db.query(TRANSACTION_UID).findMany(queryOptions);
|
|
197
|
+
return data;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const TRANSACTION_ATTRS = [
|
|
201
|
+
"txid", "reference", "invoiceid", "amount", "currency", "status",
|
|
202
|
+
"error_code", "request_type", "error_message", "customer_message",
|
|
203
|
+
"body", "raw_request", "raw_response", "createdAt", "updatedAt"
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
const parseJsonField = (val) => {
|
|
207
|
+
if (val == null || val === "") return {};
|
|
208
|
+
if (typeof val === "object") return val;
|
|
209
|
+
try {
|
|
210
|
+
const parsed = JSON.parse(String(val));
|
|
211
|
+
return typeof parsed === "object" ? parsed : {};
|
|
212
|
+
} catch {
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const normalizeImportRow = (row) => {
|
|
218
|
+
const data = {
|
|
219
|
+
txid: (row.txid ?? row.TxId ?? "NO TXID").toString().trim(),
|
|
220
|
+
reference: (row.reference ?? row.Reference ?? "NO REFERENCE").toString().trim(),
|
|
221
|
+
invoiceid: (row.invoiceid ?? row.invoiceId ?? "NO INVOICE ID").toString().trim(),
|
|
222
|
+
amount: (row.amount ?? "0").toString().trim(),
|
|
223
|
+
currency: (row.currency ?? "EUR").toString().trim(),
|
|
224
|
+
status: (row.status ?? "unknown").toString().trim(),
|
|
225
|
+
error_code: (row.error_code ?? row.errorCode ?? "NO ERROR CODE").toString().trim(),
|
|
226
|
+
request_type: (row.request_type ?? row.requestType ?? "unknown").toString().trim(),
|
|
227
|
+
error_message: (row.error_message ?? row.errorMessage ?? "NO ERROR MESSAGE").toString().trim(),
|
|
228
|
+
customer_message: (row.customer_message ?? row.customerMessage ?? "NO CUSTOMER MESSAGE").toString().trim(),
|
|
229
|
+
body: parseJsonField(row.body),
|
|
230
|
+
raw_request: parseJsonField(row.raw_request),
|
|
231
|
+
raw_response: parseJsonField(row.raw_response),
|
|
232
|
+
};
|
|
233
|
+
data.raw_request = sanitizeSensitive(data.raw_request || {});
|
|
234
|
+
data.raw_response = sanitizeSensitive(data.raw_response || {});
|
|
235
|
+
return data;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const importTransactions = async (strapi, rows) => {
|
|
239
|
+
const results = { imported: 0, failed: 0, errors: [] };
|
|
240
|
+
if (!Array.isArray(rows) || rows.length === 0) return results;
|
|
241
|
+
for (let i = 0; i < rows.length; i++) {
|
|
242
|
+
try {
|
|
243
|
+
const row = rows[i];
|
|
244
|
+
const data = normalizeImportRow(row);
|
|
245
|
+
await strapi.db.query(TRANSACTION_UID).create({ data });
|
|
246
|
+
results.imported += 1;
|
|
247
|
+
} catch (err) {
|
|
248
|
+
results.failed += 1;
|
|
249
|
+
results.errors.push({ row: i + 1, message: err.message || String(err) });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return results;
|
|
253
|
+
};
|
|
254
|
+
|
|
179
255
|
module.exports = {
|
|
180
256
|
logTransaction,
|
|
181
|
-
getTransactionHistory
|
|
257
|
+
getTransactionHistory,
|
|
258
|
+
getTransactionsForExport,
|
|
259
|
+
importTransactions,
|
|
260
|
+
TRANSACTION_ATTRS,
|
|
182
261
|
};
|
|
183
262
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const TRANSACTION_ATTRS = [
|
|
4
|
+
"txid", "reference", "invoiceid", "amount", "currency", "status",
|
|
5
|
+
"error_code", "request_type", "error_message", "customer_message",
|
|
6
|
+
"body", "raw_request", "raw_response", "createdAt", "updatedAt"
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
function escapeCsvCell(val) {
|
|
10
|
+
if (val == null) return "";
|
|
11
|
+
const str = typeof val === "object" ? JSON.stringify(val) : String(val);
|
|
12
|
+
if (/[",\n\r]/.test(str)) return `"${str.replace(/"/g, '""')}"`;
|
|
13
|
+
return str;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function parseCsvLine(line) {
|
|
17
|
+
const out = [];
|
|
18
|
+
let cur = "";
|
|
19
|
+
let inQuotes = false;
|
|
20
|
+
for (let i = 0; i < line.length; i++) {
|
|
21
|
+
const c = line[i];
|
|
22
|
+
if (c === '"') {
|
|
23
|
+
if (inQuotes && line[i + 1] === '"') {
|
|
24
|
+
cur += '"';
|
|
25
|
+
i++;
|
|
26
|
+
} else {
|
|
27
|
+
inQuotes = !inQuotes;
|
|
28
|
+
}
|
|
29
|
+
} else if (inQuotes) {
|
|
30
|
+
cur += c;
|
|
31
|
+
} else if (c === ",") {
|
|
32
|
+
out.push(cur);
|
|
33
|
+
cur = "";
|
|
34
|
+
} else {
|
|
35
|
+
cur += c;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
out.push(cur);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function csvToRows(csvText) {
|
|
43
|
+
const lines = csvText.split(/\r?\n/).filter((l) => l.trim() !== "");
|
|
44
|
+
if (lines.length === 0) return [];
|
|
45
|
+
const headers = parseCsvLine(lines[0]).map((h) => h.trim());
|
|
46
|
+
const rows = [];
|
|
47
|
+
for (let i = 1; i < lines.length; i++) {
|
|
48
|
+
const cells = parseCsvLine(lines[i]);
|
|
49
|
+
const row = {};
|
|
50
|
+
headers.forEach((h, j) => {
|
|
51
|
+
let v = cells[j];
|
|
52
|
+
if (v !== undefined) v = v.trim();
|
|
53
|
+
if (v === "" && (h === "body" || h === "raw_request" || h === "raw_response")) {
|
|
54
|
+
row[h] = {};
|
|
55
|
+
} else if (h === "body" || h === "raw_request" || h === "raw_response") {
|
|
56
|
+
try {
|
|
57
|
+
row[h] = typeof v === "string" && v ? JSON.parse(v) : {};
|
|
58
|
+
} catch {
|
|
59
|
+
row[h] = {};
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
row[h] = v ?? "";
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
rows.push(row);
|
|
66
|
+
}
|
|
67
|
+
return rows;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function rowsToCsv(rows, attrs = TRANSACTION_ATTRS) {
|
|
71
|
+
const headerLine = attrs.map(escapeCsvCell).join(",");
|
|
72
|
+
const dataLines = rows.map((r) =>
|
|
73
|
+
attrs.map((key) => escapeCsvCell(r[key])).join(",")
|
|
74
|
+
);
|
|
75
|
+
return [headerLine, ...dataLines].join("\n");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
TRANSACTION_ATTRS,
|
|
80
|
+
csvToRows,
|
|
81
|
+
rowsToCsv,
|
|
82
|
+
};
|