strapi-plugin-payone-provider 5.7.25 → 5.7.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 +506 -452
- 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 +223 -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 +100 -100
- package/server/utils/responseParser.js +141 -141
- package/strapi-admin.js +4 -4
- package/strapi-server.js +3 -3
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const axios = require("axios");
|
|
4
|
-
const { buildClientRequestParams, toFormData } = require("../utils/requestBuilder");
|
|
5
|
-
const { addPaymentMethodParams } = require("../utils/paymentMethodParams");
|
|
6
|
-
const { parseResponse, extractTxId, requires3DSRedirect, get3DSRedirectUrl } = require("../utils/responseParser");
|
|
7
|
-
const { getSettings, validateSettings } = require("./settingsService");
|
|
8
|
-
const { logTransaction } = require("./transactionService");
|
|
9
|
-
|
|
10
|
-
const POST_GATEWAY_URL = "https://api.pay1.de/post-gateway/";
|
|
11
|
-
|
|
12
|
-
const getInvoiceIdObject = (invoiceid) => {
|
|
13
|
-
if (!invoiceid || typeof invoiceid !== 'string') {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const invoiceIdVariants = [
|
|
18
|
-
'invoiceid',
|
|
19
|
-
'invoiceId',
|
|
20
|
-
'invoice_id',
|
|
21
|
-
'invoiceID',
|
|
22
|
-
'InvoiceId',
|
|
23
|
-
'InvoiceID',
|
|
24
|
-
'Invoice_Id',
|
|
25
|
-
'INVOICEID',
|
|
26
|
-
'INVOICE_ID'
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
let invoiceIdObject = {}
|
|
30
|
-
for (const variant of invoiceIdVariants) {
|
|
31
|
-
invoiceIdObject[variant] = invoiceid;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return invoiceIdObject;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const sendRequest = async (strapi, params) => {
|
|
38
|
-
try {
|
|
39
|
-
const settings = await getSettings(strapi);
|
|
40
|
-
|
|
41
|
-
if (!validateSettings(settings)) {
|
|
42
|
-
throw new Error("Payone settings not configured");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const requestParams = buildClientRequestParams(settings, params, strapi.log);
|
|
46
|
-
const formData = toFormData(requestParams);
|
|
47
|
-
|
|
48
|
-
const response = await axios.post(POST_GATEWAY_URL, formData, {
|
|
49
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
50
|
-
timeout: 30000
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const responseData = parseResponse(response.data, strapi.log);
|
|
54
|
-
const errorCode = responseData?.Error?.ErrorCode;
|
|
55
|
-
const requires3DSErrorCodes = ["4219", 4219];
|
|
56
|
-
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
57
|
-
|
|
58
|
-
if (requires3DSRedirect(responseData) || is3DSRequiredError) {
|
|
59
|
-
const redirectUrl = get3DSRedirectUrl(responseData);
|
|
60
|
-
responseData.requires3DSRedirect = true;
|
|
61
|
-
responseData.redirectUrl = redirectUrl;
|
|
62
|
-
responseData.is3DSRequired = is3DSRequiredError;
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const errorMessage = responseData?.Error?.ErrorMessage || null;
|
|
67
|
-
|
|
68
|
-
const customerMessage = responseData?.Error?.CustomerMessage || null;
|
|
69
|
-
|
|
70
|
-
const status = (responseData?.status || responseData?.Status || "unknown").toUpperCase() || null;
|
|
71
|
-
|
|
72
|
-
await logTransaction(strapi, {
|
|
73
|
-
txid: extractTxId(responseData) || params.txid || null,
|
|
74
|
-
reference: params.reference || null,
|
|
75
|
-
status: status,
|
|
76
|
-
request_type: params.request,
|
|
77
|
-
amount: params.amount || null,
|
|
78
|
-
currency: params.currency || "EUR",
|
|
79
|
-
raw_request: requestParams,
|
|
80
|
-
raw_response: responseData,
|
|
81
|
-
error_code: errorCode,
|
|
82
|
-
error_message: errorMessage,
|
|
83
|
-
customer_message: customerMessage
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
responseData.errorCode = errorCode;
|
|
87
|
-
responseData.errorMessage = errorMessage;
|
|
88
|
-
responseData.customerMessage = customerMessage;
|
|
89
|
-
responseData.status = status;
|
|
90
|
-
|
|
91
|
-
return responseData;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
strapi.log.error("Payone sendRequest error:", error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const preauthorization = async (strapi, params) => {
|
|
99
|
-
|
|
100
|
-
const requiredParams = {
|
|
101
|
-
request: "preauthorization",
|
|
102
|
-
clearingtype: params.clearingtype,
|
|
103
|
-
amount: params.amount,
|
|
104
|
-
currency: params.currency,
|
|
105
|
-
reference: params.reference,
|
|
106
|
-
firstname: params.firstname,
|
|
107
|
-
lastname: params.lastname,
|
|
108
|
-
street: params.street,
|
|
109
|
-
zip: params.zip,
|
|
110
|
-
city: params.city,
|
|
111
|
-
country: params.country,
|
|
112
|
-
email: params.email,
|
|
113
|
-
narrative_text: params.narrative_text,
|
|
114
|
-
...getInvoiceIdObject(params.invoiceid),
|
|
115
|
-
...params
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const updatedParams = addPaymentMethodParams(requiredParams, strapi.log);
|
|
120
|
-
return await sendRequest(strapi, updatedParams);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const authorization = async (strapi, params) => {
|
|
124
|
-
|
|
125
|
-
const requiredParams = {
|
|
126
|
-
request: "authorization",
|
|
127
|
-
clearingtype: params.clearingtype,
|
|
128
|
-
reference: params.reference,
|
|
129
|
-
firstname: params.firstname,
|
|
130
|
-
lastname: params.lastname,
|
|
131
|
-
street: params.street,
|
|
132
|
-
zip: params.zip,
|
|
133
|
-
city: params.city,
|
|
134
|
-
country: params.country,
|
|
135
|
-
email: params.email,
|
|
136
|
-
narrative_text: params.narrative_text,
|
|
137
|
-
...getInvoiceIdObject(params.invoiceid),
|
|
138
|
-
...params
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const updatedParams = addPaymentMethodParams(requiredParams, strapi.log);
|
|
142
|
-
return await sendRequest(strapi, updatedParams);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const capture = async (strapi, params) => {
|
|
146
|
-
if (!params.txid) {
|
|
147
|
-
throw new Error("Transaction ID (txid) is required for capture");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const requiredParams = {
|
|
152
|
-
request: "capture",
|
|
153
|
-
txid: params.txid,
|
|
154
|
-
amount: params.amount || 1000,
|
|
155
|
-
currency: params.currency || "EUR",
|
|
156
|
-
...getInvoiceIdObject(params.invoiceid),
|
|
157
|
-
...params
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
return await sendRequest(strapi, requiredParams);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const refund = async (strapi, params) => {
|
|
164
|
-
if (!params.txid) {
|
|
165
|
-
throw new Error("Transaction ID (txid) is required for refund");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const requiredParams = {
|
|
170
|
-
request: "refund",
|
|
171
|
-
txid: params.txid,
|
|
172
|
-
amount: params.amount || 1000,
|
|
173
|
-
currency: params.currency || "EUR",
|
|
174
|
-
reference: params.reference || `REFUND-${Date.now()}`,
|
|
175
|
-
...getInvoiceIdObject(params.invoiceid),
|
|
176
|
-
...params
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
return await sendRequest(strapi, requiredParams);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const handle3DSCallback = async (strapi, callbackData, resultType = 'callback') => {
|
|
183
|
-
try {
|
|
184
|
-
const parsedData = callbackData && Object.keys(callbackData).length > 0
|
|
185
|
-
? parseResponse(callbackData, strapi.log)
|
|
186
|
-
: {};
|
|
187
|
-
|
|
188
|
-
const txid = extractTxId(parsedData);
|
|
189
|
-
const reference = parsedData.reference || parsedData.Reference || null;
|
|
190
|
-
|
|
191
|
-
let status;
|
|
192
|
-
if (resultType === 'success') {
|
|
193
|
-
status = 'APPROVED';
|
|
194
|
-
} else if (resultType === 'error') {
|
|
195
|
-
status = 'ERROR';
|
|
196
|
-
} else if (resultType === 'cancelled') {
|
|
197
|
-
status = 'CANCELLED';
|
|
198
|
-
} else {
|
|
199
|
-
status = parsedData.status || parsedData.Status || 'PENDING';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
success: resultType === 'success',
|
|
204
|
-
status: status,
|
|
205
|
-
txid: txid,
|
|
206
|
-
reference: reference,
|
|
207
|
-
data: parsedData
|
|
208
|
-
};
|
|
209
|
-
} catch (error) {
|
|
210
|
-
strapi.log.error("3DS callback processing error:", error);
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
module.exports = {
|
|
216
|
-
sendRequest,
|
|
217
|
-
preauthorization,
|
|
218
|
-
authorization,
|
|
219
|
-
capture,
|
|
220
|
-
refund,
|
|
221
|
-
handle3DSCallback
|
|
222
|
-
};
|
|
223
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const axios = require("axios");
|
|
4
|
+
const { buildClientRequestParams, toFormData } = require("../utils/requestBuilder");
|
|
5
|
+
const { addPaymentMethodParams } = require("../utils/paymentMethodParams");
|
|
6
|
+
const { parseResponse, extractTxId, requires3DSRedirect, get3DSRedirectUrl } = require("../utils/responseParser");
|
|
7
|
+
const { getSettings, validateSettings } = require("./settingsService");
|
|
8
|
+
const { logTransaction } = require("./transactionService");
|
|
9
|
+
|
|
10
|
+
const POST_GATEWAY_URL = "https://api.pay1.de/post-gateway/";
|
|
11
|
+
|
|
12
|
+
const getInvoiceIdObject = (invoiceid) => {
|
|
13
|
+
if (!invoiceid || typeof invoiceid !== 'string') {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const invoiceIdVariants = [
|
|
18
|
+
'invoiceid',
|
|
19
|
+
'invoiceId',
|
|
20
|
+
'invoice_id',
|
|
21
|
+
'invoiceID',
|
|
22
|
+
'InvoiceId',
|
|
23
|
+
'InvoiceID',
|
|
24
|
+
'Invoice_Id',
|
|
25
|
+
'INVOICEID',
|
|
26
|
+
'INVOICE_ID'
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
let invoiceIdObject = {}
|
|
30
|
+
for (const variant of invoiceIdVariants) {
|
|
31
|
+
invoiceIdObject[variant] = invoiceid;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return invoiceIdObject;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const sendRequest = async (strapi, params) => {
|
|
38
|
+
try {
|
|
39
|
+
const settings = await getSettings(strapi);
|
|
40
|
+
|
|
41
|
+
if (!validateSettings(settings)) {
|
|
42
|
+
throw new Error("Payone settings not configured");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const requestParams = buildClientRequestParams(settings, params, strapi.log);
|
|
46
|
+
const formData = toFormData(requestParams);
|
|
47
|
+
|
|
48
|
+
const response = await axios.post(POST_GATEWAY_URL, formData, {
|
|
49
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
50
|
+
timeout: 30000
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const responseData = parseResponse(response.data, strapi.log);
|
|
54
|
+
const errorCode = responseData?.Error?.ErrorCode;
|
|
55
|
+
const requires3DSErrorCodes = ["4219", 4219];
|
|
56
|
+
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
57
|
+
|
|
58
|
+
if (requires3DSRedirect(responseData) || is3DSRequiredError) {
|
|
59
|
+
const redirectUrl = get3DSRedirectUrl(responseData);
|
|
60
|
+
responseData.requires3DSRedirect = true;
|
|
61
|
+
responseData.redirectUrl = redirectUrl;
|
|
62
|
+
responseData.is3DSRequired = is3DSRequiredError;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const errorMessage = responseData?.Error?.ErrorMessage || null;
|
|
67
|
+
|
|
68
|
+
const customerMessage = responseData?.Error?.CustomerMessage || null;
|
|
69
|
+
|
|
70
|
+
const status = (responseData?.status || responseData?.Status || "unknown").toUpperCase() || null;
|
|
71
|
+
|
|
72
|
+
await logTransaction(strapi, {
|
|
73
|
+
txid: extractTxId(responseData) || params.txid || null,
|
|
74
|
+
reference: params.reference || null,
|
|
75
|
+
status: status,
|
|
76
|
+
request_type: params.request,
|
|
77
|
+
amount: params.amount || null,
|
|
78
|
+
currency: params.currency || "EUR",
|
|
79
|
+
raw_request: requestParams,
|
|
80
|
+
raw_response: responseData,
|
|
81
|
+
error_code: errorCode,
|
|
82
|
+
error_message: errorMessage,
|
|
83
|
+
customer_message: customerMessage
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
responseData.errorCode = errorCode;
|
|
87
|
+
responseData.errorMessage = errorMessage;
|
|
88
|
+
responseData.customerMessage = customerMessage;
|
|
89
|
+
responseData.status = status;
|
|
90
|
+
|
|
91
|
+
return responseData;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
strapi.log.error("Payone sendRequest error:", error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const preauthorization = async (strapi, params) => {
|
|
99
|
+
|
|
100
|
+
const requiredParams = {
|
|
101
|
+
request: "preauthorization",
|
|
102
|
+
clearingtype: params.clearingtype,
|
|
103
|
+
amount: params.amount,
|
|
104
|
+
currency: params.currency,
|
|
105
|
+
reference: params.reference,
|
|
106
|
+
firstname: params.firstname,
|
|
107
|
+
lastname: params.lastname,
|
|
108
|
+
street: params.street,
|
|
109
|
+
zip: params.zip,
|
|
110
|
+
city: params.city,
|
|
111
|
+
country: params.country,
|
|
112
|
+
email: params.email,
|
|
113
|
+
narrative_text: params.narrative_text,
|
|
114
|
+
...getInvoiceIdObject(params.invoiceid),
|
|
115
|
+
...params
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const updatedParams = addPaymentMethodParams(requiredParams, strapi.log);
|
|
120
|
+
return await sendRequest(strapi, updatedParams);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const authorization = async (strapi, params) => {
|
|
124
|
+
|
|
125
|
+
const requiredParams = {
|
|
126
|
+
request: "authorization",
|
|
127
|
+
clearingtype: params.clearingtype,
|
|
128
|
+
reference: params.reference,
|
|
129
|
+
firstname: params.firstname,
|
|
130
|
+
lastname: params.lastname,
|
|
131
|
+
street: params.street,
|
|
132
|
+
zip: params.zip,
|
|
133
|
+
city: params.city,
|
|
134
|
+
country: params.country,
|
|
135
|
+
email: params.email,
|
|
136
|
+
narrative_text: params.narrative_text,
|
|
137
|
+
...getInvoiceIdObject(params.invoiceid),
|
|
138
|
+
...params
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const updatedParams = addPaymentMethodParams(requiredParams, strapi.log);
|
|
142
|
+
return await sendRequest(strapi, updatedParams);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const capture = async (strapi, params) => {
|
|
146
|
+
if (!params.txid) {
|
|
147
|
+
throw new Error("Transaction ID (txid) is required for capture");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
const requiredParams = {
|
|
152
|
+
request: "capture",
|
|
153
|
+
txid: params.txid,
|
|
154
|
+
amount: params.amount || 1000,
|
|
155
|
+
currency: params.currency || "EUR",
|
|
156
|
+
...getInvoiceIdObject(params.invoiceid),
|
|
157
|
+
...params
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return await sendRequest(strapi, requiredParams);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const refund = async (strapi, params) => {
|
|
164
|
+
if (!params.txid) {
|
|
165
|
+
throw new Error("Transaction ID (txid) is required for refund");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
const requiredParams = {
|
|
170
|
+
request: "refund",
|
|
171
|
+
txid: params.txid,
|
|
172
|
+
amount: params.amount || 1000,
|
|
173
|
+
currency: params.currency || "EUR",
|
|
174
|
+
reference: params.reference || `REFUND-${Date.now()}`,
|
|
175
|
+
...getInvoiceIdObject(params.invoiceid),
|
|
176
|
+
...params
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return await sendRequest(strapi, requiredParams);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const handle3DSCallback = async (strapi, callbackData, resultType = 'callback') => {
|
|
183
|
+
try {
|
|
184
|
+
const parsedData = callbackData && Object.keys(callbackData).length > 0
|
|
185
|
+
? parseResponse(callbackData, strapi.log)
|
|
186
|
+
: {};
|
|
187
|
+
|
|
188
|
+
const txid = extractTxId(parsedData);
|
|
189
|
+
const reference = parsedData.reference || parsedData.Reference || null;
|
|
190
|
+
|
|
191
|
+
let status;
|
|
192
|
+
if (resultType === 'success') {
|
|
193
|
+
status = 'APPROVED';
|
|
194
|
+
} else if (resultType === 'error') {
|
|
195
|
+
status = 'ERROR';
|
|
196
|
+
} else if (resultType === 'cancelled') {
|
|
197
|
+
status = 'CANCELLED';
|
|
198
|
+
} else {
|
|
199
|
+
status = parsedData.status || parsedData.Status || 'PENDING';
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
success: resultType === 'success',
|
|
204
|
+
status: status,
|
|
205
|
+
txid: txid,
|
|
206
|
+
reference: reference,
|
|
207
|
+
data: parsedData
|
|
208
|
+
};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
strapi.log.error("3DS callback processing error:", error);
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
module.exports = {
|
|
216
|
+
sendRequest,
|
|
217
|
+
preauthorization,
|
|
218
|
+
authorization,
|
|
219
|
+
capture,
|
|
220
|
+
refund,
|
|
221
|
+
handle3DSCallback
|
|
222
|
+
};
|
|
223
|
+
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const settingsService = require("./settingsService");
|
|
4
|
-
const transactionService = require("./transactionService");
|
|
5
|
-
const paymentService = require("./paymentService");
|
|
6
|
-
const testConnectionService = require("./testConnectionService");
|
|
7
|
-
const applePayService = require("./applePayService");
|
|
8
|
-
const transactionStatusService = require("./transactionStatusService");
|
|
9
|
-
|
|
10
|
-
module.exports = ({ strapi }) => ({
|
|
11
|
-
// Settings
|
|
12
|
-
async getSettings() {
|
|
13
|
-
return await settingsService.getSettings(strapi);
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
async updateSettings(settings) {
|
|
17
|
-
return await settingsService.updateSettings(strapi, settings);
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
async preauthorization(params) {
|
|
21
|
-
return await paymentService.preauthorization(strapi, params);
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
async authorization(params) {
|
|
25
|
-
return await paymentService.authorization(strapi, params);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
async capture(params) {
|
|
29
|
-
return await paymentService.capture(strapi, params);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
async refund(params) {
|
|
33
|
-
return await paymentService.refund(strapi, params);
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
// Transaction history
|
|
37
|
-
async logTransaction(transactionData) {
|
|
38
|
-
return await transactionService.logTransaction(strapi, transactionData);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
async getTransactionHistory({ filters = {}, pagination = {} }) {
|
|
43
|
-
return await transactionService.getTransactionHistory(strapi, { filters, pagination });
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
async getTransactionsForExport({ filters = {}, sort_by, sort_order } = {}) {
|
|
47
|
-
return await transactionService.getTransactionsForExport(strapi, { filters, sort_by, sort_order });
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
async importTransactions(rows) {
|
|
51
|
-
return await transactionService.importTransactions(strapi, rows);
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
// Test connection
|
|
55
|
-
async testConnection() {
|
|
56
|
-
return await testConnectionService.testConnection(strapi);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// 3D Secure callback handler
|
|
60
|
-
async handle3DSCallback(callbackData, resultType) {
|
|
61
|
-
return await paymentService.handle3DSCallback(strapi, callbackData, resultType);
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// Apple Pay
|
|
65
|
-
async validateApplePayMerchant(params) {
|
|
66
|
-
return await applePayService.validateApplePayMerchant(strapi, params);
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
async initializeApplePaySession(params) {
|
|
70
|
-
return await applePayService.initializeApplePaySession(strapi, params);
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
// TransactionStatus Notification
|
|
74
|
-
async processTransactionStatus(notificationData) {
|
|
75
|
-
return await transactionStatusService.processTransactionStatus(strapi, notificationData);
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const settingsService = require("./settingsService");
|
|
4
|
+
const transactionService = require("./transactionService");
|
|
5
|
+
const paymentService = require("./paymentService");
|
|
6
|
+
const testConnectionService = require("./testConnectionService");
|
|
7
|
+
const applePayService = require("./applePayService");
|
|
8
|
+
const transactionStatusService = require("./transactionStatusService");
|
|
9
|
+
|
|
10
|
+
module.exports = ({ strapi }) => ({
|
|
11
|
+
// Settings
|
|
12
|
+
async getSettings() {
|
|
13
|
+
return await settingsService.getSettings(strapi);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async updateSettings(settings) {
|
|
17
|
+
return await settingsService.updateSettings(strapi, settings);
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async preauthorization(params) {
|
|
21
|
+
return await paymentService.preauthorization(strapi, params);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
async authorization(params) {
|
|
25
|
+
return await paymentService.authorization(strapi, params);
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async capture(params) {
|
|
29
|
+
return await paymentService.capture(strapi, params);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async refund(params) {
|
|
33
|
+
return await paymentService.refund(strapi, params);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// Transaction history
|
|
37
|
+
async logTransaction(transactionData) {
|
|
38
|
+
return await transactionService.logTransaction(strapi, transactionData);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async getTransactionHistory({ filters = {}, pagination = {} }) {
|
|
43
|
+
return await transactionService.getTransactionHistory(strapi, { filters, pagination });
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
async getTransactionsForExport({ filters = {}, sort_by, sort_order } = {}) {
|
|
47
|
+
return await transactionService.getTransactionsForExport(strapi, { filters, sort_by, sort_order });
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
async importTransactions(rows) {
|
|
51
|
+
return await transactionService.importTransactions(strapi, rows);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Test connection
|
|
55
|
+
async testConnection() {
|
|
56
|
+
return await testConnectionService.testConnection(strapi);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// 3D Secure callback handler
|
|
60
|
+
async handle3DSCallback(callbackData, resultType) {
|
|
61
|
+
return await paymentService.handle3DSCallback(strapi, callbackData, resultType);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
// Apple Pay
|
|
65
|
+
async validateApplePayMerchant(params) {
|
|
66
|
+
return await applePayService.validateApplePayMerchant(strapi, params);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
async initializeApplePaySession(params) {
|
|
70
|
+
return await applePayService.initializeApplePaySession(strapi, params);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// TransactionStatus Notification
|
|
74
|
+
async processTransactionStatus(notificationData) {
|
|
75
|
+
return await transactionStatusService.processTransactionStatus(strapi, notificationData);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
});
|