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
@@ -0,0 +1,16 @@
1
+ import { useEffect, useRef } from "react";
2
+ import pluginId from "../../pluginId";
3
+
4
+ const Initializer = ({ setPlugin }) => {
5
+ const ref = useRef(setPlugin);
6
+
7
+ useEffect(() => {
8
+ if (ref.current) {
9
+ ref.current(pluginId);
10
+ }
11
+ }, []);
12
+
13
+ return null;
14
+ };
15
+
16
+ export default Initializer;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { Puzzle } from "@strapi/icons";
3
+
4
+ const PluginIcon = () => <Puzzle />;
5
+
6
+ export default PluginIcon;
@@ -1,7 +1,7 @@
1
1
  import pluginPkg from "../../package.json";
2
2
  import pluginId from "./pluginId";
3
- import Initializer from "./components/Initializer";
4
- import PluginIcon from "./components/PluginIcon";
3
+ import Initializer from "./components/Initializer/index.jsx";
4
+ import PluginIcon from "./components/PluginIcon/index.jsx";
5
5
  import { injectGooglePayScript } from "./pages/utils/injectGooglePayScript";
6
6
 
7
7
  const name = pluginPkg.strapi.name;
@@ -16,7 +16,7 @@ export default {
16
16
  defaultMessage: "Payone Provider"
17
17
  },
18
18
  Component: async () => {
19
- const component = await import("./pages/App");
19
+ const component = await import("./pages/App/index.jsx");
20
20
  return component;
21
21
  },
22
22
  permissions: []
