strapi-plugin-payone-provider 5.7.26 → 5.8.26
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 +1191 -1191
- package/admin/src/components/Initializer/index.jsx +16 -16
- package/admin/src/components/PluginIcon/index.jsx +17 -17
- package/admin/src/index.js +57 -57
- package/admin/src/pages/App/components/AppHeader.jsx +45 -45
- package/admin/src/pages/App/components/AppTabs.jsx +105 -105
- package/admin/src/pages/App/components/ApplePayBtn.jsx +355 -355
- package/admin/src/pages/App/components/ApplePayConfig.jsx +357 -357
- package/admin/src/pages/App/components/DocsPanel.jsx +53 -53
- package/admin/src/pages/App/components/RenderInput.jsx +78 -78
- package/admin/src/pages/App/components/StatusBadge.jsx +87 -87
- package/admin/src/pages/App/components/icons/BankIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ErrorIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/InfoIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -19
- package/admin/src/pages/App/components/icons/PaymentIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/PendingIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/PersonIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/SuccessIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/WalletIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/index.jsx +12 -12
- package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +334 -334
- package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +120 -120
- package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +183 -183
- package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +315 -315
- package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +129 -129
- package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +273 -273
- package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +114 -114
- package/admin/src/pages/App/components/transaction-history/ImportExportBar.jsx +153 -153
- package/admin/src/pages/App/components/transaction-history/details/TransactionHistoryItem.jsx +526 -526
- package/admin/src/pages/App/index.jsx +96 -96
- package/admin/src/pages/App/styles.css +176 -176
- package/admin/src/pages/constants/paymentConstants.js +71 -71
- package/admin/src/pages/hooks/use-system-theme.js +27 -27
- package/admin/src/pages/hooks/usePaymentActions.js +498 -498
- package/admin/src/pages/hooks/usePluginTranslations.js +12 -12
- package/admin/src/pages/hooks/useSettings.js +183 -183
- package/admin/src/pages/hooks/useTransactionHistory.js +148 -148
- package/admin/src/pages/utils/api.js +97 -97
- package/admin/src/pages/utils/applePayConstants.js +196 -196
- package/admin/src/pages/utils/formatTransactionData.js +15 -15
- package/admin/src/pages/utils/getInputComponent.jsx +200 -200
- package/admin/src/pages/utils/paymentUtils.js +661 -661
- package/admin/src/pages/utils/tooltipHelpers.js +18 -18
- package/admin/src/pages/utils/transactionTableUtils.js +71 -71
- package/admin/src/pluginId.js +9 -9
- package/admin/src/translations/de.json +235 -235
- package/admin/src/translations/en.json +235 -235
- package/admin/src/translations/fr.json +235 -235
- package/admin/src/translations/ru.json +235 -235
- package/admin/src/utils/prefixPluginTranslations.js +13 -13
- package/package.json +45 -45
- package/server/bootstrap.js +107 -107
- package/server/config/index.js +83 -83
- package/server/content-types/index.js +4 -4
- package/server/content-types/transactions/index.js +4 -4
- package/server/content-types/transactions/schema.json +86 -86
- package/server/controllers/index.js +7 -7
- package/server/controllers/payone.js +503 -506
- package/server/destroy.js +5 -5
- package/server/index.js +23 -23
- package/server/policies/index.js +7 -7
- package/server/policies/is-auth.js +29 -29
- package/server/policies/isSuperAdmin.js +20 -20
- package/server/register.js +5 -5
- package/server/routes/index.js +218 -218
- package/server/services/applePayService.js +295 -295
- package/server/services/index.js +9 -9
- package/server/services/paymentService.js +264 -223
- package/server/services/payone.js +78 -78
- package/server/services/settingsService.js +59 -59
- package/server/services/testConnectionService.js +115 -115
- package/server/services/transactionService.js +262 -262
- package/server/utils/csvTransactions.js +82 -82
- package/server/utils/normalize.js +39 -39
- package/server/utils/paymentMethodParams.js +288 -288
- package/server/utils/requestBuilder.js +115 -100
- package/server/utils/responseParser.js +141 -141
- package/strapi-admin.js +4 -4
- package/strapi-server.js +3 -3
|
@@ -1,288 +1,288 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function getValidCardExpiryDate(cardexpiredate) {
|
|
5
|
-
const now = new Date();
|
|
6
|
-
const currentYear = now.getFullYear() % 100;
|
|
7
|
-
const currentMonth = now.getMonth() + 1;
|
|
8
|
-
|
|
9
|
-
if (!cardexpiredate || cardexpiredate.trim() === "") {
|
|
10
|
-
const nextYear = currentYear + 1;
|
|
11
|
-
const monthStr = String(currentMonth).padStart(2, '0');
|
|
12
|
-
return `${nextYear}${monthStr}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!/^\d{4}$/.test(cardexpiredate)) {
|
|
16
|
-
const nextYear = currentYear + 1;
|
|
17
|
-
const monthStr = String(currentMonth).padStart(2, '0');
|
|
18
|
-
return `${nextYear}${monthStr}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const year = parseInt(cardexpiredate.substring(0, 2), 10);
|
|
22
|
-
const month = parseInt(cardexpiredate.substring(2, 4), 10);
|
|
23
|
-
|
|
24
|
-
if (month < 1 || month > 12) {
|
|
25
|
-
const nextYear = currentYear + 1;
|
|
26
|
-
const monthStr = String(currentMonth).padStart(2, '0');
|
|
27
|
-
return `${nextYear}${monthStr}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const currentDate = new Date(2000 + currentYear, currentMonth - 1);
|
|
31
|
-
const expiryDate = new Date(2000 + year, month - 1);
|
|
32
|
-
|
|
33
|
-
if (expiryDate < currentDate) {
|
|
34
|
-
const nextYear = currentYear + 1;
|
|
35
|
-
const monthStr = String(currentMonth).padStart(2, '0');
|
|
36
|
-
return `${nextYear}${monthStr}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return cardexpiredate;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const addPaymentMethodParams = (params, logger) => {
|
|
43
|
-
const updated = { ...params };
|
|
44
|
-
const clearingtype = updated.clearingtype || "cc";
|
|
45
|
-
|
|
46
|
-
const customParams = {};
|
|
47
|
-
const knownParams = new Set([
|
|
48
|
-
'cardexpiredate', 'cardtype', 'wallettype',
|
|
49
|
-
'bankcountry', 'iban', 'bic', 'bankaccountholder', 'onlinebanktransfertype',
|
|
50
|
-
'recurrence', 'financingtype', 'invoicetype',
|
|
51
|
-
// Cardholder name fields (credit card)
|
|
52
|
-
'cardFirstname', 'cardLastname',
|
|
53
|
-
// Common defaults
|
|
54
|
-
'salutation', 'gender', 'telephonenumber', 'ip', 'language', 'customer_is_present',
|
|
55
|
-
// Payment method tokens
|
|
56
|
-
'applePayToken', 'googlePayToken',
|
|
57
|
-
// Other known params
|
|
58
|
-
'clearingtype', 'paymentMethod', 'settings', 'enable3DSecure', 'ecommercemode'
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
Object.keys(updated).forEach(key => {
|
|
62
|
-
if (!knownParams.has(key) && !key.startsWith('add_paydata[')) {
|
|
63
|
-
customParams[key] = updated[key];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const methodDefaults = {
|
|
68
|
-
cc: {
|
|
69
|
-
cardexpiredate: getValidCardExpiryDate(null),
|
|
70
|
-
cardtype: "V"
|
|
71
|
-
},
|
|
72
|
-
wlt: {
|
|
73
|
-
wallettype: "PPE"
|
|
74
|
-
},
|
|
75
|
-
gpp: {
|
|
76
|
-
clearingtype: "wlt",
|
|
77
|
-
wallettype: "GGP"
|
|
78
|
-
},
|
|
79
|
-
apl: {
|
|
80
|
-
clearingtype: "wlt",
|
|
81
|
-
wallettype: "APL"
|
|
82
|
-
},
|
|
83
|
-
elv: {
|
|
84
|
-
bankcountry: "DE",
|
|
85
|
-
iban: "DE89370400440532013000",
|
|
86
|
-
bic: "COBADEFFXXX",
|
|
87
|
-
bankaccountholder: `${updated.firstname || "Test"} ${updated.lastname || "User"}`
|
|
88
|
-
},
|
|
89
|
-
sb: {
|
|
90
|
-
bankcountry: "DE",
|
|
91
|
-
onlinebanktransfertype: "PNT"
|
|
92
|
-
},
|
|
93
|
-
gp: {
|
|
94
|
-
bankcountry: "DE",
|
|
95
|
-
onlinebanktransfertype: "GPY"
|
|
96
|
-
},
|
|
97
|
-
idl: {
|
|
98
|
-
bankcountry: "NL",
|
|
99
|
-
onlinebanktransfertype: "IDL"
|
|
100
|
-
},
|
|
101
|
-
bct: {
|
|
102
|
-
bankcountry: "BE",
|
|
103
|
-
onlinebanktransfertype: "BCT"
|
|
104
|
-
},
|
|
105
|
-
rec: {
|
|
106
|
-
recurrence: "recurring"
|
|
107
|
-
},
|
|
108
|
-
fnc: {
|
|
109
|
-
financingtype: "fnc"
|
|
110
|
-
},
|
|
111
|
-
iv: {
|
|
112
|
-
invoicetype: "invoice"
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
if (clearingtype === "gpp" || clearingtype === "apl") {
|
|
117
|
-
if (clearingtype === "gpp") {
|
|
118
|
-
updated.wallettype = "GGP";
|
|
119
|
-
} else if (clearingtype === "apl") {
|
|
120
|
-
updated.wallettype = "APL";
|
|
121
|
-
}
|
|
122
|
-
updated.clearingtype = "wlt";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const defaults = methodDefaults[clearingtype] || methodDefaults.cc;
|
|
126
|
-
|
|
127
|
-
Object.entries(defaults).forEach(([key, value]) => {
|
|
128
|
-
if (key === "wallettype" && updated.wallettype) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (key === "cardexpiredate") {
|
|
132
|
-
if (!updated[key] || updated[key].trim() === "") {
|
|
133
|
-
updated[key] = getValidCardExpiryDate(null);
|
|
134
|
-
} else {
|
|
135
|
-
updated[key] = getValidCardExpiryDate(updated[key]);
|
|
136
|
-
}
|
|
137
|
-
} else if (!updated[key]) {
|
|
138
|
-
updated[key] = value;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (updated.applePayToken) {
|
|
143
|
-
let tokenData;
|
|
144
|
-
try {
|
|
145
|
-
const tokenString = Buffer.from(updated.applePayToken, 'base64').toString('utf-8');
|
|
146
|
-
tokenData = JSON.parse(tokenString);
|
|
147
|
-
|
|
148
|
-
if (logger) {
|
|
149
|
-
logger.info("[Apple Pay] Token decoded from Base64 successfully");
|
|
150
|
-
}
|
|
151
|
-
} catch (e) {
|
|
152
|
-
try {
|
|
153
|
-
tokenData = typeof updated.applePayToken === 'string'
|
|
154
|
-
? JSON.parse(updated.applePayToken)
|
|
155
|
-
: updated.applePayToken;
|
|
156
|
-
|
|
157
|
-
if (logger) {
|
|
158
|
-
logger.info("[Apple Pay] Token parsed as JSON string directly");
|
|
159
|
-
}
|
|
160
|
-
} catch (e2) {
|
|
161
|
-
tokenData = updated.applePayToken;
|
|
162
|
-
|
|
163
|
-
if (logger) {
|
|
164
|
-
logger.info("[Apple Pay] Token used as-is (already an object)");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (tokenData && typeof tokenData === 'object') {
|
|
170
|
-
const paymentData = tokenData.paymentData;
|
|
171
|
-
|
|
172
|
-
if (!paymentData) {
|
|
173
|
-
if (logger) {
|
|
174
|
-
logger.error("[Apple Pay] Invalid token structure: missing paymentData field", {
|
|
175
|
-
tokenKeys: Object.keys(tokenData),
|
|
176
|
-
tokenStructure: JSON.stringify(tokenData).substring(0, 500)
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
delete updated.applePayToken;
|
|
180
|
-
return updated;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const header = paymentData.header || {};
|
|
184
|
-
|
|
185
|
-
// Payone required fields according to docs
|
|
186
|
-
// Extract version, data, signature from paymentData
|
|
187
|
-
const tokenVersion = paymentData.version || "EC_v1";
|
|
188
|
-
const tokenDataValue = paymentData.data || "";
|
|
189
|
-
const tokenSignature = paymentData.signature || "";
|
|
190
|
-
|
|
191
|
-
// Extract from header
|
|
192
|
-
const ephemeralPublicKey = header.ephemeralPublicKey || "";
|
|
193
|
-
const publicKeyHash = header.publicKeyHash || "";
|
|
194
|
-
const transactionId = paymentData.transactionId || header.transactionId || "";
|
|
195
|
-
|
|
196
|
-
// Set Payone required fields
|
|
197
|
-
updated["add_paydata[paymentdata_token_version]"] = tokenVersion;
|
|
198
|
-
updated["add_paydata[paymentdata_token_data]"] = tokenDataValue;
|
|
199
|
-
updated["add_paydata[paymentdata_token_signature]"] = tokenSignature;
|
|
200
|
-
updated["add_paydata[paymentdata_token_ephemeral_publickey]"] = ephemeralPublicKey;
|
|
201
|
-
updated["add_paydata[paymentdata_token_publickey_hash]"] = publicKeyHash;
|
|
202
|
-
|
|
203
|
-
// Transaction ID is optional according to Payone docs
|
|
204
|
-
if (transactionId) {
|
|
205
|
-
updated["add_paydata[paymentdata_token_transaction_id]"] = transactionId;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (logger) {
|
|
209
|
-
logger.info("[Apple Pay] Token extracted successfully:", {
|
|
210
|
-
hasVersion: !!tokenVersion,
|
|
211
|
-
hasData: !!tokenDataValue,
|
|
212
|
-
hasSignature: !!tokenSignature,
|
|
213
|
-
hasEphemeralPublicKey: !!ephemeralPublicKey,
|
|
214
|
-
hasPublicKeyHash: !!publicKeyHash,
|
|
215
|
-
hasTransactionId: !!transactionId,
|
|
216
|
-
dataLength: tokenDataValue.length,
|
|
217
|
-
signatureLength: tokenSignature.length,
|
|
218
|
-
ephemeralPublicKeyLength: ephemeralPublicKey.length,
|
|
219
|
-
publicKeyHashLength: publicKeyHash.length
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Validate required fields
|
|
224
|
-
if (!tokenDataValue ||
|
|
225
|
-
!tokenSignature ||
|
|
226
|
-
!ephemeralPublicKey ||
|
|
227
|
-
!publicKeyHash) {
|
|
228
|
-
if (logger) {
|
|
229
|
-
logger.error("[Apple Pay] Missing required token fields:", {
|
|
230
|
-
hasData: !!tokenDataValue,
|
|
231
|
-
hasSignature: !!tokenSignature,
|
|
232
|
-
hasEphemeralPublicKey: !!ephemeralPublicKey,
|
|
233
|
-
hasPublicKeyHash: !!publicKeyHash,
|
|
234
|
-
paymentDataKeys: Object.keys(paymentData),
|
|
235
|
-
headerKeys: Object.keys(header)
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
} else {
|
|
240
|
-
if (logger) {
|
|
241
|
-
logger.error("[Apple Pay] Token is not a valid object:", {
|
|
242
|
-
tokenType: typeof tokenData,
|
|
243
|
-
tokenValue: typeof tokenData === 'string' ? tokenData.substring(0, 200) : String(tokenData).substring(0, 200)
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
delete updated.applePayToken;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (updated.clearingtype === "wlt" && !updated.wallettype) {
|
|
252
|
-
if (clearingtype === "gpp" || updated.paymentMethod === "gpp" || (updated["add_paydata[paymentmethod]"] === "GGP")) {
|
|
253
|
-
updated.wallettype = "GGP";
|
|
254
|
-
} else if (clearingtype === "apl" || updated.paymentMethod === "apl" || (updated["add_paydata[paymentmethod]"] === "APL")) {
|
|
255
|
-
updated.wallettype = "APL";
|
|
256
|
-
} else {
|
|
257
|
-
updated.wallettype = "PPE";
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (updated.clearingtype === "wlt" && updated.cardtype) {
|
|
261
|
-
delete updated.cardtype;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const commonDefaults = {
|
|
266
|
-
salutation: "Herr",
|
|
267
|
-
gender: "m",
|
|
268
|
-
telephonenumber: "01752345678",
|
|
269
|
-
ip: "127.0.0.1",
|
|
270
|
-
language: "de",
|
|
271
|
-
customer_is_present: "yes"
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
Object.entries(commonDefaults).forEach(([key, value]) => {
|
|
275
|
-
if (!updated[key]) {
|
|
276
|
-
updated[key] = value;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
Object.assign(updated, customParams);
|
|
281
|
-
|
|
282
|
-
return updated;
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
module.exports = {
|
|
286
|
-
addPaymentMethodParams
|
|
287
|
-
};
|
|
288
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function getValidCardExpiryDate(cardexpiredate) {
|
|
5
|
+
const now = new Date();
|
|
6
|
+
const currentYear = now.getFullYear() % 100;
|
|
7
|
+
const currentMonth = now.getMonth() + 1;
|
|
8
|
+
|
|
9
|
+
if (!cardexpiredate || cardexpiredate.trim() === "") {
|
|
10
|
+
const nextYear = currentYear + 1;
|
|
11
|
+
const monthStr = String(currentMonth).padStart(2, '0');
|
|
12
|
+
return `${nextYear}${monthStr}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!/^\d{4}$/.test(cardexpiredate)) {
|
|
16
|
+
const nextYear = currentYear + 1;
|
|
17
|
+
const monthStr = String(currentMonth).padStart(2, '0');
|
|
18
|
+
return `${nextYear}${monthStr}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const year = parseInt(cardexpiredate.substring(0, 2), 10);
|
|
22
|
+
const month = parseInt(cardexpiredate.substring(2, 4), 10);
|
|
23
|
+
|
|
24
|
+
if (month < 1 || month > 12) {
|
|
25
|
+
const nextYear = currentYear + 1;
|
|
26
|
+
const monthStr = String(currentMonth).padStart(2, '0');
|
|
27
|
+
return `${nextYear}${monthStr}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const currentDate = new Date(2000 + currentYear, currentMonth - 1);
|
|
31
|
+
const expiryDate = new Date(2000 + year, month - 1);
|
|
32
|
+
|
|
33
|
+
if (expiryDate < currentDate) {
|
|
34
|
+
const nextYear = currentYear + 1;
|
|
35
|
+
const monthStr = String(currentMonth).padStart(2, '0');
|
|
36
|
+
return `${nextYear}${monthStr}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return cardexpiredate;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const addPaymentMethodParams = (params, logger) => {
|
|
43
|
+
const updated = { ...params };
|
|
44
|
+
const clearingtype = updated.clearingtype || "cc";
|
|
45
|
+
|
|
46
|
+
const customParams = {};
|
|
47
|
+
const knownParams = new Set([
|
|
48
|
+
'cardexpiredate', 'cardtype', 'wallettype',
|
|
49
|
+
'bankcountry', 'iban', 'bic', 'bankaccountholder', 'onlinebanktransfertype',
|
|
50
|
+
'recurrence', 'financingtype', 'invoicetype',
|
|
51
|
+
// Cardholder name fields (credit card)
|
|
52
|
+
'cardFirstname', 'cardLastname',
|
|
53
|
+
// Common defaults
|
|
54
|
+
'salutation', 'gender', 'telephonenumber', 'ip', 'language', 'customer_is_present',
|
|
55
|
+
// Payment method tokens
|
|
56
|
+
'applePayToken', 'googlePayToken',
|
|
57
|
+
// Other known params
|
|
58
|
+
'clearingtype', 'paymentMethod', 'settings', 'enable3DSecure', 'ecommercemode'
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
Object.keys(updated).forEach(key => {
|
|
62
|
+
if (!knownParams.has(key) && !key.startsWith('add_paydata[')) {
|
|
63
|
+
customParams[key] = updated[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const methodDefaults = {
|
|
68
|
+
cc: {
|
|
69
|
+
cardexpiredate: getValidCardExpiryDate(null),
|
|
70
|
+
cardtype: "V"
|
|
71
|
+
},
|
|
72
|
+
wlt: {
|
|
73
|
+
wallettype: "PPE"
|
|
74
|
+
},
|
|
75
|
+
gpp: {
|
|
76
|
+
clearingtype: "wlt",
|
|
77
|
+
wallettype: "GGP"
|
|
78
|
+
},
|
|
79
|
+
apl: {
|
|
80
|
+
clearingtype: "wlt",
|
|
81
|
+
wallettype: "APL"
|
|
82
|
+
},
|
|
83
|
+
elv: {
|
|
84
|
+
bankcountry: "DE",
|
|
85
|
+
iban: "DE89370400440532013000",
|
|
86
|
+
bic: "COBADEFFXXX",
|
|
87
|
+
bankaccountholder: `${updated.firstname || "Test"} ${updated.lastname || "User"}`
|
|
88
|
+
},
|
|
89
|
+
sb: {
|
|
90
|
+
bankcountry: "DE",
|
|
91
|
+
onlinebanktransfertype: "PNT"
|
|
92
|
+
},
|
|
93
|
+
gp: {
|
|
94
|
+
bankcountry: "DE",
|
|
95
|
+
onlinebanktransfertype: "GPY"
|
|
96
|
+
},
|
|
97
|
+
idl: {
|
|
98
|
+
bankcountry: "NL",
|
|
99
|
+
onlinebanktransfertype: "IDL"
|
|
100
|
+
},
|
|
101
|
+
bct: {
|
|
102
|
+
bankcountry: "BE",
|
|
103
|
+
onlinebanktransfertype: "BCT"
|
|
104
|
+
},
|
|
105
|
+
rec: {
|
|
106
|
+
recurrence: "recurring"
|
|
107
|
+
},
|
|
108
|
+
fnc: {
|
|
109
|
+
financingtype: "fnc"
|
|
110
|
+
},
|
|
111
|
+
iv: {
|
|
112
|
+
invoicetype: "invoice"
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (clearingtype === "gpp" || clearingtype === "apl") {
|
|
117
|
+
if (clearingtype === "gpp") {
|
|
118
|
+
updated.wallettype = "GGP";
|
|
119
|
+
} else if (clearingtype === "apl") {
|
|
120
|
+
updated.wallettype = "APL";
|
|
121
|
+
}
|
|
122
|
+
updated.clearingtype = "wlt";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const defaults = methodDefaults[clearingtype] || methodDefaults.cc;
|
|
126
|
+
|
|
127
|
+
Object.entries(defaults).forEach(([key, value]) => {
|
|
128
|
+
if (key === "wallettype" && updated.wallettype) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (key === "cardexpiredate") {
|
|
132
|
+
if (!updated[key] || updated[key].trim() === "") {
|
|
133
|
+
updated[key] = getValidCardExpiryDate(null);
|
|
134
|
+
} else {
|
|
135
|
+
updated[key] = getValidCardExpiryDate(updated[key]);
|
|
136
|
+
}
|
|
137
|
+
} else if (!updated[key]) {
|
|
138
|
+
updated[key] = value;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (updated.applePayToken) {
|
|
143
|
+
let tokenData;
|
|
144
|
+
try {
|
|
145
|
+
const tokenString = Buffer.from(updated.applePayToken, 'base64').toString('utf-8');
|
|
146
|
+
tokenData = JSON.parse(tokenString);
|
|
147
|
+
|
|
148
|
+
if (logger) {
|
|
149
|
+
logger.info("[Apple Pay] Token decoded from Base64 successfully");
|
|
150
|
+
}
|
|
151
|
+
} catch (e) {
|
|
152
|
+
try {
|
|
153
|
+
tokenData = typeof updated.applePayToken === 'string'
|
|
154
|
+
? JSON.parse(updated.applePayToken)
|
|
155
|
+
: updated.applePayToken;
|
|
156
|
+
|
|
157
|
+
if (logger) {
|
|
158
|
+
logger.info("[Apple Pay] Token parsed as JSON string directly");
|
|
159
|
+
}
|
|
160
|
+
} catch (e2) {
|
|
161
|
+
tokenData = updated.applePayToken;
|
|
162
|
+
|
|
163
|
+
if (logger) {
|
|
164
|
+
logger.info("[Apple Pay] Token used as-is (already an object)");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (tokenData && typeof tokenData === 'object') {
|
|
170
|
+
const paymentData = tokenData.paymentData;
|
|
171
|
+
|
|
172
|
+
if (!paymentData) {
|
|
173
|
+
if (logger) {
|
|
174
|
+
logger.error("[Apple Pay] Invalid token structure: missing paymentData field", {
|
|
175
|
+
tokenKeys: Object.keys(tokenData),
|
|
176
|
+
tokenStructure: JSON.stringify(tokenData).substring(0, 500)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
delete updated.applePayToken;
|
|
180
|
+
return updated;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const header = paymentData.header || {};
|
|
184
|
+
|
|
185
|
+
// Payone required fields according to docs
|
|
186
|
+
// Extract version, data, signature from paymentData
|
|
187
|
+
const tokenVersion = paymentData.version || "EC_v1";
|
|
188
|
+
const tokenDataValue = paymentData.data || "";
|
|
189
|
+
const tokenSignature = paymentData.signature || "";
|
|
190
|
+
|
|
191
|
+
// Extract from header
|
|
192
|
+
const ephemeralPublicKey = header.ephemeralPublicKey || "";
|
|
193
|
+
const publicKeyHash = header.publicKeyHash || "";
|
|
194
|
+
const transactionId = paymentData.transactionId || header.transactionId || "";
|
|
195
|
+
|
|
196
|
+
// Set Payone required fields
|
|
197
|
+
updated["add_paydata[paymentdata_token_version]"] = tokenVersion;
|
|
198
|
+
updated["add_paydata[paymentdata_token_data]"] = tokenDataValue;
|
|
199
|
+
updated["add_paydata[paymentdata_token_signature]"] = tokenSignature;
|
|
200
|
+
updated["add_paydata[paymentdata_token_ephemeral_publickey]"] = ephemeralPublicKey;
|
|
201
|
+
updated["add_paydata[paymentdata_token_publickey_hash]"] = publicKeyHash;
|
|
202
|
+
|
|
203
|
+
// Transaction ID is optional according to Payone docs
|
|
204
|
+
if (transactionId) {
|
|
205
|
+
updated["add_paydata[paymentdata_token_transaction_id]"] = transactionId;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (logger) {
|
|
209
|
+
logger.info("[Apple Pay] Token extracted successfully:", {
|
|
210
|
+
hasVersion: !!tokenVersion,
|
|
211
|
+
hasData: !!tokenDataValue,
|
|
212
|
+
hasSignature: !!tokenSignature,
|
|
213
|
+
hasEphemeralPublicKey: !!ephemeralPublicKey,
|
|
214
|
+
hasPublicKeyHash: !!publicKeyHash,
|
|
215
|
+
hasTransactionId: !!transactionId,
|
|
216
|
+
dataLength: tokenDataValue.length,
|
|
217
|
+
signatureLength: tokenSignature.length,
|
|
218
|
+
ephemeralPublicKeyLength: ephemeralPublicKey.length,
|
|
219
|
+
publicKeyHashLength: publicKeyHash.length
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Validate required fields
|
|
224
|
+
if (!tokenDataValue ||
|
|
225
|
+
!tokenSignature ||
|
|
226
|
+
!ephemeralPublicKey ||
|
|
227
|
+
!publicKeyHash) {
|
|
228
|
+
if (logger) {
|
|
229
|
+
logger.error("[Apple Pay] Missing required token fields:", {
|
|
230
|
+
hasData: !!tokenDataValue,
|
|
231
|
+
hasSignature: !!tokenSignature,
|
|
232
|
+
hasEphemeralPublicKey: !!ephemeralPublicKey,
|
|
233
|
+
hasPublicKeyHash: !!publicKeyHash,
|
|
234
|
+
paymentDataKeys: Object.keys(paymentData),
|
|
235
|
+
headerKeys: Object.keys(header)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
if (logger) {
|
|
241
|
+
logger.error("[Apple Pay] Token is not a valid object:", {
|
|
242
|
+
tokenType: typeof tokenData,
|
|
243
|
+
tokenValue: typeof tokenData === 'string' ? tokenData.substring(0, 200) : String(tokenData).substring(0, 200)
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
delete updated.applePayToken;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (updated.clearingtype === "wlt" && !updated.wallettype) {
|
|
252
|
+
if (clearingtype === "gpp" || updated.paymentMethod === "gpp" || (updated["add_paydata[paymentmethod]"] === "GGP")) {
|
|
253
|
+
updated.wallettype = "GGP";
|
|
254
|
+
} else if (clearingtype === "apl" || updated.paymentMethod === "apl" || (updated["add_paydata[paymentmethod]"] === "APL")) {
|
|
255
|
+
updated.wallettype = "APL";
|
|
256
|
+
} else {
|
|
257
|
+
updated.wallettype = "PPE";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (updated.clearingtype === "wlt" && updated.cardtype) {
|
|
261
|
+
delete updated.cardtype;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
const commonDefaults = {
|
|
266
|
+
salutation: "Herr",
|
|
267
|
+
gender: "m",
|
|
268
|
+
telephonenumber: "01752345678",
|
|
269
|
+
ip: "127.0.0.1",
|
|
270
|
+
language: "de",
|
|
271
|
+
customer_is_present: "yes"
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
Object.entries(commonDefaults).forEach(([key, value]) => {
|
|
275
|
+
if (!updated[key]) {
|
|
276
|
+
updated[key] = value;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
Object.assign(updated, customParams);
|
|
281
|
+
|
|
282
|
+
return updated;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
module.exports = {
|
|
286
|
+
addPaymentMethodParams
|
|
287
|
+
};
|
|
288
|
+
|