@akinon/pz-tabby-extension 1.59.0-rc.4 → 1.59.0

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