strapi-plugin-payone-provider 1.5.8 → 1.6.1

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.
Files changed (53) hide show
  1. package/admin/src/components/Initializer/index.jsx +16 -0
  2. package/admin/src/components/PluginIcon/index.jsx +6 -0
  3. package/admin/src/index.js +3 -3
  4. package/admin/src/pages/App/components/AppHeader.jsx +55 -0
  5. package/admin/src/pages/App/components/AppTabs.jsx +158 -0
  6. package/admin/src/pages/App/components/ApplePayBtn.jsx +304 -0
  7. package/admin/src/pages/App/components/ApplePayButton.js +139 -93
  8. package/admin/src/pages/App/components/ApplePayButton.jsx +908 -0
  9. package/admin/src/pages/App/components/ApplePayConfig.jsx +298 -0
  10. package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +81 -0
  11. package/admin/src/pages/App/components/ConfigurationPanel.jsx +280 -0
  12. package/admin/src/pages/App/components/DocsPanel.jsx +1057 -0
  13. package/admin/src/pages/App/components/GooglePayConfig.jsx +217 -0
  14. package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +82 -0
  15. package/admin/src/pages/App/components/GooglePaybutton.jsx +300 -0
  16. package/admin/src/pages/App/components/HistoryPanel.jsx +285 -0
  17. package/admin/src/pages/App/components/PaymentActionsPanel.jsx +238 -0
  18. package/admin/src/pages/App/components/StatusBadge.jsx +24 -0
  19. package/admin/src/pages/App/components/TransactionHistoryItem.jsx +377 -0
  20. package/admin/src/pages/App/components/icons/BankIcon.jsx +10 -0
  21. package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +9 -0
  22. package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +9 -0
  23. package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +9 -0
  24. package/admin/src/pages/App/components/icons/ErrorIcon.jsx +10 -0
  25. package/admin/src/pages/App/components/icons/InfoIcon.jsx +9 -0
  26. package/admin/src/pages/App/components/icons/PaymentIcon.jsx +10 -0
  27. package/admin/src/pages/App/components/icons/PendingIcon.jsx +9 -0
  28. package/admin/src/pages/App/components/icons/PersonIcon.jsx +9 -0
  29. package/admin/src/pages/App/components/icons/SuccessIcon.jsx +9 -0
  30. package/admin/src/pages/App/components/icons/WalletIcon.jsx +9 -0
  31. package/admin/src/pages/App/components/icons/index.jsx +11 -0
  32. package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +205 -0
  33. package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +65 -0
  34. package/admin/src/pages/App/components/paymentActions/CardDetailsInput.jsx +191 -0
  35. package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +236 -0
  36. package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +148 -0
  37. package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +132 -0
  38. package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +90 -0
  39. package/admin/src/pages/App/index.jsx +127 -0
  40. package/admin/src/pages/constants/paymentConstants.js +1 -2
  41. package/admin/src/pages/hooks/usePaymentActions.js +96 -0
  42. package/package.json +2 -2
  43. package/server/bootstrap.js +65 -0
  44. package/server/controllers/payone.js +4 -48
  45. package/server/routes/index.js +1 -1
  46. package/server/services/applePayService.js +51 -407
  47. package/server/services/paymentService.js +0 -68
  48. package/server/services/payone.js +0 -3
  49. package/server/services/settingsService.js +0 -21
  50. package/server/services/testConnectionService.js +0 -14
  51. package/server/services/transactionService.js +14 -0
  52. package/server/utils/paymentMethodParams.js +60 -27
  53. package/server/utils/requestBuilder.js +0 -22
@@ -6,9 +6,6 @@ const paymentService = require("./paymentService");
6
6
  const testConnectionService = require("./testConnectionService");
7
7
  const applePayService = require("./applePayService");
8
8
 
