strapi-plugin-payone-provider 1.4.1 → 1.5.0
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/APPLE_PAY_INTEGRATION.md +472 -0
- package/CSP_SETUP.md +184 -0
- package/HTTPS_REQUIREMENT.md +136 -0
- package/admin/src/pages/App/components/AppTabs.js +2 -0
- package/admin/src/pages/App/components/ApplePayButton.js +704 -0
- package/admin/src/pages/App/components/ApplePayConfig.js +305 -0
- package/admin/src/pages/App/components/PaymentActionsPanel.js +6 -0
- package/admin/src/pages/App/components/icons/BankIcon.js +10 -10
- package/admin/src/pages/App/components/icons/ChevronDownIcon.js +9 -9
- package/admin/src/pages/App/components/icons/ChevronUpIcon.js +9 -9
- package/admin/src/pages/App/components/icons/CreditCardIcon.js +9 -9
- package/admin/src/pages/App/components/icons/ErrorIcon.js +10 -10
- package/admin/src/pages/App/components/icons/InfoIcon.js +9 -9
- package/admin/src/pages/App/components/icons/PaymentIcon.js +10 -10
- package/admin/src/pages/App/components/icons/PendingIcon.js +9 -9
- package/admin/src/pages/App/components/icons/PersonIcon.js +9 -9
- package/admin/src/pages/App/components/icons/SuccessIcon.js +9 -9
- package/admin/src/pages/App/components/icons/WalletIcon.js +9 -9
- package/admin/src/pages/App/components/icons/index.js +11 -11
- package/admin/src/pages/App/components/paymentActions/AuthorizationForm.js +29 -2
- package/admin/src/pages/App/components/paymentActions/CaptureForm.js +1 -0
- package/admin/src/pages/App/components/paymentActions/CardDetailsInput.js +18 -16
- package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.js +44 -2
- package/admin/src/pages/App/components/paymentActions/RefundForm.js +1 -0
- package/admin/src/pages/hooks/usePaymentActions.js +25 -12
- package/admin/src/pages/utils/applePayConstants.js +222 -0
- package/admin/src/pages/utils/formatTransactionData.js +15 -15
- package/admin/src/pages/utils/paymentUtils.js +32 -69
- package/package.json +1 -1
- package/server/bootstrap.js +5 -1
- package/server/config/index.js +5 -1
- package/server/controllers/payone.js +10 -0
- package/server/routes/index.js +17 -0
- package/server/services/applePayService.js +261 -0
- package/server/services/paymentService.js +1 -7
- package/server/services/payone.js +10 -0
- package/server/utils/paymentMethodParams.js +19 -2
|
@@ -94,22 +94,24 @@ const CardDetailsInput = ({
|
|
|
94
94
|
return (
|
|
95
95
|
<Box>
|
|
96
96
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{card.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
<Flex direction="row" gap={2} alignItems="flex-start">
|
|
98
|
+
<Select
|
|
99
|
+
label="3D Secure Test Cards"
|
|
100
|
+
name="testCard"
|
|
101
|
+
value={selectedTestCard}
|
|
102
|
+
placeholder="Select a 3DS test card to auto-fill"
|
|
103
|
+
hint="These cards will trigger 3DS authentication redirect. Password: 12345"
|
|
104
|
+
onChange={handleTestCardSelect}
|
|
105
|
+
className="payment-input"
|
|
106
|
+
>
|
|
107
|
+
<Option value="">-- Select a test card --</Option>
|
|
108
|
+
{TEST_3DS_CARDS.map((card, index) => (
|
|
109
|
+
<Option key={index} value={`${card.cardtype}-${card.cardpan}`}>
|
|
110
|
+
{card.name} - {card.description}
|
|
111
|
+
</Option>
|
|
112
|
+
))}
|
|
113
|
+
</Select>
|
|
114
|
+
</Flex>
|
|
113
115
|
|
|
114
116
|
<Flex gap={4} wrap="wrap" alignItems="flex-start">
|
|
115
117
|
<Select
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Box, Flex, Typography, TextInput, Button } from "@strapi/design-system";
|
|
3
3
|
import { Play } from "@strapi/icons";
|
|
4
4
|
import GooglePayButton from "../GooglePaybutton";
|
|
5
|
+
import ApplePayButton from "../ApplePayButton";
|
|
5
6
|
import CardDetailsInput from "./CardDetailsInput";
|
|
6
7
|
|
|
7
8
|
const PreauthorizationForm = ({
|
|
@@ -15,6 +16,8 @@ const PreauthorizationForm = ({
|
|
|
15
16
|
settings,
|
|
16
17
|
googlePayToken,
|
|
17
18
|
setGooglePayToken,
|
|
19
|
+
applePayToken,
|
|
20
|
+
setApplePayToken,
|
|
18
21
|
cardtype,
|
|
19
22
|
setCardtype,
|
|
20
23
|
cardpan,
|
|
@@ -37,6 +40,20 @@ const PreauthorizationForm = ({
|
|
|
37
40
|
onError(error);
|
|
38
41
|
}
|
|
39
42
|
};
|
|
43
|
+
|
|
44
|
+
const handleApplePayToken = (token, paymentData) => {
|
|
45
|
+
if (!token) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setApplePayToken(token);
|
|
49
|
+
onPreauthorization(token);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleApplePayError = (error) => {
|
|
53
|
+
if (onError) {
|
|
54
|
+
onError(error);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
40
57
|
return (
|
|
41
58
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
42
59
|
<Flex direction="row" gap={2}>
|
|
@@ -73,8 +90,7 @@ const PreauthorizationForm = ({
|
|
|
73
90
|
/>
|
|
74
91
|
</Flex>
|
|
75
92
|
|
|
76
|
-
{
|
|
77
|
-
{paymentMethod === "cc" && settings?.enable3DSecure !== false && (
|
|
93
|
+
{paymentMethod === "cc" && settings?.enable3DSecure && (
|
|
78
94
|
<Box marginTop={4}>
|
|
79
95
|
<CardDetailsInput
|
|
80
96
|
cardtype={cardtype}
|
|
@@ -97,12 +113,38 @@ const PreauthorizationForm = ({
|
|
|
97
113
|
onError={handleGooglePayError}
|
|
98
114
|
settings={settings}
|
|
99
115
|
/>
|
|
116
|
+
) : paymentMethod === "apl" ? (
|
|
117
|
+
<Box>
|
|
118
|
+
<ApplePayButton
|
|
119
|
+
amount={paymentAmount}
|
|
120
|
+
currency="EUR"
|
|
121
|
+
onTokenReceived={handleApplePayToken}
|
|
122
|
+
onError={handleApplePayError}
|
|
123
|
+
settings={settings}
|
|
124
|
+
/>
|
|
125
|
+
<Box marginTop={3} style={{ width: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start", gap: "8px" }}>
|
|
126
|
+
<Typography variant="pi" textColor="neutral600" style={{ marginBottom: "8px" }}>
|
|
127
|
+
Apple Pay is not available on localhost. You can test the payment flow without Apple Pay token:
|
|
128
|
+
</Typography>
|
|
129
|
+
<Button
|
|
130
|
+
variant="secondary"
|
|
131
|
+
onClick={() => onPreauthorization(null)}
|
|
132
|
+
loading={isProcessingPayment}
|
|
133
|
+
startIcon={<Play />}
|
|
134
|
+
style={{ maxWidth: '200px' }}
|
|
135
|
+
disabled={!paymentAmount.trim() || !preauthReference.trim()}
|
|
136
|
+
>
|
|
137
|
+
Process Preauthorization
|
|
138
|
+
</Button>
|
|
139
|
+
</Box>
|
|
140
|
+
</Box>
|
|
100
141
|
) : (
|
|
101
142
|
<Button
|
|
102
143
|
variant="default"
|
|
103
144
|
onClick={onPreauthorization}
|
|
104
145
|
loading={isProcessingPayment}
|
|
105
146
|
startIcon={<Play />}
|
|
147
|
+
style={{ maxWidth: '200px' }}
|
|
106
148
|
className="payment-button payment-button-primary"
|
|
107
149
|
disabled={
|
|
108
150
|
!paymentAmount.trim() ||
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
getPreauthorizationParams,
|
|
6
6
|
getAuthorizationParams,
|
|
7
7
|
getCaptureParams,
|
|
8
|
-
getRefundParams
|
|
8
|
+
getRefundParams,
|
|
9
|
+
generateLagOrderNumber
|
|
9
10
|
} from "../utils/paymentUtils";
|
|
10
11
|
import { DEFAULT_PAYMENT_DATA } from "../constants/paymentConstants";
|
|
11
12
|
|
|
@@ -32,15 +33,16 @@ const usePaymentActions = () => {
|
|
|
32
33
|
// Payment form state
|
|
33
34
|
const [paymentAmount, setPaymentAmount] = useState("1000");
|
|
34
35
|
|
|
35
|
-
// Generate reference
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// Generate order reference using generateLagOrderNumber
|
|
37
|
+
// Sequence number starts from 1000 and increments based on timestamp
|
|
38
|
+
const generateOrderReference = () => {
|
|
39
|
+
// Use timestamp to generate unique sequence (1000 to 99999 range)
|
|
40
|
+
const sequence = 1000 + Math.floor((Date.now() % 99000));
|
|
41
|
+
return generateLagOrderNumber(sequence);
|
|
40
42
|
};
|
|
41
43
|
|
|
42
|
-
const [preauthReference, setPreauthReference] = useState(
|
|
43
|
-
const [authReference, setAuthReference] = useState(
|
|
44
|
+
const [preauthReference, setPreauthReference] = useState(generateOrderReference());
|
|
45
|
+
const [authReference, setAuthReference] = useState(generateOrderReference());
|
|
44
46
|
const [captureTxid, setCaptureTxid] = useState("");
|
|
45
47
|
const [refundTxid, setRefundTxid] = useState("");
|
|
46
48
|
const [refundSequenceNumber, setRefundSequenceNumber] = useState("2");
|
|
@@ -48,6 +50,7 @@ const usePaymentActions = () => {
|
|
|
48
50
|
const [paymentMethod, setPaymentMethod] = useState("cc");
|
|
49
51
|
const [captureMode, setCaptureMode] = useState("full");
|
|
50
52
|
const [googlePayToken, setGooglePayToken] = useState(null);
|
|
53
|
+
const [applePayToken, setApplePayToken] = useState(null);
|
|
51
54
|
|
|
52
55
|
// Card details for 3DS testing
|
|
53
56
|
const [cardtype, setCardtype] = useState("");
|
|
@@ -85,7 +88,7 @@ const usePaymentActions = () => {
|
|
|
85
88
|
setPaymentResult(null);
|
|
86
89
|
try {
|
|
87
90
|
// Auto-generate reference if empty
|
|
88
|
-
const finalPreauthReference = preauthReference.trim() ||
|
|
91
|
+
const finalPreauthReference = preauthReference.trim() || generateOrderReference();
|
|
89
92
|
if (!preauthReference.trim()) {
|
|
90
93
|
setPreauthReference(finalPreauthReference);
|
|
91
94
|
}
|
|
@@ -127,10 +130,13 @@ const usePaymentActions = () => {
|
|
|
127
130
|
baseParams.backurl = `${baseUrl}${basePath}${pluginPath}/back`;
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
const tokenToUse = tokenParam || googlePayToken;
|
|
133
|
+
const tokenToUse = tokenParam || googlePayToken || applePayToken;
|
|
131
134
|
if (paymentMethod === "gpp" && tokenToUse) {
|
|
132
135
|
baseParams.googlePayToken = tokenToUse;
|
|
133
136
|
baseParams.settings = settings;
|
|
137
|
+
} else if (paymentMethod === "apl" && tokenToUse) {
|
|
138
|
+
baseParams.applePayToken = tokenToUse;
|
|
139
|
+
baseParams.settings = settings;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
const params = getPreauthorizationParams(paymentMethod, baseParams);
|
|
@@ -227,7 +233,7 @@ const usePaymentActions = () => {
|
|
|
227
233
|
|
|
228
234
|
try {
|
|
229
235
|
// Auto-generate reference if empty
|
|
230
|
-
const finalAuthReference = authReference.trim() ||
|
|
236
|
+
const finalAuthReference = authReference.trim() || generateOrderReference();
|
|
231
237
|
if (!authReference.trim()) {
|
|
232
238
|
setAuthReference(finalAuthReference);
|
|
233
239
|
}
|
|
@@ -269,10 +275,13 @@ const usePaymentActions = () => {
|
|
|
269
275
|
baseParams.backurl = `${baseUrl}${basePath}${pluginPath}/back`;
|
|
270
276
|
}
|
|
271
277
|
|
|
272
|
-
const tokenToUse = tokenParam || googlePayToken;
|
|
278
|
+
const tokenToUse = tokenParam || googlePayToken || applePayToken;
|
|
273
279
|
if (paymentMethod === "gpp" && tokenToUse) {
|
|
274
280
|
baseParams.googlePayToken = tokenToUse;
|
|
275
281
|
baseParams.settings = settings;
|
|
282
|
+
} else if (paymentMethod === "apl" && tokenToUse) {
|
|
283
|
+
baseParams.applePayToken = tokenToUse;
|
|
284
|
+
baseParams.settings = settings;
|
|
276
285
|
}
|
|
277
286
|
|
|
278
287
|
const params = getAuthorizationParams(paymentMethod, baseParams);
|
|
@@ -452,6 +461,10 @@ const usePaymentActions = () => {
|
|
|
452
461
|
googlePayToken,
|
|
453
462
|
setGooglePayToken,
|
|
454
463
|
|
|
464
|
+
// Apple Pay
|
|
465
|
+
applePayToken,
|
|
466
|
+
setApplePayToken,
|
|
467
|
+
|
|
455
468
|
// Card details for 3DS
|
|
456
469
|
cardtype,
|
|
457
470
|
setCardtype,
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Pay Constants
|
|
3
|
+
* Based on Apple Pay documentation and Payone requirements
|
|
4
|
+
* https://developer.apple.com/documentation/applepayontheweb
|
|
5
|
+
* https://docs.payone.com/payment-methods/apple-pay/apple-pay-without-dev
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Apple Pay supported countries
|
|
9
|
+
// Note: Apple Pay availability varies by country
|
|
10
|
+
export const APPLE_PAY_SUPPORTED_COUNTRIES = [
|
|
11
|
+
{ code: "US", name: "United States" },
|
|
12
|
+
{ code: "GB", name: "United Kingdom" },
|
|
13
|
+
{ code: "CA", name: "Canada" },
|
|
14
|
+
{ code: "AU", name: "Australia" },
|
|
15
|
+
{ code: "DE", name: "Germany" },
|
|
16
|
+
{ code: "FR", name: "France" },
|
|
17
|
+
{ code: "IT", name: "Italy" },
|
|
18
|
+
{ code: "ES", name: "Spain" },
|
|
19
|
+
{ code: "NL", name: "Netherlands" },
|
|
20
|
+
{ code: "BE", name: "Belgium" },
|
|
21
|
+
{ code: "CH", name: "Switzerland" },
|
|
22
|
+
{ code: "AT", name: "Austria" },
|
|
23
|
+
{ code: "IE", name: "Ireland" },
|
|
24
|
+
{ code: "SE", name: "Sweden" },
|
|
25
|
+
{ code: "NO", name: "Norway" },
|
|
26
|
+
{ code: "DK", name: "Denmark" },
|
|
27
|
+
{ code: "FI", name: "Finland" },
|
|
28
|
+
{ code: "PL", name: "Poland" },
|
|
29
|
+
{ code: "CZ", name: "Czech Republic" },
|
|
30
|
+
{ code: "HU", name: "Hungary" },
|
|
31
|
+
{ code: "PT", name: "Portugal" },
|
|
32
|
+
{ code: "GR", name: "Greece" },
|
|
33
|
+
{ code: "JP", name: "Japan" },
|
|
34
|
+
{ code: "CN", name: "China" },
|
|
35
|
+
{ code: "HK", name: "Hong Kong" },
|
|
36
|
+
{ code: "TW", name: "Taiwan" },
|
|
37
|
+
{ code: "SG", name: "Singapore" },
|
|
38
|
+
{ code: "NZ", name: "New Zealand" },
|
|
39
|
+
{ code: "BR", name: "Brazil" },
|
|
40
|
+
{ code: "MX", name: "Mexico" },
|
|
41
|
+
{ code: "AE", name: "United Arab Emirates" },
|
|
42
|
+
{ code: "SA", name: "Saudi Arabia" },
|
|
43
|
+
{ code: "RU", name: "Russia" },
|
|
44
|
+
{ code: "UA", name: "Ukraine" },
|
|
45
|
+
{ code: "TR", name: "Turkey" },
|
|
46
|
+
{ code: "ZA", name: "South Africa" }
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
// Apple Pay supported currencies
|
|
50
|
+
// Note: Some currencies may be restricted in certain countries
|
|
51
|
+
export const APPLE_PAY_SUPPORTED_CURRENCIES = [
|
|
52
|
+
{ code: "USD", name: "US Dollar", symbol: "$" },
|
|
53
|
+
{ code: "EUR", name: "Euro", symbol: "€" },
|
|
54
|
+
{ code: "GBP", name: "British Pound", symbol: "£" },
|
|
55
|
+
{ code: "CAD", name: "Canadian Dollar", symbol: "C$" },
|
|
56
|
+
{ code: "AUD", name: "Australian Dollar", symbol: "A$" },
|
|
57
|
+
{ code: "JPY", name: "Japanese Yen", symbol: "¥" },
|
|
58
|
+
{ code: "CNY", name: "Chinese Yuan", symbol: "¥" },
|
|
59
|
+
{ code: "HKD", name: "Hong Kong Dollar", symbol: "HK$" },
|
|
60
|
+
{ code: "TWD", name: "Taiwan Dollar", symbol: "NT$" },
|
|
61
|
+
{ code: "SGD", name: "Singapore Dollar", symbol: "S$" },
|
|
62
|
+
{ code: "NZD", name: "New Zealand Dollar", symbol: "NZ$" },
|
|
63
|
+
{ code: "BRL", name: "Brazilian Real", symbol: "R$" },
|
|
64
|
+
{ code: "MXN", name: "Mexican Peso", symbol: "Mex$" },
|
|
65
|
+
{ code: "AED", name: "UAE Dirham", symbol: "د.إ" },
|
|
66
|
+
{ code: "SAR", name: "Saudi Riyal", symbol: "﷼" },
|
|
67
|
+
{ code: "RUB", name: "Russian Ruble", symbol: "₽" },
|
|
68
|
+
{ code: "UAH", name: "Ukrainian Hryvnia", symbol: "₴" },
|
|
69
|
+
{ code: "TRY", name: "Turkish Lira", symbol: "₺" },
|
|
70
|
+
{ code: "ZAR", name: "South African Rand", symbol: "R" },
|
|
71
|
+
{ code: "CHF", name: "Swiss Franc", symbol: "CHF" },
|
|
72
|
+
{ code: "SEK", name: "Swedish Krona", symbol: "kr" },
|
|
73
|
+
{ code: "NOK", name: "Norwegian Krone", symbol: "kr" },
|
|
74
|
+
{ code: "DKK", name: "Danish Krone", symbol: "kr" },
|
|
75
|
+
{ code: "PLN", name: "Polish Zloty", symbol: "zł" },
|
|
76
|
+
{ code: "CZK", name: "Czech Koruna", symbol: "Kč" },
|
|
77
|
+
{ code: "HUF", name: "Hungarian Forint", symbol: "Ft" }
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
// Apple Pay supported payment networks
|
|
81
|
+
export const APPLE_PAY_SUPPORTED_NETWORKS = [
|
|
82
|
+
{ code: "amex", name: "American Express" },
|
|
83
|
+
{ code: "discover", name: "Discover" },
|
|
84
|
+
{ code: "masterCard", name: "Mastercard" },
|
|
85
|
+
{ code: "visa", name: "Visa" },
|
|
86
|
+
{ code: "maestro", name: "Maestro" },
|
|
87
|
+
{ code: "girocard", name: "Girocard" },
|
|
88
|
+
{ code: "cartesBancaires", name: "Cartes Bancaires" },
|
|
89
|
+
{ code: "chinaUnionPay", name: "China UnionPay" },
|
|
90
|
+
{ code: "jcb", name: "JCB" },
|
|
91
|
+
{ code: "interac", name: "Interac" },
|
|
92
|
+
{ code: "privateLabel", name: "Private Label" }
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
// Merchant capabilities
|
|
96
|
+
export const APPLE_PAY_MERCHANT_CAPABILITIES = [
|
|
97
|
+
{ code: "supports3DS", name: "3D Secure", description: "Required for most payment methods" },
|
|
98
|
+
{ code: "supportsCredit", name: "Credit Cards", description: "Support credit card payments" },
|
|
99
|
+
{ code: "supportsDebit", name: "Debit Cards", description: "Support debit card payments" }
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
// Country-currency restrictions
|
|
103
|
+
// Some currencies are not available in certain countries
|
|
104
|
+
export const COUNTRY_CURRENCY_RESTRICTIONS = {
|
|
105
|
+
US: ["USD"],
|
|
106
|
+
GB: ["GBP", "EUR"],
|
|
107
|
+
CA: ["CAD", "USD"],
|
|
108
|
+
AU: ["AUD"],
|
|
109
|
+
DE: ["EUR"],
|
|
110
|
+
FR: ["EUR"],
|
|
111
|
+
IT: ["EUR"],
|
|
112
|
+
ES: ["EUR"],
|
|
113
|
+
JP: ["JPY"],
|
|
114
|
+
CN: ["CNY"],
|
|
115
|
+
HK: ["HKD"],
|
|
116
|
+
TW: ["TWD"],
|
|
117
|
+
SG: ["SGD"],
|
|
118
|
+
NZ: ["NZD"],
|
|
119
|
+
BR: ["BRL"],
|
|
120
|
+
MX: ["MXN"],
|
|
121
|
+
AE: ["AED"],
|
|
122
|
+
SA: ["SAR"],
|
|
123
|
+
RU: ["RUB", "USD", "EUR"],
|
|
124
|
+
UA: ["UAH", "USD", "EUR"],
|
|
125
|
+
TR: ["TRY", "USD", "EUR"],
|
|
126
|
+
ZA: ["ZAR"]
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Get supported currencies for a country
|
|
130
|
+
export const getSupportedCurrenciesForCountry = (countryCode) => {
|
|
131
|
+
const restrictions = COUNTRY_CURRENCY_RESTRICTIONS[countryCode];
|
|
132
|
+
if (restrictions) {
|
|
133
|
+
return APPLE_PAY_SUPPORTED_CURRENCIES.filter(currency =>
|
|
134
|
+
restrictions.includes(currency.code)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
// Default: return all currencies if no restrictions
|
|
138
|
+
return APPLE_PAY_SUPPORTED_CURRENCIES;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Get supported networks for a country
|
|
142
|
+
// Some networks are country-specific
|
|
143
|
+
export const getSupportedNetworksForCountry = (countryCode) => {
|
|
144
|
+
const countryNetworks = {
|
|
145
|
+
US: ["amex", "discover", "masterCard", "visa"],
|
|
146
|
+
GB: ["amex", "masterCard", "visa", "maestro"],
|
|
147
|
+
DE: ["masterCard", "visa", "girocard", "maestro"],
|
|
148
|
+
FR: ["masterCard", "visa", "cartesBancaires"],
|
|
149
|
+
CN: ["chinaUnionPay", "visa", "masterCard"],
|
|
150
|
+
JP: ["jcb", "visa", "masterCard", "amex"],
|
|
151
|
+
CA: ["visa", "masterCard", "amex", "interac"],
|
|
152
|
+
AU: ["visa", "masterCard", "amex"],
|
|
153
|
+
// Default networks for other countries
|
|
154
|
+
default: ["visa", "masterCard", "amex"]
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return countryNetworks[countryCode] || countryNetworks.default;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Test data for Apple Pay
|
|
161
|
+
// Based on Apple Pay sandbox testing documentation
|
|
162
|
+
export const APPLE_PAY_TEST_DATA = {
|
|
163
|
+
// Test card numbers (for sandbox testing)
|
|
164
|
+
testCards: {
|
|
165
|
+
visa: "4111111111111111",
|
|
166
|
+
mastercard: "5555555555554444",
|
|
167
|
+
amex: "378282246310005",
|
|
168
|
+
discover: "6011111111111117"
|
|
169
|
+
},
|
|
170
|
+
// Test merchant identifiers (for development)
|
|
171
|
+
testMerchantIdentifier: "merchant.com.payone.test",
|
|
172
|
+
// Test domain
|
|
173
|
+
testDomain: "test.payone.com"
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Apple Pay button styles
|
|
177
|
+
export const APPLE_PAY_BUTTON_STYLES = [
|
|
178
|
+
{ code: "black", name: "Black" },
|
|
179
|
+
{ code: "white", name: "White with outline" },
|
|
180
|
+
{ code: "white-outline", name: "White" }
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
// Apple Pay button types
|
|
184
|
+
export const APPLE_PAY_BUTTON_TYPES = [
|
|
185
|
+
{ code: "plain", name: "Plain" },
|
|
186
|
+
{ code: "buy", name: "Buy" },
|
|
187
|
+
{ code: "donate", name: "Donate" },
|
|
188
|
+
{ code: "check-out", name: "Check Out" },
|
|
189
|
+
{ code: "book", name: "Book" },
|
|
190
|
+
{ code: "subscribe", name: "Subscribe" },
|
|
191
|
+
{ code: "reload", name: "Reload" },
|
|
192
|
+
{ code: "add-money", name: "Add Money" },
|
|
193
|
+
{ code: "top-up", name: "Top Up" },
|
|
194
|
+
{ code: "order", name: "Order" },
|
|
195
|
+
{ code: "rent", name: "Rent" },
|
|
196
|
+
{ code: "support", name: "Support" },
|
|
197
|
+
{ code: "contribute", name: "Contribute" },
|
|
198
|
+
{ code: "tip", name: "Tip" },
|
|
199
|
+
{ code: "continue", name: "Continue" },
|
|
200
|
+
{ code: "pay", name: "Pay" },
|
|
201
|
+
{ code: "set-up", name: "Set Up" }
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
// Default Apple Pay configuration
|
|
205
|
+
export const DEFAULT_APPLE_PAY_CONFIG = {
|
|
206
|
+
countryCode: "DE",
|
|
207
|
+
currencyCode: "EUR",
|
|
208
|
+
merchantCapabilities: ["supports3DS"],
|
|
209
|
+
supportedNetworks: ["visa", "masterCard", "girocard"],
|
|
210
|
+
buttonStyle: "black",
|
|
211
|
+
buttonType: "pay",
|
|
212
|
+
requestPayerName: false,
|
|
213
|
+
requestBillingAddress: false,
|
|
214
|
+
requestPayerEmail: false,
|
|
215
|
+
requestPayerPhone: false,
|
|
216
|
+
requestShipping: false,
|
|
217
|
+
shippingType: "shipping"
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export const formatTransactionData = (data) => {
|
|
2
|
-
const formattedData = [];
|
|
3
|
-
if (!data || typeof data !== "object") return formattedData;
|
|
4
|
-
|
|
5
|
-
for (const [key, value] of Object.entries(data)) {
|
|
6
|
-
if (value !== null && value !== undefined) {
|
|
7
|
-
formattedData.push({
|
|
8
|
-
key:
|
|
9
|
-
key.charAt(0).toUpperCase() + key.slice(1).replace(/([A-Z])/g, " $1"),
|
|
10
|
-
value: typeof value === "object" ? JSON.stringify(value) : String(value)
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return formattedData;
|
|
1
|
+
export const formatTransactionData = (data) => {
|
|
2
|
+
const formattedData = [];
|
|
3
|
+
if (!data || typeof data !== "object") return formattedData;
|
|
4
|
+
|
|
5
|
+
for (const [key, value] of Object.entries(data)) {
|
|
6
|
+
if (value !== null && value !== undefined) {
|
|
7
|
+
formattedData.push({
|
|
8
|
+
key:
|
|
9
|
+
key.charAt(0).toUpperCase() + key.slice(1).replace(/([A-Z])/g, " $1"),
|
|
10
|
+
value: typeof value === "object" ? JSON.stringify(value) : String(value)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return formattedData;
|
|
16
16
|
};
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Payment Utils - Universal functions for different payment methods and operations
|
|
3
|
-
* Based on Payone v1 API Documentation
|
|
4
|
-
*
|
|
5
|
-
* This file contains all necessary parameters and validations for:
|
|
6
|
-
* - Preauthorization
|
|
7
|
-
* - Authorization
|
|
8
|
-
* - Capture
|
|
9
|
-
* - Refund
|
|
10
|
-
*
|
|
11
|
-
* Supported Payment Methods:
|
|
12
|
-
* - Credit Card (cc)
|
|
13
|
-
* - PayPal (wlt)
|
|
14
|
-
* - Google Pay (gpp)
|
|
15
|
-
* - Apple Pay (apl)
|
|
16
|
-
* - Sofort Banking (sb)
|
|
17
|
-
* - SEPA Direct Debit (elv)
|
|
18
|
-
*/
|
|
19
1
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
export function generateLagOrderNumber(sequence = 1000) {
|
|
3
|
+
const paddedSequence = sequence.toString().padStart(5, '0');
|
|
4
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
5
|
+
let randomPart = '';
|
|
6
|
+
for (let i = 0; i < 4; i++) {
|
|
7
|
+
randomPart += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
8
|
+
}
|
|
9
|
+
return `ORD-${paddedSequence}-${randomPart}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
26
13
|
export const getBaseParams = (options = {}) => {
|
|
27
14
|
const {
|
|
28
15
|
amount,
|
|
@@ -91,13 +78,7 @@ export const getBaseParams = (options = {}) => {
|
|
|
91
78
|
};
|
|
92
79
|
};
|
|
93
80
|
|
|
94
|
-
|
|
95
|
-
* Get payment method specific parameters
|
|
96
|
-
* Based on Payone v1 API Documentation
|
|
97
|
-
* @param {string} paymentMethod - Payment method (cc, wlt, sb, elv)
|
|
98
|
-
* @param {Object} options - Additional options
|
|
99
|
-
* @returns {Object} Payment method specific parameters
|
|
100
|
-
*/
|
|
81
|
+
|
|
101
82
|
export const getPaymentMethodParams = (paymentMethod, options = {}) => {
|
|
102
83
|
const {
|
|
103
84
|
cardType,
|
|
@@ -176,12 +157,25 @@ export const getPaymentMethodParams = (paymentMethod, options = {}) => {
|
|
|
176
157
|
return googlePayParams;
|
|
177
158
|
|
|
178
159
|
case "apl": // Apple Pay
|
|
179
|
-
|
|
160
|
+
const applePayParams = {
|
|
180
161
|
clearingtype: "wlt",
|
|
181
162
|
wallettype: "APL", // Apple Pay
|
|
182
163
|
...getShippingParams()
|
|
183
164
|
};
|
|
184
165
|
|
|
166
|
+
if (options.applePayToken) {
|
|
167
|
+
const gatewayMerchantId = options.settings?.mid || options.settings?.portalid || '';
|
|
168
|
+
applePayParams["add_paydata[paymentmethod_token_data]"] = options.applePayToken;
|
|
169
|
+
applePayParams["add_paydata[paymentmethod]"] = "APL";
|
|
170
|
+
applePayParams["add_paydata[paymentmethod_type]"] = "APPLEPAY";
|
|
171
|
+
applePayParams["add_paydata[gatewayid]"] = "payonegmbh";
|
|
172
|
+
if (gatewayMerchantId) {
|
|
173
|
+
applePayParams["add_paydata[gateway_merchantid]"] = gatewayMerchantId;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return applePayParams;
|
|
178
|
+
|
|
185
179
|
case "sb": // Sofort Banking
|
|
186
180
|
return {
|
|
187
181
|
clearingtype: "sb",
|
|
@@ -210,13 +204,7 @@ export const getPaymentMethodParams = (paymentMethod, options = {}) => {
|
|
|
210
204
|
}
|
|
211
205
|
};
|
|
212
206
|
|
|
213
|
-
|
|
214
|
-
* Get preauthorization parameters for specific payment method
|
|
215
|
-
* Based on Payone v1 API Documentation
|
|
216
|
-
* @param {string} paymentMethod - Payment method
|
|
217
|
-
* @param {Object} options - Options including amount, reference, etc.
|
|
218
|
-
* @returns {Object} Complete preauthorization parameters
|
|
219
|
-
*/
|
|
207
|
+
|
|
220
208
|
export const getPreauthorizationParams = (paymentMethod, options = {}) => {
|
|
221
209
|
const baseParams = getBaseParams(options);
|
|
222
210
|
const methodParams = getPaymentMethodParams(paymentMethod, options);
|
|
@@ -236,13 +224,7 @@ export const getPreauthorizationParams = (paymentMethod, options = {}) => {
|
|
|
236
224
|
return params;
|
|
237
225
|
};
|
|
238
226
|
|
|
239
|
-
|
|
240
|
-
* Get authorization parameters for specific payment method
|
|
241
|
-
* Based on Payone v1 API Documentation
|
|
242
|
-
* @param {string} paymentMethod - Payment method
|
|
243
|
-
* @param {Object} options - Options including amount, reference, etc.
|
|
244
|
-
* @returns {Object} Complete authorization parameters
|
|
245
|
-
*/
|
|
227
|
+
|
|
246
228
|
export const getAuthorizationParams = (paymentMethod, options = {}) => {
|
|
247
229
|
const baseParams = getBaseParams(options);
|
|
248
230
|
const methodParams = getPaymentMethodParams(paymentMethod, options);
|
|
@@ -262,13 +244,7 @@ export const getAuthorizationParams = (paymentMethod, options = {}) => {
|
|
|
262
244
|
return params;
|
|
263
245
|
};
|
|
264
246
|
|
|
265
|
-
|
|
266
|
-
* Get capture parameters for specific payment method
|
|
267
|
-
* Based on Payone v1 API Documentation
|
|
268
|
-
* @param {string} paymentMethod - Payment method
|
|
269
|
-
* @param {Object} options - Options including txid, amount, captureMode, etc.
|
|
270
|
-
* @returns {Object} Complete capture parameters
|
|
271
|
-
*/
|
|
247
|
+
|
|
272
248
|
export const getCaptureParams = (paymentMethod, options = {}) => {
|
|
273
249
|
const {
|
|
274
250
|
txid,
|
|
@@ -324,13 +300,7 @@ export const getCaptureParams = (paymentMethod, options = {}) => {
|
|
|
324
300
|
};
|
|
325
301
|
};
|
|
326
302
|
|
|
327
|
-
|
|
328
|
-
* Get refund parameters for specific payment method
|
|
329
|
-
* Based on Payone v1 API Documentation
|
|
330
|
-
* @param {string} paymentMethod - Payment method
|
|
331
|
-
* @param {Object} options - Options including txid, amount, sequencenumber, etc.
|
|
332
|
-
* @returns {Object} Complete refund parameters
|
|
333
|
-
*/
|
|
303
|
+
|
|
334
304
|
export const getRefundParams = (paymentMethod, options = {}) => {
|
|
335
305
|
const {
|
|
336
306
|
txid,
|
|
@@ -383,11 +353,7 @@ export const getRefundParams = (paymentMethod, options = {}) => {
|
|
|
383
353
|
};
|
|
384
354
|
};
|
|
385
355
|
|
|
386
|
-
|
|
387
|
-
* Get payment method display name
|
|
388
|
-
* @param {string} paymentMethod - Payment method code
|
|
389
|
-
* @returns {string} Display name
|
|
390
|
-
*/
|
|
356
|
+
|
|
391
357
|
export const getPaymentMethodDisplayName = (paymentMethod) => {
|
|
392
358
|
const displayNames = {
|
|
393
359
|
cc: "Credit Card (Visa, Mastercard)",
|
|
@@ -401,10 +367,7 @@ export const getPaymentMethodDisplayName = (paymentMethod) => {
|
|
|
401
367
|
return displayNames[paymentMethod] || "Unknown Payment Method";
|
|
402
368
|
};
|
|
403
369
|
|
|
404
|
-
|
|
405
|
-
* Get payment method options for dropdown
|
|
406
|
-
* @returns {Array} Array of payment method options
|
|
407
|
-
*/
|
|
370
|
+
|
|
408
371
|
export const getPaymentMethodOptions = () => {
|
|
409
372
|
return [
|
|
410
373
|
{ value: "cc", label: "Credit Card (Visa, Mastercard)" },
|
package/package.json
CHANGED
package/server/bootstrap.js
CHANGED