@akinon/pz-masterpass 1.45.0-rc.0 → 1.45.0

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,12 +1,6 @@
1
1
  # @akinon/pz-masterpass
2
2
 
3
- ## 1.45.0-rc.0
4
-
5
- ### Minor Changes
6
-
7
- - 50b9069: ZERO-2767: update plugin readme files
8
- - 64699d3: ZERO-2761: Fix invalid import for plugin module
9
- - e9a46ac: ZERO-2738: add CVC input to registered cards in Masterpass
3
+ ## 1.45.0
10
4
 
11
5
  ## 1.44.0
12
6
 
package/README.md CHANGED
@@ -1,14 +1,4 @@
1
- # @akinon/pz-masterpass
2
-
3
- ### Install the npm package
4
-
5
- ```bash
6
- # For latest version
7
- yarn add @akinon/pz-masterpass
8
-
9
- # Preferred installation method
10
- npx @akinon/projectzero@latest --plugins
11
- ```
1
+ # pz-masterpass
12
2
 
13
3
  ## Available Props
14
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass",
3
- "version": "1.45.0-rc.0",
3
+ "version": "1.45.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
@@ -29,7 +29,6 @@ export interface MasterpassState {
29
29
  additionalParams?: {
30
30
  [key: string]: string;
31
31
  };
32
- cvcRequired: boolean;
33
32
  }
34
33
 