9
- /**
10
- * Main Payone service - aggregates all sub-services
11
- */
12
9
  module.exports = ({ strapi }) => ({
13
10
  // Settings
14
11
  async getSettings() {
@@ -2,11 +2,6 @@
2
2
 
3
3
  const PLUGIN_NAME = "strapi-plugin-payone-provider";
4
4
 
5
- /**
6
- * Get plugin store instance
7
- * @param {Object} strapi - Strapi instance
8
- * @returns {Object} Plugin store
9
- */
10
5
  const getPluginStore = (strapi) => {
11
6
  return strapi.store({
12
7
  environment: "",
@@ -15,22 +10,11 @@ const getPluginStore = (strapi) => {
15
10
  });
16
11
  };
17
12
 
18
- /**
19
- * Get Payone settings
20
- * @param {Object} strapi - Strapi instance
21
- * @returns {Promise<Object>} Settings
22
- */
23
13
  const getSettings = async (strapi) => {
24
14
  const pluginStore = getPluginStore(strapi);
25
15
  return await pluginStore.get({ key: "settings" });
26
16
  };
27
17
 
28
- /**
29
- * Update Payone settings
30
- * @param {Object} strapi - Strapi instance
31
- * @param {Object} settings - Settings to update
32
- * @returns {Promise<Object>} Updated settings
33
- */
34
18
  const updateSettings = async (strapi, settings) => {
35
19
  const pluginStore = getPluginStore(strapi);
36
20
  await pluginStore.set({
@@ -40,11 +24,6 @@ const updateSettings = async (strapi, settings) => {
40
24
  return settings;
41
25
  };
42
26
 
43
- /**
44
- * Validate settings
45
- * @param {Object} settings - Settings to validate
46
- * @returns {boolean} True if valid
47
- */
48
27
  const validateSettings = (settings) => {
49
28
  return !!(settings && settings.aid && settings.portalid && settings.key);
50
29
  };
@@ -7,11 +7,6 @@ const { getSettings, validateSettings } = require("./settingsService");
7
7
 
8
8
  const POST_GATEWAY_URL = "https://api.pay1.de/post-gateway/";
9
9
 
10
- /**
11
- * Test Payone connection
12
- * @param {Object} strapi - Strapi instance
13
- * @returns {Promise<Object>} Test result
14
- */
15
10
  const testConnection = async (strapi) => {
16
11
  try {
17
12
  const settings = await getSettings(strapi);
@@ -79,11 +74,7 @@ const testConnection = async (strapi) => {
79
74
  result.Error?.CustomerMessage ||
80
75
  "";
81
76
 
82
- strapi.log.info("Payone test connection response:", { status, errorCode });
83
-
84
- // Handle error status
85
77
  if (status === "ERROR" || status === "error") {
86
- // Authentication errors
87
78
  if (["2006", "920", "921", "922", "401", "403"].includes(errorCode)) {
88
79
  return {
89
80
  success: false,
@@ -92,7 +83,6 @@ const testConnection = async (strapi) => {
92
83
  };
93
84
  }
94
85
 
95
- // Check for invalid credentials in message
96
86
  const errorMessageStr = typeof errorMessage === "string" ? errorMessage : JSON.stringify(errorMessage);
97
87
  const errorMessageLower = (errorMessageStr || "").toLowerCase();
98
88
  const authErrorKeywords = [
@@ -118,7 +108,6 @@ const testConnection = async (strapi) => {
118
108
  };
119
109
  }
120
110
 
121
- // Reference already exists (911) means credentials are working
122
111
  if (errorCode === "911") {
123
112
  return {
124
113
  success: true,
@@ -132,7 +121,6 @@ const testConnection = async (strapi) => {
132
121
  };
133
122
  }
134
123
 
135
- // Other errors
136
124
  return {
137
125
  success: false,
138
126
  message: `Connection failed: ${customErrorMessage || errorMessageStr || "Unknown error"}`,
@@ -145,7 +133,6 @@ const testConnection = async (strapi) => {
145
133
  };
146
134
  }
147
135
 
148
- // APPROVED status means connection is OK
149
136
  if (status === "APPROVED" || status === "approved") {
150
137
  return {
151
138
  success: true,
@@ -159,7 +146,6 @@ const testConnection = async (strapi) => {
159
146
  };
160
147
  }
161
148
 
162
- // Unexpected response format
163
149
  return {
164
150
  success: false,
165
151
  message: "Unexpected response format from Payone API",
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ <<<<<<< HEAD
3
4
  const { getPluginStore, PLUGIN_NAME } = require("./settingsService");
4
5
 
5
6
  /**
@@ -8,6 +9,10 @@ const { getPluginStore, PLUGIN_NAME } = require("./settingsService");
8
9
  * @param {Object} transactionData - Transaction data
9
10
  * @returns {Promise<void>}
10
11
  */
12
+ =======
13
+ const { getPluginStore } = require("./settingsService");
14
+
15
+ >>>>>>> feature/apple-pay
11
16
  const logTransaction = async (strapi, transactionData) => {
12
17
  const pluginStore = getPluginStore(strapi);
13
18
  let transactionHistory =
@@ -41,7 +46,10 @@ const logTransaction = async (strapi, transactionData) => {
41
46
 
42
47
  transactionHistory.unshift(logEntry);
43
48
 
49
+ <<<<<<< HEAD
44
50
  // Keep only last 1000 transactions
51
+ =======
52
+ >>>>>>> feature/apple-pay
45
53
  if (transactionHistory.length > 1000) {
46
54
  transactionHistory = transactionHistory.slice(0, 1000);
47
55
  }
@@ -54,18 +62,24 @@ const logTransaction = async (strapi, transactionData) => {
54
62
  strapi.log.info("Transaction logged:", logEntry);
55
63
  };
56
64
 
65
+ <<<<<<< HEAD
57
66
  /**
58
67
  * Get transaction history with filters
59
68
  * @param {Object} strapi - Strapi instance
60
69
  * @param {Object} filters - Filter options
61
70
  * @returns {Promise<Array>} Filtered transaction history
62
71
  */
72
+ =======
73
+ >>>>>>> feature/apple-pay
63
74
  const getTransactionHistory = async (strapi, filters = {}) => {
64
75
  const pluginStore = getPluginStore(strapi);
65
76
  let transactionHistory =
66
77
  (await pluginStore.get({ key: "transactionHistory" })) || [];
67
78
 
79
+ <<<<<<< HEAD
68
80
  // Apply filters
81
+ =======
82
+ >>>>>>> feature/apple-pay
69
83
  if (filters.status) {
70
84
  transactionHistory = transactionHistory.filter(
71
85
  (transaction) => transaction.status === filters.status
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Add payment method specific parameters
5
- * @param {Object} params - Request parameters
6
- * @param {Object} logger - Logger instance
7
- * @returns {Object} Updated parameters with payment method defaults
8
- */
3
+
9
4
  const addPaymentMethodParams = (params, logger) => {
10
5
  const updated = { ...params };
11
6
  const clearingtype = updated.clearingtype || "cc";
@@ -62,7 +57,6 @@ const addPaymentMethodParams = (params, logger) => {
62
57
  }
63
58
  };
64
59
 
65
- // Handle special cases (gpp, apl) FIRST - set wallettype BEFORE changing clearingtype
66
60
  if (clearingtype === "gpp" || clearingtype === "apl") {
67
61
  if (clearingtype === "gpp") {
68
62
  updated.wallettype = "GGP";
@@ -74,34 +68,76 @@ const addPaymentMethodParams = (params, logger) => {
74
68
 
75
69
  const defaults = methodDefaults[clearingtype] || methodDefaults.cc;
76
70
 
77
- // Apply defaults (but don't override wallettype if already set)
78
71
  Object.entries(defaults).forEach(([key, value]) => {
79
72
  if (key === "wallettype" && updated.wallettype) {
80
- return; // Don't override wallettype if already set
73
+ return;
81
74
  }
82
75
  if (!updated[key]) {
83
76
  updated[key] = value;
84
77
  }
85
78
  });
86
-
87
- // Handle Apple Pay token if present
88
- if (updated.applePayToken || updated["add_paydata[paymentmethod_token_data]"]) {
89
- const token = updated.applePayToken || updated["add_paydata[paymentmethod_token_data]"];
90
- const gatewayMerchantId = updated.mid || updated.portalid || '';
91
-
92
- updated["add_paydata[paymentmethod_token_data]"] = token;
93
- updated["add_paydata[paymentmethod]"] = "APL";
94
- updated["add_paydata[paymentmethod_type]"] = "APPLEPAY";
95
- updated["add_paydata[gatewayid]"] = "payonegmbh";
96
- if (gatewayMerchantId) {
97
- updated["add_paydata[gateway_merchantid]"] = gatewayMerchantId;
79
+
80
+ if (updated.applePayToken) {
81
+ let tokenData;
82
+ try {
83
+ // Decode Base64 token
84
+ const tokenString = Buffer.from(updated.applePayToken, 'base64').toString('utf-8');
85
+ tokenData = JSON.parse(tokenString);
86
+ } catch (e) {
87
+ try {
88
+ // Try parsing as JSON string directly
89
+ tokenData = typeof updated.applePayToken === 'string'
90
+ ? JSON.parse(updated.applePayToken)
91
+ : updated.applePayToken;
92
+ } catch (e2) {
93
+ // If already an object, use as-is
94
+ tokenData = updated.applePayToken;
95
+ }
96
+ }
97
+
98
+ if (tokenData && typeof tokenData === 'object') {
99
+ const paymentData = tokenData.paymentData;
100
+
101
+ if (!paymentData) {
102
+ if (logger) {
103
+ logger.error("[Apple Pay] Invalid token structure: missing paymentData field");
104
+ }
105
+ delete updated.applePayToken;
106
+ return updated;
107
+ }
108
+
109
+ const header = paymentData.header || {};
110
+
111
+ // Payone required fields according to docs
112
+ updated["add_paydata[paymentdata_token_version]"] = paymentData.version || "EC_v1";
113
+ updated["add_paydata[paymentdata_token_data]"] = paymentData.data || "";
114
+ updated["add_paydata[paymentdata_token_signature]"] = paymentData.signature || "";
115
+ updated["add_paydata[paymentdata_token_ephemeral_publickey]"] = header.ephemeralPublicKey || "";
116
+ updated["add_paydata[paymentdata_token_publickey_hash]"] = header.publicKeyHash || "";
117
+
118
+ // Transaction ID is optional according to Payone docs
119
+ if (paymentData.transactionId || header.transactionId) {
120
+ updated["add_paydata[paymentdata_token_transaction_id]"] = paymentData.transactionId || header.transactionId || "";
121
+ }
122
+
123
+ if (!updated["add_paydata[paymentdata_token_data]"] ||
124
+ !updated["add_paydata[paymentdata_token_signature]"] ||
125
+ !updated["add_paydata[paymentdata_token_ephemeral_publickey]"] ||
126
+ !updated["add_paydata[paymentdata_token_publickey_hash]"]) {
127
+ if (logger) {
128
+ logger.error("[Apple Pay] Missing required token fields:", {
129
+ hasData: !!updated["add_paydata[paymentdata_token_data]"],
130
+ hasSignature: !!updated["add_paydata[paymentdata_token_signature]"],
131
+ hasEphemeralPublicKey: !!updated["add_paydata[paymentdata_token_ephemeral_publickey]"],
132
+ hasPublicKeyHash: !!updated["add_paydata[paymentdata_token_publickey_hash]"]
133
+ });
134
+ }
135
+ }
98
136
  }
99
-
100
- // Remove applePayToken from params as it's now in add_paydata
137
+
101
138
  delete updated.applePayToken;
102
139
  }
103
140
 
104
- // Ensure wallettype is set for wallet payments
105
141
  if (updated.clearingtype === "wlt" && !updated.wallettype) {
106
142
  if (clearingtype === "gpp" || updated.paymentMethod === "gpp" || (updated["add_paydata[paymentmethod]"] === "GGP")) {
107
143
  updated.wallettype = "GGP";
@@ -111,14 +147,11 @@ const addPaymentMethodParams = (params, logger) => {
111
147
  updated.wallettype = "PPE";
112
148
  }
113
149
  }
114
-
115
- // Remove cardtype if clearingtype is wallet payment
116
150
  if (updated.clearingtype === "wlt" && updated.cardtype) {
117
151
  delete updated.cardtype;
118
152
  }
119
153
 
120
154
 
121
- // Common defaults
122
155
  const commonDefaults = {
123
156
  salutation: "Herr",
124
157
  gender: "m",
@@ -3,13 +3,6 @@
3
3
  const crypto = require("crypto");
4
4
  const { normalizeCustomerId } = require("./normalize");
5
5
 
6
- /**
7
- * Build client request parameters for Payone API
8
- * @param {Object} settings - Payone settings
9
- * @param {Object} params - Request parameters
10
- * @param {Object|null} logger - Logger instance
11
- * @returns {Object} Built request parameters
12
- */
13
6
  const buildClientRequestParams = (settings, params, logger = null) => {
14
7
  const requestParams = {
15
8
  request: params.request,
@@ -21,29 +14,23 @@ const buildClientRequestParams = (settings, params, logger = null) => {
21
14
  ...params
22
15
  };
23
16
 
24
- // Generate MD5 hash key
25
17
  requestParams.key = crypto
26
18
  .createHash("md5")
27
19
  .update(settings.portalKey || settings.key)
28
20
  .digest("hex");
29
21
 
30
- // Normalize customer ID
31
22
  requestParams.customerid = normalizeCustomerId(
32
23
  requestParams.customerid,
33
24
  logger
34
25
  );
35
26
 
36
- // Add 3D Secure parameters if enabled and for credit card payments
37
27
  const isCreditCard = requestParams.clearingtype === "cc";
38
- // Enable 3DS if setting is true or not explicitly false (default to enabled if not set)
39
28
  const enable3DSecure = settings.enable3DSecure !== false;
40
29
 
41
30
  if (isCreditCard && enable3DSecure && (params.request === "preauthorization" || params.request === "authorization")) {
42
31
  requestParams["3dsecure"] = "yes";
43
32
  requestParams.ecommercemode = params.ecommercemode || "internet";
44
33
 
45
- // Ensure redirect URLs are always provided for 3DS
46
- // These are required for 3DS authentication flow
47
34
  if (!requestParams.successurl) {
48
35
  requestParams.successurl = params.successurl || "https://www.example.com/success";
49
36
  }
@@ -54,7 +41,6 @@ const buildClientRequestParams = (settings, params, logger = null) => {
54
41
  requestParams.backurl = params.backurl || "https://www.example.com/back";
55
42
  }
56
43
 
57
- // Log redirect URLs for debugging
58
44
  if (logger) {
59
45
  logger.info("3DS Redirect URLs:", {
60
46
  successurl: requestParams.successurl,
@@ -66,7 +52,6 @@ const buildClientRequestParams = (settings, params, logger = null) => {
66
52
  requestParams["3dsecure"] = "no";
67
53
  }
68
54
 
69
- // Set default values
70
55
  const defaults = {
71
56
  salutation: "Herr",
72
57
  gender: "m",
@@ -82,12 +67,10 @@ const buildClientRequestParams = (settings, params, logger = null) => {
82
67
  }
83
68
  });
84
69
 
85
- // Remove cardtype if clearingtype is wallet payment
86
70
  if (requestParams.clearingtype === "wlt" && requestParams.cardtype) {
87
71
  delete requestParams.cardtype;
88
72
  }
89
73
 
90
- // Ensure wallettype is set for wallet payments
91
74
  if (requestParams.clearingtype === "wlt" && !requestParams.wallettype) {
92
75
  if (requestParams["add_paydata[paymentmethod_token_data]"]) {
93
76
  requestParams.wallettype = "GGP";
@@ -99,11 +82,6 @@ const buildClientRequestParams = (settings, params, logger = null) => {
99
82
  return requestParams;
100
83
  };
101
84
 
102
- /**
103
- * Convert request parameters to form data
104
- * @param {Object} requestParams - Request parameters
105
- * @returns {URLSearchParams} Form data
106
- */
107
85
  const toFormData = (requestParams) => {
108
86
  const formData = new URLSearchParams();
109
87
  for (const [key, value] of Object.entries(requestParams)) {