@@ -0,0 +1,55 @@
1
+ import React from "react";
2
+ import { HeaderLayout, Box, Typography, Button } from "@strapi/design-system";
3
+ import { Check, ArrowLeft } from "@strapi/icons";
4
+ import { useHistory, useLocation } from "react-router-dom";
5
+ import pluginId from "../../../pluginId";
6
+
7
+ const AppHeader = ({ activeTab, isSaving, onSave }) => {
8
+ const history = useHistory();
9
+ const location = useLocation();
10
+ const isApplePayConfigPage = location.pathname.includes('/apple-pay-config');
11
+
12
+ return (
13
+ <HeaderLayout
14
+ title={
15
+ <Box>
16
+ <Typography variant="alpha" as="h1" fontWeight="bold" className="payment-title">
17
+ {isApplePayConfigPage ? "Apple Pay Configuration" : "Payone Provider"}
18
+ </Typography>
19
+ <Typography variant="pi" marginTop={2} className="payment-subtitle">
20
+ {isApplePayConfigPage
21
+ ? "Configure Apple Pay settings for your payment gateway"
22
+ : "Configure your Payone integration and manage payment transactions"
23
+ }
24
+ </Typography>
25
+ </Box>
26
+ }
27
+ primaryAction={
28
+ isApplePayConfigPage ? (
29
+ <Button
30
+ onClick={() => history.push(`/plugins/${pluginId}`)}
31
+ startIcon={<ArrowLeft />}
32
+ size="L"
33
+ variant="secondary"
34
+ >
35
+ Back to Main
36
+ </Button>
37
+ ) : activeTab === 0 ? (
38
+ <Button
39
+ loading={isSaving}
40
+ onClick={onSave}
41
+ startIcon={<Check />}
42
+ size="L"
43
+ variant="default"
44
+ className="payment-button payment-button-success"
45
+ >
46
+ Save Configuration
47
+ </Button>
48
+ ) : null
49
+ }
50
+ />
51
+ );
52
+ };
53
+
54
+ export default AppHeader;
55
+
@@ -0,0 +1,158 @@
1
+ import React from "react";
2
+ import { Tabs, Tab, TabGroup, TabPanels, TabPanel } from "@strapi/design-system";
3
+ import pluginId from "../../../pluginId";
4
+ import ConfigurationPanel from "./ConfigurationPanel";
5
+ import HistoryPanel from "./HistoryPanel";
6
+ import PaymentActionsPanel from "./PaymentActionsPanel";
7
+ import DocsPanel from "./DocsPanel";
8
+
9
+ const AppTabs = ({
10
+ activeTab,
11
+ setActiveTab,
12
+ // Settings props
13
+ settings,
14
+ isSaving,
15
+ isTesting,
16
+ testResult,
17
+ onSave,
18
+ onTestConnection,
19
+ onInputChange,
20
+ // Transaction history props
21
+ filters,
22
+ onFilterChange,
23
+ onFilterApply,
24
+ isLoadingHistory,
25
+ transactionHistory,
26
+ paginatedTransactions,
27
+ currentPage,
28
+ totalPages,
29
+ pageSize,
30
+ onRefresh,
31
+ onPageChange,
32
+ selectedTransaction,
33
+ onTransactionSelect,
34
+ // Payment actions props
35
+ paymentActions,
36
+ history
37
+ }) => {
38
+ const handleNavigateToConfig = (configType = "apple-pay") => {
39
+ if (history) {
40
+ if (configType === "google-pay") {
41
+ history.push(`/plugins/${pluginId}/google-pay-config`);
42
+ } else {
43
+ history.push(`/plugins/${pluginId}/apple-pay-config`);
44
+ }
45
+ }
46
+ };
47
+ return (
48
+ <TabGroup
49
+ label="Payone Provider Tabs"
50
+ onTabChange={(index) => setActiveTab(index)}
51
+ >
52
+ <Tabs style={{ borderBottom: "2px solid #e8e8ea" }}>
53
+ <Tab
54
+ className={`payment-tab ${activeTab === 0 ? 'payment-tab-active' : ''}`}
55
+ >
56
+ Configuration
57
+ </Tab>
58
+ <Tab
59
+ className={`payment-tab ${activeTab === 1 ? 'payment-tab-active' : ''}`}
60
+ >
61
+ Transaction History
62
+ </Tab>
63
+ <Tab
64
+ className={`payment-tab ${activeTab === 2 ? 'payment-tab-active' : ''}`}
65
+ >
66
+ Payment Actions
67
+ </Tab>
68
+ <Tab
69
+ className={`payment-tab ${activeTab === 3 ? 'payment-tab-active' : ''}`}
70
+ >
71
+ Documentation
72
+ </Tab>
73
+ </Tabs>
74
+ <TabPanels>
75
+ <TabPanel>
76
+ <ConfigurationPanel
77
+ settings={settings}
78
+ isSaving={isSaving}
79
+ isTesting={isTesting}
80
+ testResult={testResult}
81
+ onSave={onSave}
82
+ onTestConnection={onTestConnection}
83
+ onInputChange={onInputChange}
84
+ />
85
+ </TabPanel>
86
+
87
+ <TabPanel>
88
+ <HistoryPanel
89
+ filters={filters}
90
+ onFilterChange={onFilterChange}
91
+ onFilterApply={onFilterApply}
92
+ isLoadingHistory={isLoadingHistory}
93
+ transactionHistory={transactionHistory}
94
+ paginatedTransactions={paginatedTransactions}
95
+ currentPage={currentPage}
96
+ totalPages={totalPages}
97
+ pageSize={pageSize}
98
+ onRefresh={onRefresh}
99
+ onPageChange={onPageChange}
100
+ selectedTransaction={selectedTransaction}
101
+ onTransactionSelect={onTransactionSelect}
102
+ />
103
+ </TabPanel>
104
+
105
+ <TabPanel>
106
+ <PaymentActionsPanel
107
+ paymentAmount={paymentActions.paymentAmount}
108
+ setPaymentAmount={paymentActions.setPaymentAmount}
109
+ preauthReference={paymentActions.preauthReference}
110
+ setPreauthReference={paymentActions.setPreauthReference}
111
+ authReference={paymentActions.authReference}
112
+ setAuthReference={paymentActions.setAuthReference}
113
+ captureTxid={paymentActions.captureTxid}
114
+ setCaptureTxid={paymentActions.setCaptureTxid}
115
+ refundTxid={paymentActions.refundTxid}
116
+ setRefundTxid={paymentActions.setRefundTxid}
117
+ refundSequenceNumber={paymentActions.refundSequenceNumber}
118
+ setRefundSequenceNumber={paymentActions.setRefundSequenceNumber}
119
+ refundReference={paymentActions.refundReference}
120
+ setRefundReference={paymentActions.setRefundReference}
121
+ paymentMethod={paymentActions.paymentMethod}
122
+ setPaymentMethod={paymentActions.setPaymentMethod}
123
+ captureMode={paymentActions.captureMode}
124
+ setCaptureMode={paymentActions.setCaptureMode}
125
+ isProcessingPayment={paymentActions.isProcessingPayment}
126
+ paymentError={paymentActions.paymentError}
127
+ paymentResult={paymentActions.paymentResult}
128
+ onPreauthorization={paymentActions.handlePreauthorization}
129
+ onAuthorization={paymentActions.handleAuthorization}
130
+ onCapture={paymentActions.handleCapture}
131
+ onRefund={paymentActions.handleRefund}
132
+ settings={settings}
133
+ googlePayToken={paymentActions.googlePayToken}
134
+ setGooglePayToken={paymentActions.setGooglePayToken}
135
+ applePayToken={paymentActions.applePayToken}
136
+ setApplePayToken={paymentActions.setApplePayToken}
137
+ cardtype={paymentActions.cardtype}
138
+ setCardtype={paymentActions.setCardtype}
139
+ cardpan={paymentActions.cardpan}
140
+ setCardpan={paymentActions.setCardpan}
141
+ cardexpiredate={paymentActions.cardexpiredate}
142
+ setCardexpiredate={paymentActions.setCardexpiredate}
143
+ cardcvc2={paymentActions.cardcvc2}
144
+ setCardcvc2={paymentActions.setCardcvc2}
145
+ onNavigateToConfig={handleNavigateToConfig}
146
+ />
147
+ </TabPanel>
148
+
149
+ <TabPanel>
150
+ <DocsPanel />
151
+ </TabPanel>
152
+ </TabPanels>
153
+ </TabGroup>
154
+ );
155
+ };
156
+
157
+ export default AppTabs;
158
+
@@ -0,0 +1,304 @@
1
+ import React from "react";
2
+ import ApplePayButton from "apple-pay-button";
3
+ import { Box, Typography, Alert } from "@strapi/design-system";
4
+ import { request } from "@strapi/helper-plugin";
5
+ import pluginId from "../../../pluginId";
6
+
7
+ const ApplePayBtn = ({
8
+ amount,
9
+ onTokenReceived,
10
+ onError,
11
+ settings,
12
+ buttonStyle = "black",
13
+ type = "pay",
14
+ }) => {
15
+ const handleEventsForApplePay = (session, amountValue, currencyCode) => {
16
+ session.onvalidatemerchant = async (event) => {
17
+ try {
18
+ const merchantSession = await request(
19
+ `/${pluginId}/validate-apple-pay-merchant`,
20
+ {
21
+ method: "POST",
22
+ body: {
23
+ domain: window.location.hostname,
24
+ displayName: settings?.merchantName || "Store",
25
+ currency: currencyCode,
26
+ },
27
+ }
28
+ );
29
+
30
+ if (merchantSession.error) {
31
+ throw new Error(
32
+ merchantSession.error.message || "Merchant validation failed"
33
+ );
34
+ }
35
+
36
+ const sessionData = merchantSession.data || merchantSession;
37
+
38
+ if (!sessionData || !sessionData.merchantIdentifier) {
39
+ console.error(
40
+ "[Apple Pay Button] Invalid merchant session: missing merchantIdentifier"
41
+ );
42
+ throw new Error(
43
+ "Invalid merchant session: missing merchantIdentifier"
44
+ );
45
+ }
46
+
47
+ session.completeMerchantValidation(sessionData);
48
+ console.log(
49
+ "[Apple Pay Button] Merchant validation completed successfully"
50
+ );
51
+ } catch (error) {
52
+ console.error("[Apple Pay Button] Merchant validation error:", error);
53
+ if (onError) {
54
+ onError(error);
55
+ }
56
+ session.completeMerchantValidation({});
57
+ }
58
+ };
59
+
60
+ session.onpaymentmethodselected = (event) => {
61
+ const update = {
62
+ newTotal: {
63
+ label: settings?.merchantName || "Total",
64
+ type: "final",
65
+ amount: amountValue,
66
+ },
67
+ };
68
+ session.completePaymentMethodSelection(update);
69
+ };
70
+
71
+ session.onshippingmethodselected = (event) => {
72
+ const update = {
73
+ newTotal: {
74
+ label: settings?.merchantName || "Total",
75
+ type: "final",
76
+ amount: amountValue,
77
+ },
78
+ };
79
+ session.completeShippingMethodSelection(update);
80
+ };
81
+
82
+ session.onshippingcontactselected = (event) => {
83
+ const update = {
84
+ newTotal: {
85
+ label: settings?.merchantName || "Total",
86
+ type: "final",
87
+ amount: amountValue,
88
+ },
89
+ };
90
+ session.completeShippingContactSelection(update);
91
+ };
92
+
93
+ session.onpaymentauthorized = async (event) => {
94
+ try {
95
+ const paymentData = event.payment;
96
+
97
+ if (!paymentData || !paymentData.token) {
98
+ const result = {
99
+ status: window.ApplePaySession.STATUS_FAILURE,
100
+ };
101
+ session.completePayment(result);
102
+ if (onError) {
103
+ onError(new Error("Payment token is missing"));
104
+ }
105
+ return;
106
+ }
107
+
108
+ const tokenObject = paymentData.token;
109
+
110
+ if (!tokenObject.paymentData) {
111
+ console.error(
112
+ "[Apple Pay] Invalid token structure: missing paymentData"
113
+ );
114
+ const result = {
115
+ status: window.ApplePaySession.STATUS_FAILURE,
116
+ };
117
+ session.completePayment(result);
118
+ if (onError) {
119
+ onError(new Error("Invalid Apple Pay token structure"));
120
+ }
121
+ return;
122
+ }
123
+
124
+ // Encode token as Base64 for transmission
125
+ let tokenString;
126
+ try {
127
+ tokenString = btoa(
128
+ unescape(encodeURIComponent(JSON.stringify(tokenObject)))
129
+ );
130
+ } catch (e) {
131
+ console.error("[Apple Pay] Token encoding error:", e);
132
+ tokenString = btoa(
133
+ unescape(encodeURIComponent(JSON.stringify(tokenObject)))
134
+ );
135
+ }
136
+
137
+ if (onTokenReceived) {
138
+ const result = await onTokenReceived(tokenString, {
139
+ paymentToken: tokenObject,
140
+ billingContact: paymentData.billingContact,
141
+ shippingContact: paymentData.shippingContact,
142
+ amount: amountValue, //
143
+ currency: currencyCode,
144
+ });
145
+
146
+ if (result && typeof result.then === "function") {
147
+ await result;
148
+ }
149
+
150
+ const paymentResult = {
151
+ status: window.ApplePaySession.STATUS_SUCCESS,
152
+ };
153
+ session.completePayment(paymentResult);
154
+ } else {
155
+ const paymentResult = {
156
+ status: window.ApplePaySession.STATUS_SUCCESS,
157
+ };
158
+ session.completePayment(paymentResult);
159
+ }
160
+ } catch (error) {
161
+ console.error("[Apple Pay] Payment authorization error:", error);
162
+ const result = {
163
+ status: window.ApplePaySession.STATUS_FAILURE,
164
+ };
165
+ session.completePayment(result);
166
+ if (onError) {
167
+ onError(error);
168
+ }
169
+ }
170
+ };
171
+
172
+ session.oncancel = (event) => {
173
+ console.log("[Apple Pay Button] Session cancelled by user");
174
+ };
175
+ };
176
+
177
+ const handleApplePayClick = () => {
178
+ if (!settings?.mid) {
179
+ const error = new Error(
180
+ "Merchant ID is not configured. Please set Merchant ID in plugin settings."
181
+ );
182
+ if (onError) {
183
+ onError(error);
184
+ }
185
+ return;
186
+ }
187
+
188
+ if (typeof window === "undefined" || !window.ApplePaySession) {
189
+ if (onError) {
190
+ onError(new Error("Apple Pay is not supported in this environment."));
191
+ }
192
+ return;
193
+ }
194
+
195
+ const amountValue = amount ? (parseFloat(amount) / 100).toFixed(2) : "0.00";
196
+ const applePayConfig = settings?.applePayConfig || {};
197
+ const supportedNetworks = applePayConfig.supportedNetworks || [
198
+ "visa",
199
+ "masterCard",
200
+ "amex",
201
+ ];
202
+ const merchantCapabilities = applePayConfig.merchantCapabilities || [
203
+ "supports3DS",
204
+ ];
205
+ const currencyCode = applePayConfig.currencyCode || "EUR";
206
+ const countryCode = applePayConfig.countryCode || "DE";
207
+
208
+ const applePayRequest = {
209
+ countryCode: countryCode,
210
+ currencyCode: currencyCode,
211
+ merchantCapabilities: merchantCapabilities,
212
+ supportedNetworks: supportedNetworks,
213
+ total: {
214
+ label: settings?.merchantName || "Total",
215
+ type: "final",
216
+ amount: amountValue,
217
+ },
218
+ };
219
+
220
+ const session = new window.ApplePaySession(3, applePayRequest);
221
+
222
+ handleEventsForApplePay(session, amountValue, currencyCode);
223
+
224
+ session.begin();
225
+ };
226
+
227
+ const mode = (settings?.mode || 'test').toLowerCase();
228
+ const isLiveMode = mode === 'live';
229
+
230
+ if (!settings?.mid) {
231
+ return (
232
+ <Box>
233
+ <Alert closeLabel="Close" title="Merchant ID Missing" variant="warning">
234
+ <Typography variant="pi" marginTop={2}>
235
+ Merchant ID is not configured. Please set Merchant ID in plugin
236
+ settings. You can find your merchantIdentifier in PMI at:
237
+ CONFIGURATION → PAYMENT PORTALS → [Your Portal] → Payment type
238
+ configuration tab.
239
+ </Typography>
240
+ </Alert>
241
+ </Box>
242
+ );
243
+ }
244
+
245
+ if (!isLiveMode) {
246
+ return (
247
+ <Box>
248
+ <Alert closeLabel="Close" title="⚠️ Apple Pay Only Works in Live Mode" variant="danger">
249
+ <Typography variant="pi" marginTop={2}>
250
+ <strong>Apple Pay is only supported in live mode.</strong> According to Payone documentation, test mode support will be available at a later time.
251
+ </Typography>
252
+ <Typography variant="pi" marginTop={2}>
253
+ Please switch to <strong>live mode</strong> in plugin settings to use Apple Pay.
254
+ </Typography>
255
+ <Typography variant="pi" marginTop={2} fontWeight="bold" textColor="danger600">
256
+ ⚠️ Apple Pay will NOT work in test mode!
257
+ </Typography>
258
+ </Alert>
259
+ </Box>
260
+ );
261
+ }
262
+
263
+ const buttonStyleMap = {
264
+ black: "black",
265
+ white: "white",
266
+ "white-outline": "white-outline",
267
+ };
268
+
269
+ const buttonTypeMap = {
270
+ pay: "plain",
271
+ buy: "buy",
272
+ donate: "donate",
273
+ "check-out": "check-out",
274
+ book: "book",
275
+ subscribe: "subscribe",
276
+ };
277
+
278
+ const nativeButtonStyle = buttonStyleMap[buttonStyle] || "black";
279
+ const nativeButtonType = buttonTypeMap[type] || "plain";
280
+
281
+ return (
282
+ <Box style={{ minHeight: "40px", width: "100%" }}>
283
+ <ApplePayButton
284
+ onClick={handleApplePayClick}
285
+ buttonStyle={nativeButtonStyle}
286
+ type={nativeButtonType}
287
+ style={{
288
+ width: "100%",
289
+ borderRadius: "8px",
290
+ }}
291
+ />
292
+ <Typography
293
+ variant="pi"
294
+ textColor="neutral600"
295
+ style={{ fontSize: "12px", marginTop: "8px", marginRight: "6px" }}
296
+ >
297
+ Apple Pay does NOT work on localhost. Use a production domain with
298
+ HTTPS.
299
+ </Typography>
300
+ </Box>
301
+ );
302
+ };
303
+
304
+ export default ApplePayBtn;