strapi-plugin-payone-provider 1.4.2 → 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.
@@ -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,27 +1,4 @@
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
- * Generate order reference number
22
- * @param {number} sequence - Sequence number (default: 1000)
23
- * @returns {string} Generated order reference (format: ORD-XXXXX-XXXX)
24
- */
25
2
  export function generateLagOrderNumber(sequence = 1000) {
26
3
  const paddedSequence = sequence.toString().padStart(5, '0');
27
4
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
@@ -32,12 +9,7 @@ export function generateLagOrderNumber(sequence = 1000) {
32
9
  return `ORD-${paddedSequence}-${randomPart}`;
33
10
  }
34
11
 
35
- /**
36
- * Get base parameters for all payment methods
37
- * Based on Payone v1 API Documentation
38
- * @param {Object} options - Base options
39
- * @returns {Object} Base parameters with all required fields
40
- */
12
+
41
13
  export const getBaseParams = (options = {}) => {
42
14
  const {
43
15
  amount,
@@ -106,13 +78,7 @@ export const getBaseParams = (options = {}) => {
106
78
  };
107
79
  };
108
80
 
109
- /**
110
- * Get payment method specific parameters
111
- * Based on Payone v1 API Documentation
112
- * @param {string} paymentMethod - Payment method (cc, wlt, sb, elv)
113
- * @param {Object} options - Additional options
114
- * @returns {Object} Payment method specific parameters
115
- */
81
+
116
82
  export const getPaymentMethodParams = (paymentMethod, options = {}) => {
117
83
  const {
118
84
  cardType,
@@ -191,12 +157,25 @@ export const getPaymentMethodParams = (paymentMethod, options = {}) => {
191
157
  return googlePayParams;
192
158
 
193
159
  case "apl": // Apple Pay
194
- return {
160
+ const applePayParams = {
195
161
  clearingtype: "wlt",
196
162
  wallettype: "APL", // Apple Pay
197
163
  ...getShippingParams()
198
164
  };
199
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
+
200
179
  case "sb": // Sofort Banking
201
180
  return {
202
181
  clearingtype: "sb",
@@ -225,13 +204,7 @@ export const getPaymentMethodParams = (paymentMethod, options = {}) => {
225
204
  }
226
205
  };
227
206
 
228
- /**
229
- * Get preauthorization parameters for specific payment method
230
- * Based on Payone v1 API Documentation
231
- * @param {string} paymentMethod - Payment method
232
- * @param {Object} options - Options including amount, reference, etc.
233
- * @returns {Object} Complete preauthorization parameters
234
- */
207
+
235
208
  export const getPreauthorizationParams = (paymentMethod, options = {}) => {
236
209
  const baseParams = getBaseParams(options);
237
210
  const methodParams = getPaymentMethodParams(paymentMethod, options);
@@ -251,13 +224,7 @@ export const getPreauthorizationParams = (paymentMethod, options = {}) => {
251
224
  return params;
252
225
  };
253
226
 
254
- /**
255
- * Get authorization parameters for specific payment method
256
- * Based on Payone v1 API Documentation
257
- * @param {string} paymentMethod - Payment method
258
- * @param {Object} options - Options including amount, reference, etc.
259
- * @returns {Object} Complete authorization parameters
260
- */
227
+
261
228
  export const getAuthorizationParams = (paymentMethod, options = {}) => {
262
229
  const baseParams = getBaseParams(options);
263
230
  const methodParams = getPaymentMethodParams(paymentMethod, options);
@@ -277,13 +244,7 @@ export const getAuthorizationParams = (paymentMethod, options = {}) => {
277
244
  return params;
278
245
  };
279
246
 
280
- /**
281
- * Get capture parameters for specific payment method
282
- * Based on Payone v1 API Documentation
283
- * @param {string} paymentMethod - Payment method
284
- * @param {Object} options - Options including txid, amount, captureMode, etc.
285
- * @returns {Object} Complete capture parameters
286
- */
247
+
287
248
  export const getCaptureParams = (paymentMethod, options = {}) => {
288
249
  const {
289
250
  txid,
@@ -339,13 +300,7 @@ export const getCaptureParams = (paymentMethod, options = {}) => {
339
300
  };
340
301
  };
341
302
 
342
- /**
343
- * Get refund parameters for specific payment method
344
- * Based on Payone v1 API Documentation
345
- * @param {string} paymentMethod - Payment method
346
- * @param {Object} options - Options including txid, amount, sequencenumber, etc.
347
- * @returns {Object} Complete refund parameters
348
- */
303
+
349
304
  export const getRefundParams = (paymentMethod, options = {}) => {
350
305
  const {
351
306
  txid,
@@ -398,11 +353,7 @@ export const getRefundParams = (paymentMethod, options = {}) => {
398
353
  };
399
354
  };
400
355
 
401
- /**
402
- * Get payment method display name
403
- * @param {string} paymentMethod - Payment method code
404
- * @returns {string} Display name
405
- */
356
+
406
357
  export const getPaymentMethodDisplayName = (paymentMethod) => {
407
358
  const displayNames = {
408
359
  cc: "Credit Card (Visa, Mastercard)",
@@ -416,10 +367,7 @@ export const getPaymentMethodDisplayName = (paymentMethod) => {
416
367
  return displayNames[paymentMethod] || "Unknown Payment Method";
417
368
  };
418
369
 
419
- /**
420
- * Get payment method options for dropdown
421
- * @returns {Array} Array of payment method options
422
- */
370
+
423
371
  export const getPaymentMethodOptions = () => {
424
372
  return [
425
373
  { value: "cc", label: "Credit Card (Visa, Mastercard)" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-payone-provider",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Strapi plugin for Payone payment gateway integration",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -19,7 +19,11 @@ module.exports = async ({ strapi }) => {
19
19
  mid: "",
20
20
  key: "",
21
21
  mode: "test",
22
- api_version: "3.10"
22
+ api_version: "3.10",
23
+ merchantName: "",
24
+ displayName: "",
25
+ domainName: "",
26
+ merchantIdentifier: ""
23
27
  }
24
28
  });
25
29
  }
@@ -10,7 +10,11 @@ module.exports = {
10
10
  mid: "",
11
11
  key: "",
12
12
  mode: "test",
13
- api_version: "3.10"
13
+ api_version: "3.10",
14
+ merchantName: "",
15
+ displayName: "",
16
+ domainName: "",
17
+ merchantIdentifier: ""
14
18
  }
15
19
  },
16
20
  validator(config) {
@@ -176,5 +176,15 @@ module.exports = ({ strapi }) => ({
176
176
  strapi.log.error("3DS callback error:", error);
177
177
  handleError(ctx, error);
178
178
  }
179
+ },
180
+
181
+ async validateApplePayMerchant(ctx) {
182
+ try {
183
+ const params = ctx.request.body;
184
+ const result = await getPayoneService(strapi).validateApplePayMerchant(params);
185
+ ctx.body = { data: result };
186
+ } catch (error) {
187
+ handleError(ctx, error);
188
+ }
179
189
  }
180
190
  });
@@ -75,6 +75,14 @@ module.exports = {
75
75
  config: {
76
76
  policies: ["admin::isAuthenticatedAdmin"]
77
77
  }
78
+ },
79
+ {
80
+ method: "POST",
81
+ path: "/validate-apple-pay-merchant",
82
+ handler: "payone.validateApplePayMerchant",
83
+ config: {
84
+ policies: ["admin::isAuthenticatedAdmin"]
85
+ }
78
86
  }
79
87
  ]
80
88
  },
@@ -144,6 +152,15 @@ module.exports = {
144
152
  policies: ["plugin::strapi-plugin-payone-provider.is-auth"],
145
153
  auth: false
146
154
  }
155
+ },
156
+ {
157
+ method: "POST",
158
+ path: "/validate-apple-pay-merchant",
159
+ handler: "payone.validateApplePayMerchant",
160
+ config: {
161
+ policies: ["plugin::strapi-plugin-payone-provider.is-auth"],
162
+ auth: false
163
+ }
147
164
  }
148
165
  ]
149
166
  }