35
34
  const initialState: MasterpassState = {
@@ -42,8 +41,7 @@ const initialState: MasterpassState = {
42
41
  deletion: {
43
42
  isModalVisible: false
44
43
  },
45
- additionalParams: {},
46
- cvcRequired: false
44
+ additionalParams: {}
47
45
  };
48
46
 
49
47
  const rootSlice = createSlice({
@@ -113,9 +111,6 @@ const rootSlice = createSlice({
113
111
  { payload }: PayloadAction<{ [key: string]: any }>
114
112
  ) => {
115
113
  state.additionalParams = payload;
116
- },
117
- setCvcRequired: (state, { payload }: PayloadAction<boolean>) => {
118
- state.cvcRequired = payload;
119
114
  }
120
115
  }
121
116
  });
@@ -136,8 +131,7 @@ export const {
136
131
  setOtpResponse,
137
132
  setDeletionModalVisible,
138
133
  setDeletionCardAliasName,
139
- setAdditionalParams,
140
- setCvcRequired
134
+ setAdditionalParams
141
135
  } = rootSlice.actions;
142
136
 
143
137
  export default rootSlice.reducer;
@@ -80,8 +80,7 @@ export const buildPurchaseForm = async ({
80
80
  amount,
81
81
  additionalParams,
82
82
  language = 'eng',
83
- installmentCount,
84
- cardCvc
83
+ installmentCount
85
84
  }: {
86
85
  token: string;
87
86
  orderNo: string;
@@ -95,7 +94,6 @@ export const buildPurchaseForm = async ({
95
94
  };
96
95
  language: string;
97
96
  installmentCount: number;
98
- cardCvc?: string;
99
97
  }) => {
100
98
  const session = await getSession();
101
99
 
@@ -126,10 +124,6 @@ export const buildPurchaseForm = async ({
126
124
  { name: 'cardAliasName', value: selectedCard?.Name ?? '' }
127
125
  ];
128
126
 
129
- if (cardCvc) {
130
- fields.push({ name: 'cvc', value: cardCvc });
131
- }
132
-
133
127
  const form = formCreator({
134
128
  id: 'mp-purchase-form',
135
129
  fields
@@ -15,22 +15,10 @@ import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
15
15
  import { useCards } from '../../hooks/use-cards';
16
16
  import { useDeleteCard } from '../../hooks/use-delete-card';
17
17
  import { useSetBinNumberMutation } from '@akinon/next/data/client/checkout';
18
- import { Button, Icon, Image, Input } from '@akinon/next/components';
18
+ import { Button, Image } from '@akinon/next/components';
19
19
  import { twMerge } from 'tailwind-merge';
20
- import {
21
- setCvcRequired,
22
- setIsDirectPurchase,
23
- setSelectedCard
24
- } from '../../redux/reducer';
20
+ import { setIsDirectPurchase, setSelectedCard } from '../../redux/reducer';
25
21
  import { setInstallmentOptions } from '@akinon/next/redux/reducers/checkout';
26
- import clsx from 'clsx';
27
- import {
28
- Control,
29
- FieldError,
30
- UseFormClearErrors,
31
- UseFormRegister,
32
- UseFormSetValue
33
- } from 'react-hook-form';
34
22
 
35
23
  const cardImages = {
36
24
  amex,
@@ -43,31 +31,22 @@ const cardImages = {
43
31
  const defaultTranslations = {
44
32
  title: 'Select a card to pay with',
45
33
  pay_with_new_card: 'Pay with a new card',
46
- retryFetchCards: 'Retry Fetching Cards',
47
- security_code: 'Security Code',
48
- security_code_info: 'What’s CVC?'
34
+ retryFetchCards: 'Retry Fetching Cards'
49
35
  };
50
36
 
51
37
  export interface MasterpassCardListProps {
52
38
  className?: string;
53
39
  translations?: typeof defaultTranslations;
54
- form?: {
55
- clearErrors: UseFormClearErrors<any>;
56
- control: Control<any>;
57
- errors: Record<string, FieldError>;
58
- register: UseFormRegister<any>;
59
- setFormValue: UseFormSetValue<any>;
60
- };
61
40
  }
62
41
 
63
42
  export const MasterpassCardList = ({
64
43
  className,
65
- translations,
66
- form
44
+ translations
67
45
  }: MasterpassCardListProps) => {
68
46
  const { preOrder } = useAppSelector((state) => state.checkout);
69
- const { accountStatus, isDirectPurchase, selectedCard, cvcRequired } =
70
- useAppSelector((state) => state.masterpass);
47
+ const { accountStatus, isDirectPurchase, selectedCard } = useAppSelector(
48
+ (state) => state.masterpass
49
+ );
71
50
  const [setMasterpassBinNumber] = useSetBinNumberMutation();
72
51
  const { cards, loading, error, refreshCards } = useCards({ skipData: false });
73
52
  const { DeleteButton } = useDeleteCard();
@@ -142,90 +121,40 @@ export const MasterpassCardList = ({
142
121
  return (
143
122
  <li
144
123
  key={card.UniqueId}
145
- className="p-4 mb-2 border-2 border-gray-200 flex flex-col space-x-2 cursor-pointer"
124
+ className="p-4 mb-2 border-2 border-gray-200 flex justify-between items-center space-x-2 cursor-pointer"
146
125
  onClick={async () => {
147
- if (selectedCard?.UniqueId !== card.UniqueId) {
148
- await setMasterpassBinNumber(
149
- card.Value1.substring(0, 6)
150
- ).unwrap();
151
-
152
- dispatch(setSelectedCard(card));
153
- dispatch(setCvcRequired(false));
154
-
155
- if (form) {
156
- form.setFormValue('card_cvv', '');
157
- form.clearErrors('card_cvv');
158
- }
159
- }
126
+ await setMasterpassBinNumber(
127
+ card.Value1.substring(0, 6)
128
+ ).unwrap();
129
+
130
+ dispatch(setSelectedCard(card));
160
131
  }}
161
132
  >
162
- <div className="flex justify-between items-center">
163
- <input
164
- name="masterpass-card"
165
- type="radio"
166
- checked={selectedCard?.UniqueId === card.UniqueId}
167
- value={card.Name}
168
- id={card.UniqueId}
169
- className="mr-2"
170
- onChange={(e) => e.preventDefault()}
133
+ <input
134
+ name="masterpass-card"
135
+ type="radio"
136
+ checked={selectedCard?.UniqueId === card.UniqueId}
137
+ value={card.Name}
138
+ id={card.UniqueId}
139
+ className="mr-2"
140
+ onChange={(e) => e.preventDefault()}
141
+ />
142
+ <label
143
+ htmlFor={card.UniqueId}
144
+ className="flex flex-col w-full cursor-pointer md:flex-row md:items-center md:justify-between"
145
+ >
146
+ <p className="w-full lg:w-1/3">{card.Name}</p>
147
+ <p className="w-full text-[10px] lg:w-1/3">{card.Value1}</p>
148
+ <Image
149
+ className="w-8 h-6 object-contain flex items-center justify-center mr-4"
150
+ width={50}
151
+ height={50}
152
+ src={cardImages[getCreditCardType(card.Value1)].src}
153
+ alt={card.Name}
171
154
  />
172
- <label
173
- htmlFor={card.UniqueId}
174
- className="flex flex-col w-full cursor-pointer md:flex-row md:items-center md:justify-between"
175
- >
176
- <p className="w-full lg:w-1/3">{card.Name}</p>
177
- <p className="w-full text-[10px] lg:w-1/3">{card.Value1}</p>
178
- <Image
179
- className="w-8 h-6 object-contain flex items-center justify-center mr-4"
180
- width={50}
181
- height={50}
182
- src={cardImages[getCreditCardType(card.Value1)].src}
183
- alt={card.Name}
184
- />
185
- </label>
186
-
187
- <DeleteButton cardAliasName={card.Name} />
188
- </div>
189
- {selectedCard?.UniqueId === card.UniqueId && form && cvcRequired && (
190
- <div
191
- className={twMerge(
192
- clsx('flex items-center justify-start mt-2', {
193
- 'items-baseline': form.errors.card_cvv
194
- })
195
- )}
196
- >
197
- <label
198
- className="text-xs text-black-400 mr-1.5"
199
- htmlFor="card_cvv"
200
- >
201
- {translations?.security_code ??
202
- defaultTranslations.security_code}
203
- </label>
204
- <Input
205
- format="###"
206
- mask="_"
207
- control={form.control}
208
- allowEmptyFormatting={true}
209
- {...form.register('card_cvv')}
210
- error={form.errors.card_cvv}
211
- />
212
- <div className="group relative flex items-center justify-start text-gray-600 cursor-pointer ml-2 transition-all hover:text-secondary">
213
- <span className="text-xs underline">
214
- {translations?.security_code_info ??
215
- defaultTranslations.security_code_info}
216
- </span>
217
- <Icon name="cvc" size={16} className="leading-none ml-2" />
218
- <div className="hidden group-hover:block absolute right-0 bottom-5 w-[11rem] lg:w-[21rem] lg:left-auto lg:right-auto border-2">
219
- <Image
220
- src="/cvv.jpg"
221
- alt="Cvv"
222
- width={385}
223
- height={262}
224
- />
225
- </div>
226
- </div>
227
- </div>
228
- )}
155
+ </label>
156
+
157
+ <DeleteButton cardAliasName={card.Name} />
229
158
  </li>
230
159
  );
231
160
  })}