@akinon/pz-tamara-extension 2.0.0-beta.12 → 2.0.0-beta.14

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/CHANGELOG.md CHANGED
@@ -1,38 +1,101 @@
1
1
  # @akinon/pz-tamara-extension
2
2
 
3
- ## 2.0.0-beta.12
3
+ ## 2.0.0-beta.14
4
+
5
+ ## 2.0.0-beta.13
6
+
7
+ ## 1.118.0
8
+
9
+ ## 1.117.0
10
+
11
+ ## 1.116.0
12
+
13
+ ## 1.115.0
14
+
15
+ ## 1.114.0
16
+
17
+ ## 1.113.0
18
+
19
+ ## 1.112.0
20
+
21
+ ## 1.111.0
22
+
23
+ ## 1.110.0
24
+
25
+ ## 1.109.0
26
+
27
+ ## 1.108.0
28
+
29
+ ## 1.107.0
30
+
31
+ ## 1.106.0
4
32
 
5
33
  ### Minor Changes
6
34
 
7
- - 1d79e32: ZERO-3540: Next.js Upgrade to 15.4.5
35
+ - 155cd23: ZERO-3377: Add customization options for Tamara payment gateway component
36
+
37
+ ## 1.105.0
38
+
39
+ ## 1.104.0
8
40
 
9
- ## 2.0.0-beta.11
41
+ ## 1.103.0
42
+
43
+ ## 1.102.0
44
+
45
+ ## 1.101.0
46
+
47
+ ## 1.100.0
48
+
49
+ ## 1.99.0
10
50
 
11
51
  ### Minor Changes
12
52
 
13
- - ac783d6: ZERO-3482: Update tailwindcss to version 4.1.11 and enhance button cursor styles
53
+ - d58538b: ZERO-3638: Enhance RC pipeline: add fetch, merge, and pre-release setup with conditional commit
54
+
55
+ ## 1.98.0
56
+
57
+ ## 1.97.0
58
+
59
+ ## 1.96.0
60
+
61
+ ## 1.95.0
14
62
 
15
- ## 2.0.0-beta.10
63
+ ## 1.94.0
64
+
65
+ ## 1.93.0
66
+
67
+ ## 1.92.0
68
+
69
+ ## 1.91.0
16
70
 
17
71
  ### Minor Changes
18
72
 
19
- - 2806320: ZERO-3390: Update version tailwindcss, autoprefixer, tailwind-merge, postcss
73
+ - 1e53e17: ZERO-3302: decimal precision in formatDecimal function
74
+ - 07248e0: ZERO-3302: fix decimal formatting for Tamara payment gateway
75
+
76
+ ## 1.90.0
20
77
 
21
- ## 2.0.0-beta.9
78
+ ## 1.89.0
22
79
 
23
80
  ### Minor Changes
24
81
 
25
- - 0fe7711: ZERO-3387: Upgrade nextjs, eslint-config-next
82
+ - 1ba5af2: ZERO-3354: Add data-testids for tamara package
26
83
 
27
- ## 2.0.0-beta.8
84
+ ## 1.88.0
28
85
 
29
- ## 2.0.0-beta.7
86
+ ## 1.87.0
30
87
 
31
- ## 2.0.0-beta.6
88
+ ## 1.86.0
89
+
90
+ ## 1.85.0
91
+
92
+ ## 1.84.0
32
93
 
33
94
  ### Minor Changes
34
95
 
35
- - 8f05f9b: ZERO-3250: Beta branch synchronized with Main branch
96
+ - 624a4eb: ZERO-3276: Update installation instructions across multiple README files to standardize format and improve clarity
97
+
98
+ ## 1.83.0
36
99
 
37
100
  ## 1.82.0
38
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-tamara-extension",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "scripts": {
@@ -8,8 +8,8 @@
8
8
  "test:watch": "jest --watch"
9
9
  },
10
10
  "peerDependencies": {
11
- "react": "^18.0.0",
12
- "react-dom": "^18.0.0"
11
+ "react": "^18.0.0 || ^19.0.0",
12
+ "react-dom": "^18.0.0 || ^19.0.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/jest": "^29.5.14",
@@ -18,8 +18,8 @@
18
18
  "@types/react-dom": "^18.0.6",
19
19
  "jest": "^29.7.0",
20
20
  "prettier": "^3.0.3",
21
- "react": "^18.2.0",
22
- "react-dom": "^18.2.0",
21
+ "react": "^19.2.4",
22
+ "react-dom": "^19.2.4",
23
23
  "ts-jest": "^29.3.1",
24
24
  "typescript": "^5.2.2"
25
25
  }
