@akinon/pz-tamara-extension 2.0.0-beta.11 → 2.0.0-beta.13

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,32 +1,99 @@
1
1
  # @akinon/pz-tamara-extension
2
2
 
3
- ## 2.0.0-beta.11
3
+ ## 2.0.0-beta.13
4
+
5
+ ## 1.118.0
6
+
7
+ ## 1.117.0
8
+
9
+ ## 1.116.0
10
+
11
+ ## 1.115.0
12
+
13
+ ## 1.114.0
14
+
15
+ ## 1.113.0
16
+
17
+ ## 1.112.0
18
+
19
+ ## 1.111.0
20
+
21
+ ## 1.110.0
22
+
23
+ ## 1.109.0
24
+
25
+ ## 1.108.0
26
+
27
+ ## 1.107.0
28
+
29
+ ## 1.106.0
30
+
31
+ ### Minor Changes
32
+
33
+ - 155cd23: ZERO-3377: Add customization options for Tamara payment gateway component
34
+
35
+ ## 1.105.0
36
+
37
+ ## 1.104.0
38
+
39
+ ## 1.103.0
40
+
41
+ ## 1.102.0
42
+
43
+ ## 1.101.0
44
+
45
+ ## 1.100.0
46
+
47
+ ## 1.99.0
4
48
 
5
49
  ### Minor Changes
6
50
 
7
- - ac783d6: ZERO-3482: Update tailwindcss to version 4.1.11 and enhance button cursor styles
51
+ - d58538b: ZERO-3638: Enhance RC pipeline: add fetch, merge, and pre-release setup with conditional commit
52
+
53
+ ## 1.98.0
54
+
55
+ ## 1.97.0
56
+
57
+ ## 1.96.0
8
58
 
9
- ## 2.0.0-beta.10
59
+ ## 1.95.0
60
+
61
+ ## 1.94.0
62
+
63
+ ## 1.93.0
64
+
65
+ ## 1.92.0
66
+
67
+ ## 1.91.0
10
68
 
11
69
  ### Minor Changes
12
70
 
13
- - 2806320: ZERO-3390: Update version tailwindcss, autoprefixer, tailwind-merge, postcss
71
+ - 1e53e17: ZERO-3302: decimal precision in formatDecimal function
72
+ - 07248e0: ZERO-3302: fix decimal formatting for Tamara payment gateway
14
73
 
15
- ## 2.0.0-beta.9
74
+ ## 1.90.0
75
+
76
+ ## 1.89.0
16
77
 
17
78
  ### Minor Changes
18
79
 
19
- - 0fe7711: ZERO-3387: Upgrade nextjs, eslint-config-next
80
+ - 1ba5af2: ZERO-3354: Add data-testids for tamara package
81
+
82
+ ## 1.88.0
20
83
 
21
- ## 2.0.0-beta.8
84
+ ## 1.87.0
22
85
 
23
- ## 2.0.0-beta.7
86
+ ## 1.86.0
24
87
 
25
- ## 2.0.0-beta.6
88
+ ## 1.85.0
89
+
90
+ ## 1.84.0
26
91
 
27
92
  ### Minor Changes
28
93
 
29
- - 8f05f9b: ZERO-3250: Beta branch synchronized with Main branch
94
+ - 624a4eb: ZERO-3276: Update installation instructions across multiple README files to standardize format and improve clarity
95
+
96
+ ## 1.83.0
30
97
 
31
98
  ## 1.82.0
32
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-tamara-extension",
3
- "version": "2.0.0-beta.11",
3
+ "version": "2.0.0-beta.13",
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
+ }