@akinon/pz-tabby-extension 1.66.0 → 1.68.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/package.json +1 -1
- package/readme.md +14 -11
- package/src/components/FormComponent.tsx +0 -6
- package/src/pages/TabbyPaymentGateway.tsx +16 -7
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# @akinon/pz-tabby-extension
|
2
2
|
|
3
|
+
## 1.68.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 907813c: ZERO-2934: add payment-gateway/<gateway> redirect in middleware
|
8
|
+
- 82cf1e5: ZERO-2934: return empty when sessionId or currency null
|
9
|
+
- fa4c716: ZERO-2934: add accept-language headers
|
10
|
+
- 2eba2a8: ZERO-2934: fix zip code
|
11
|
+
|
12
|
+
## 1.67.0
|
13
|
+
|
3
14
|
## 1.66.0
|
4
15
|
|
5
16
|
## 1.65.0
|
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -31,20 +31,23 @@ Once the extension is installed, you can easily integrate the Tabby payment gate
|
|
31
31
|
```jsx
|
32
32
|
import { TabbyPaymentGateway } from '@akinon/pz-tabby-extension';
|
33
33
|
|
34
|
-
const TabbyGateway = ({
|
34
|
+
const TabbyGateway = async ({
|
35
35
|
searchParams: { sessionId },
|
36
|
-
params: { currency }
|
36
|
+
params: { currency, locale }
|
37
37
|
}: {
|
38
38
|
searchParams: Record<string, string>;
|
39
|
-
params: { currency: string };
|
40
|
-
}) =>
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
params: { currency: string; locale: string };
|
40
|
+
}) => {
|
41
|
+
return (
|
42
|
+
<TabbyPaymentGateway
|
43
|
+
sessionId={sessionId}
|
44
|
+
currency={currency}
|
45
|
+
locale={locale}
|
46
|
+
extensionUrl={process.env.TABBY_EXTENSION_URL}
|
47
|
+
hashKey={process.env.TABBY_HASH_KEY}
|
48
|
+
/>
|
49
|
+
);
|
50
|
+
};
|
48
51
|
|
49
52
|
export default TabbyGateway;
|
50
53
|
```
|
@@ -4,16 +4,12 @@ import { cookies } from 'next/headers';
|
|
4
4
|
type FormComponentProps = {
|
5
5
|
extensionUrl: string;
|
6
6
|
sessionId: string;
|
7
|
-
hash: string;
|
8
|
-
salt: string;
|
9
7
|
context: any;
|
10
8
|
};
|
11
9
|
|
12
10
|
const FormComponent = ({
|
13
11
|
extensionUrl,
|
14
12
|
sessionId,
|
15
|
-
hash,
|
16
|
-
salt,
|
17
13
|
context
|
18
14
|
}: FormComponentProps) => {
|
19
15
|
const nextCookies = cookies();
|
@@ -32,8 +28,6 @@ const FormComponent = ({
|
|
32
28
|
id="tabby-extension-form"
|
33
29
|
>
|
34
30
|
<input type="hidden" name="csrf_token" value={csrfToken} />
|
35
|
-
<input type="hidden" name="hash" value={hash} />
|
36
|
-
<input type="hidden" name="salt" value={salt} />
|
37
31
|
<input type="hidden" name="data" value={JSON.stringify(context)} />
|
38
32
|
|
39
33
|
<script
|
@@ -1,7 +1,7 @@
|
|
1
|
+
import React from 'react';
|
1
2
|
import { URLS } from '@akinon/next/data/urls';
|
2
3
|
import settings from 'settings';
|
3
4
|
import { cookies } from 'next/headers';
|
4
|
-
import React from 'react';
|
5
5
|
import FormComponent from '../components/FormComponent';
|
6
6
|
import {
|
7
7
|
fetchData,
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
type TabbyPaymentGatewayProps = {
|
15
15
|
sessionId: string;
|
16
16
|
currency: string;
|
17
|
+
locale: string;
|
17
18
|
extensionUrl: string;
|
18
19
|
hashKey: string;
|
19
20
|
};
|
@@ -21,16 +22,26 @@ type TabbyPaymentGatewayProps = {
|
|
21
22
|
export const TabbyPaymentGateway = async ({
|
22
23
|
sessionId,
|
23
24
|
currency,
|
25
|
+
locale,
|
24
26
|
extensionUrl,
|
25
27
|
hashKey
|
26
28
|
}: TabbyPaymentGatewayProps) => {
|
29
|
+
if (!sessionId || !currency || !locale) {
|
30
|
+
return <></>;
|
31
|
+
}
|
32
|
+
|
27
33
|
const nextCookies = cookies();
|
28
34
|
|
35
|
+
const language = settings.localization.locales.find(
|
36
|
+
(item) => item.value === locale
|
37
|
+
).apiValue;
|
38
|
+
|
29
39
|
const requestHeaders = {
|
30
40
|
Cookie: `osessionid=${nextCookies.get('osessionid')?.value}`,
|
31
41
|
'Content-Type': 'application/json',
|
32
|
-
'
|
33
|
-
'X-Requested-With': 'XMLHttpRequest'
|
42
|
+
'X-Currency': currency,
|
43
|
+
'X-Requested-With': 'XMLHttpRequest',
|
44
|
+
'Accept-Language': language
|
34
45
|
};
|
35
46
|
|
36
47
|
const [preOrder, userProfile, successOrders, orderHistory, wishlist] =
|
@@ -57,7 +68,7 @@ export const TabbyPaymentGateway = async ({
|
|
57
68
|
shipping_address: {
|
58
69
|
city: preOrder.pre_order.shipping_address.city.name,
|
59
70
|
address: preOrder.pre_order.shipping_address.line,
|
60
|
-
zip: preOrder.pre_order.shipping_address.postcode
|
71
|
+
zip: preOrder.pre_order.shipping_address.postcode ?? '0'
|
61
72
|
},
|
62
73
|
order_items: preOrder.pre_order.basket.basketitem_set.map((item: any) => ({
|
63
74
|
unit_price: item.unit_price,
|
@@ -86,7 +97,7 @@ export const TabbyPaymentGateway = async ({
|
|
86
97
|
shipping_address: {
|
87
98
|
city: order_history.shipping_address.city.name,
|
88
99
|
address: order_history.shipping_address.line,
|
89
|
-
zip: order_history.shipping_address.postcode
|
100
|
+
zip: order_history.shipping_address.postcode ?? '0'
|
90
101
|
},
|
91
102
|
order_items: groupByProductId(order_history.orderitem_set)
|
92
103
|
}))
|
@@ -96,8 +107,6 @@ export const TabbyPaymentGateway = async ({
|
|
96
107
|
<FormComponent
|
97
108
|
extensionUrl={extensionUrl}
|
98
109
|
sessionId={sessionId}
|
99
|
-
hash={hash}
|
100
|
-
salt={salt}
|
101
110
|
context={context}
|
102
111
|
/>
|
103
112
|
);
|