package/readme.md CHANGED
@@ -40,6 +40,94 @@ const TamaraGateway = async ({
40
40
  export default TamaraGateway;
41
41
  ```
42
42
 
43
+ ## Customizing the Tamara Component
44
+
45
+ You can customize the appearance of the Tamara payment gateway using the `renderer` prop. This allows you to provide custom rendering functions for different parts of the component.
46
+
47
+ ### Custom Form Component
48
+
49
+ ```jsx
50
+ import { TamaraPaymentGateway } from '@akinon/pz-tamara-extension';
51
+
52
+ const TamaraGateway = async ({
53
+ searchParams: { sessionId },
54
+ params: { currency, locale }
55
+ }: {
56
+ searchParams: Record<string, string>;
57
+ params: { currency: string; locale: string };
58
+ }) => {
59
+ return (
60
+ <TamaraPaymentGateway
61
+ sessionId={sessionId}
62
+ currency={currency}
63
+ locale={locale}
64
+ extensionUrl={process.env.TAMARA_EXTENSION_URL}
65
+ hashKey={process.env.TAMARA_HASH_KEY}
66
+ renderer={{
67
+ formComponent: {
68
+ renderForm: ({ extensionUrl, sessionId, context, csrfToken, autoSubmit }) => (
69
+ <div className="custom-tamara-form-wrapper">
70
+ <h3 className="text-lg font-semibold mb-4">Tamara Payment</h3>
71
+ <p className="mb-4">You are beign redirected to Tamara payment page...</p>
72
+ <form
73
+ action={`${extensionUrl}/form-page/?sessionId=${sessionId}`}
74
+ method="post"
75
+ encType="multipart/form-data"
76
+ id="tamara-custom-form"
77
+ className="hidden"
78
+ >
79
+ <input type="hidden" name="csrf_token" value={csrfToken} />
80
+ <input type="hidden" name="data" value={JSON.stringify(context)} />
81
+ {autoSubmit && (
82
+ <script
83
+ dangerouslySetInnerHTML={{
84
+ __html: "document.getElementById('tamara-custom-form').submit()"
85
+ }}
86
+ />
87
+ )}
88
+ </form>
89
+ <div className="loader w-12 h-12 border-4 border-t-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"></div>
90
+ </div>
91
+ )
92
+ },
93
+ paymentGateway: {
94
+ renderContainer: ({ children }) => (
95
+ <div className="p-8 max-w-lg mx-auto bg-white rounded-lg shadow-md">
96
+ {children}
97
+ </div>
98
+ )
99
+ }
100
+ }}
101
+ />
102
+ );
103
+ };
104
+
105
+ export default TamaraGateway;
106
+ ```
107
+
108
+ ## Custom Renderer API
109
+
110
+ The renderer prop accepts an object with the following structure:
111
+
112
+ ```typescript
113
+ interface TamaraRendererProps {
114
+ formComponent?: {
115
+ renderForm?: (props: {
116
+ extensionUrl: string;
117
+ sessionId: string;
118
+ context: any;
119
+ csrfToken: string;
120
+ autoSubmit: boolean;
121
+ }) => React.ReactNode;
122
+ renderLoading?: () => React.ReactNode;
123
+ renderError?: (error: string) => React.ReactNode;
124
+ };
125
+ paymentGateway?: {
126
+ renderContainer?: (props: { children: React.ReactNode }) => React.ReactNode;
127
+ };
128
+ }
129
+ ```
130
+
43
131
  ## API Routes
44
132
 
45
133
  ### Check Availability API
@@ -1,16 +1,13 @@
1
1
  import React from 'react';
2
2
  import { cookies } from 'next/headers';
3
-
4
- type FormComponentProps = {
5
- extensionUrl: string;
6
- sessionId: string;
7
- context: any;
8
- };
3
+ import { FormComponentProps } from '../types';
9
4
 
10
5
  const FormComponent = async ({
11
6
  extensionUrl,
12
7
  sessionId,
13
- context
8
+ context,
9
+ renderer,
10
+ autoSubmit = true
14
11
  }: FormComponentProps) => {
15
12
  const nextCookies = await cookies();
16
13
 
@@ -20,9 +17,15 @@ const FormComponent = async ({
20
17
 
21
18
  const csrfToken = nextCookies.get('csrftoken')?.value ?? '';
22
19
 
23
- return (
20
+ const DefaultForm = ({
21
+ extensionUrl,
22
+ sessionId,
23
+ context,
24
+ csrfToken,
25
+ autoSubmit
26
+ }) => (
24
27
  <form
25
- action={`${extensionUrlWithoutSlash}/form-page/?sessionId=${sessionId}`}
28
+ action={`${extensionUrl}/form-page/?sessionId=${sessionId}`}
26
29
  method="post"
27
30
  encType="multipart/form-data"
28
31
  id="tamara-extension-form"
@@ -30,13 +33,27 @@ const FormComponent = async ({
30
33
  <input type="hidden" name="csrf_token" value={csrfToken} />
31
34
  <input type="hidden" name="data" value={JSON.stringify(context)} />
32
35
 
33
- <script
34
- dangerouslySetInnerHTML={{
35
- __html: "document.getElementById('tamara-extension-form').submit()"
36
- }}
37
- />
36
+ {autoSubmit && (
37
+ <script
38
+ dangerouslySetInnerHTML={{
39
+ __html: "document.getElementById('tamara-extension-form').submit()"
40
+ }}
41
+ />
42
+ )}
38
43
  </form>
39
44
  );
45
+
46
+ const RenderForm = renderer?.renderForm || DefaultForm;
47
+
48
+ return (
49
+ <RenderForm
50
+ extensionUrl={extensionUrlWithoutSlash}
51
+ sessionId={sessionId}
52
+ context={context}
53
+ csrfToken={csrfToken}
54
+ autoSubmit={autoSubmit}
55
+ />
56
+ );
40
57
  };
41
58
 
42
59
  export default FormComponent;
package/src/index.tsx CHANGED
@@ -1 +1,6 @@
1
1
  export * from './pages/TamaraPaymentGateway';
2
+ export type {
3
+ TamaraPaymentGatewayProps,
4
+ TamaraRendererProps,
5
+ FormComponentProps
6
+ } from './types';
@@ -9,21 +9,15 @@ import {
9
9
  formatDecimal,
10
10
  getQuantizeFormat
11
11
  } from '../utils';
12
-
13
- type TamaraPaymentGatewayProps = {
14
- sessionId: string;
15
- currency: string;
16
- locale: string;
17
- extensionUrl: string;
18
- hashKey: string;
19
- };
12
+ import { TamaraPaymentGatewayProps } from '../types';
20
13
 
21
14
  export const TamaraPaymentGateway = async ({
22
15
  sessionId,
23
16
  currency,
24
17
  locale,
25
18
  extensionUrl,
26
- hashKey
19
+ hashKey,
20
+ renderer
27
21
  }: TamaraPaymentGatewayProps) => {
28
22
  if (!sessionId || !currency || !locale) {
29
23
  return <></>;
@@ -142,11 +136,18 @@ export const TamaraPaymentGateway = async ({
142
136
  }
143
137
  };
144
138
 
139
+ const DefaultContainer = ({ children }) => <>{children}</>;
140
+ const RenderContainer =
141
+ renderer?.paymentGateway?.renderContainer || DefaultContainer;
142
+
145
143
  return (
146
- <FormComponent
147
- extensionUrl={extensionUrl}
148
- sessionId={sessionId}
149
- context={context}
150
- />
144
+ <RenderContainer>
145
+ <FormComponent
146
+ extensionUrl={extensionUrl}
147
+ sessionId={sessionId}
148
+ context={context}
149
+ renderer={renderer?.formComponent}
150
+ />
151
+ </RenderContainer>
151
152
  );
152
153
  };
package/src/types.ts ADDED
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+
3
+ export interface TamaraRendererProps {
4
+ formComponent?: {
5
+ renderForm?: (props: {
6
+ extensionUrl: string;
7
+ sessionId: string;
8
+ context: any;
9
+ csrfToken: string;
10
+ autoSubmit: boolean;
11
+ }) => React.ReactNode;
12
+ renderLoading?: () => React.ReactNode;
13
+ renderError?: (error: string) => React.ReactNode;
14
+ };
15
+ paymentGateway?: {
16
+ renderContainer?: (props: { children: React.ReactNode }) => React.ReactNode;
17
+ };
18
+ }
19
+
20
+ export interface FormComponentProps {
21
+ extensionUrl: string;
22
+ sessionId: string;
23
+ context: any;
24
+ renderer?: TamaraRendererProps['formComponent'];
25
+ autoSubmit?: boolean;
26
+ }
27
+
28
+ export interface TamaraPaymentGatewayProps {
29
+ sessionId: string;
30
+ currency: string;
31
+ locale: string;
32
+ extensionUrl: string;
33
+ hashKey: string;
34
+ renderer?: TamaraRendererProps;
35
+ }