strapi-plugin-payone-provider 1.4.1 → 1.4.2

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.
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
-
3
- const BankIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill={color} />
6
- <path d="M12 6l-1.5 3L7 8.5l2.5 2.5L8 14l4-2.5L16 14l-1.5-3L18 8.5l-3.5.5L12 6z" fill={color} />
7
- </svg>
8
- );
9
-
10
- export default BankIcon;
1
+ import React from 'react';
2
+
3
+ const BankIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill={color} />
6
+ <path d="M12 6l-1.5 3L7 8.5l2.5 2.5L8 14l4-2.5L16 14l-1.5-3L18 8.5l-3.5.5L12 6z" fill={color} />
7
+ </svg>
8
+ );
9
+
10
+ export default BankIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const ChevronDownIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default ChevronDownIcon;
1
+ import React from 'react';
2
+
3
+ const ChevronDownIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default ChevronDownIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const ChevronUpIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default ChevronUpIcon;
1
+ import React from 'react';
2
+
3
+ const ChevronUpIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default ChevronUpIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const CreditCardIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default CreditCardIcon;
1
+ import React from 'react';
2
+
3
+ const CreditCardIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default CreditCardIcon;
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
-
3
- const ErrorIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill={color} />
6
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z" fill={color} />
7
- </svg>
8
- );
9
-
10
- export default ErrorIcon;
1
+ import React from 'react';
2
+
3
+ const ErrorIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill={color} />
6
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z" fill={color} />
7
+ </svg>
8
+ );
9
+
10
+ export default ErrorIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const InfoIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default InfoIcon;
1
+ import React from 'react';
2
+
3
+ const InfoIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default InfoIcon;
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
-
3
- const PaymentIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M2 8h20v12H2V8zm2 2v8h16V10H4z" fill={color} />
6
- <path d="M2 4h20v2H2V4z" fill={color} />
7
- </svg>
8
- );
9
-
10
- export default PaymentIcon;
1
+ import React from 'react';
2
+
3
+ const PaymentIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M2 8h20v12H2V8zm2 2v8h16V10H4z" fill={color} />
6
+ <path d="M2 4h20v2H2V4z" fill={color} />
7
+ </svg>
8
+ );
9
+
10
+ export default PaymentIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const PendingIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M12.5 7H11V13L16.25 16.15L17 14.92L12.5 12.25V7Z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default PendingIcon;
1
+ import React from 'react';
2
+
3
+ const PendingIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M12.5 7H11V13L16.25 16.15L17 14.92L12.5 12.25V7Z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default PendingIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const PersonIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default PersonIcon;
1
+ import React from 'react';
2
+
3
+ const PersonIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default PersonIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const SuccessIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default SuccessIcon;
1
+ import React from 'react';
2
+
3
+ const SuccessIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default SuccessIcon;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const WalletIcon = ({ size = 16, color = 'currentColor' }) => (
4
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.37-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z" fill={color} />
6
- </svg>
7
- );
8
-
9
- export default WalletIcon;
1
+ import React from 'react';
2
+
3
+ const WalletIcon = ({ size = 16, color = 'currentColor' }) => (
4
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.37-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z" fill={color} />
6
+ </svg>
7
+ );
8
+
9
+ export default WalletIcon;
@@ -1,11 +1,11 @@
1
- export { default as PaymentIcon } from './PaymentIcon';
2
- export { default as PersonIcon } from './PersonIcon';
3
- export { default as CreditCardIcon } from './CreditCardIcon';
4
- export { default as BankIcon } from './BankIcon';
5
- export { default as WalletIcon } from './WalletIcon';
6
- export { default as ErrorIcon } from './ErrorIcon';
7
- export { default as SuccessIcon } from './SuccessIcon';
8
- export { default as PendingIcon } from './PendingIcon';
9
- export { default as InfoIcon } from './InfoIcon';
10
- export { default as ChevronDownIcon } from './ChevronDownIcon';
11
- export { default as ChevronUpIcon } from './ChevronUpIcon';
1
+ export { default as PaymentIcon } from './PaymentIcon';
2
+ export { default as PersonIcon } from './PersonIcon';
3
+ export { default as CreditCardIcon } from './CreditCardIcon';
4
+ export { default as BankIcon } from './BankIcon';
5
+ export { default as WalletIcon } from './WalletIcon';
6
+ export { default as ErrorIcon } from './ErrorIcon';
7
+ export { default as SuccessIcon } from './SuccessIcon';
8
+ export { default as PendingIcon } from './PendingIcon';
9
+ export { default as InfoIcon } from './InfoIcon';
10
+ export { default as ChevronDownIcon } from './ChevronDownIcon';
11
+ export { default as ChevronUpIcon } from './ChevronUpIcon';
@@ -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 automatically
36
- const generateReference = (prefix = "REF") => {
37
- const timestamp = Date.now().toString(36).toUpperCase();
38
- const random = Math.random().toString(36).substring(2, 6).toUpperCase();
39
- return `${prefix}-${timestamp}${random}`.slice(0, 20);
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(generateReference("PRE"));
43
- const [authReference, setAuthReference] = useState(generateReference("AUTH"));
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");
@@ -85,7 +87,7 @@ const usePaymentActions = () => {
85
87
  setPaymentResult(null);
86
88
  try {
87
89
  // Auto-generate reference if empty
88
- const finalPreauthReference = preauthReference.trim() || generateReference("PRE");
90
+ const finalPreauthReference = preauthReference.trim() || generateOrderReference();
89
91
  if (!preauthReference.trim()) {
90
92
  setPreauthReference(finalPreauthReference);
91
93
  }
@@ -227,7 +229,7 @@ const usePaymentActions = () => {
227
229
 
228
230
  try {
229
231
  // Auto-generate reference if empty
230
- const finalAuthReference = authReference.trim() || generateReference("AUTH");
232
+ const finalAuthReference = authReference.trim() || generateOrderReference();
231
233
  if (!authReference.trim()) {
232
234
  setAuthReference(finalAuthReference);
233
235
  }
@@ -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
  };
@@ -17,6 +17,21 @@
17
17
  * - SEPA Direct Debit (elv)
18
18
  */
19
19
 
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
+ export function generateLagOrderNumber(sequence = 1000) {
26
+ const paddedSequence = sequence.toString().padStart(5, '0');
27
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
28
+ let randomPart = '';
29
+ for (let i = 0; i < 4; i++) {
30
+ randomPart += chars.charAt(Math.floor(Math.random() * chars.length));
31
+ }
32
+ return `ORD-${paddedSequence}-${randomPart}`;
33
+ }
34
+
20
35
  /**
21
36
  * Get base parameters for all payment methods
22
37
  * Based on Payone v1 API Documentation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-payone-provider",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Strapi plugin for Payone payment gateway integration",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  const axios = require("axios");
4
- const { normalizeReference } = require("../utils/normalize");
5
4
  const { buildClientRequestParams, toFormData } = require("../utils/requestBuilder");
6
5
  const { addPaymentMethodParams } = require("../utils/paymentMethodParams");
7
6
  const { parseResponse, extractTxId, requires3DSRedirect, get3DSRedirectUrl } = require("../utils/responseParser");
@@ -24,12 +23,7 @@ const sendRequest = async (strapi, params) => {
24
23
  throw new Error("Payone settings not configured");
25
24
  }
26
25
 
27
- const reqType = params.request;
28
- if (["authorization", "preauthorization", "refund"].includes(reqType)) {
29
- const prefix =
30
- reqType === "refund" ? "REF" : reqType === "preauthorization" ? "PRE" : "AUTH";
31
- params.reference = normalizeReference(params.reference, prefix);
32
- }
26
+ // Reference is saved as-is without normalization
33
27
 
34
28
  const requestParams = buildClientRequestParams(settings, params, strapi.log);
35
29
  const formData = toFormData(requestParams);