@akinon/pz-masterpass 1.91.0-rc.2 → 1.91.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,19 +1,6 @@
1
1
  # @akinon/pz-masterpass
2
2
 
3
- ## 1.91.0-rc.2
4
-
5
- ## 1.91.0-rc.1
6
-
7
- ## 1.91.0-rc.0
8
-
9
- ### Minor Changes
10
-
11
- - ad0bec9: ZERO-3364 :Update readme file for masterpass
12
- - 64699d3f: ZERO-2761: Fix invalid import for plugin module
13
- - e974d8e: ZERO-3406: Fix rc build
14
- - b31333e: ZERO-3357 :Add components with renderer properties for customizable UI elements in pz-masterpass
15
- - 7727ae55: ZERO-3073: Refactor basket page to use server-side data fetching and simplify component structure
16
- - 33377cfd: ZERO-3267: Refactor import statement for ROUTES in error-page component
3
+ ## 1.91.0
17
4
 
18
5
  ## 1.90.0
19
6
 
package/README.md CHANGED
@@ -12,14 +12,10 @@ npx @akinon/projectzero@latest --plugins
12
12
 
13
13
  ## Available Props
14
14
 
15
- ## Masterpass Provider
15
+ ### Masterpass Provider
16
16
 
17
17
  ##### File Path: src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx
18
18
 
19
- ### Usage Examples
20
-
21
- ##### Default Usage
22
-
23
19
  ```javascript
24
20
  <PluginModule
25
21
  component={Component.MasterpassProvider}
@@ -33,7 +29,7 @@ npx @akinon/projectzero@latest --plugins
33
29
  </PluginModule>
34
30
  ```
35
31
 
36
- ##### Customized Usage with Additional Params
32
+ ### Additional Params
37
33
 
38
34
  ##### To add extra parameters, it can be added by passing additional Params property to the Masterpass Provider.
39
35
 
@@ -55,30 +51,8 @@ npx @akinon/projectzero@latest --plugins
55
51
 
56
52
  ### Delete Confirmation Modal
57
53
 
58
- #### Props
59
-
60
- | Props | Type | Required | Description |
61
- | --- | --- | --- | --- |
62
- | translations | typeof defaultTranslations | Optional | Used to customize the default texts. |
63
- | renderer | RendererProps | Optional | Renderer functions that can be used to customize all subcomponents. |
64
-
65
- #### RendererProps
66
-
67
- | Props | Type | Description |
68
- | --- | --- | --- |
69
- | open | boolean | It is information whether the modal is open or not. |
70
- | setOpen | (open: boolean) => void | Used to manage modal on/off operation. |
71
- | onConfirm | () => void | This is the function that will perform the deletion operation. |
72
- | onCancel | () => void | This is the function that will be run if the user cancels the deletion process. |
73
- | loading | boolean | Indicates the loading status during the deletion process. |
74
- | error | string / null | Error message to be displayed if an error occurs during deletion. |
75
-
76
54
  ##### File Path: src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx
77
55
 
78
- ### Usage Examples
79
-
80
- ##### Default Usage
81
-
82
56
  ```javascript
83
57
  <PluginModule
84
58
  component={Component.MasterpassDeleteConfirmationModal}
@@ -92,70 +66,10 @@ npx @akinon/projectzero@latest --plugins
92
66
  />
93
67
  ```
94
68
 
95
- ##### Customized Usage with Renderer
96
-
97
- ```javascript
98
- <PluginModule
99
- component={Component.MasterpassDeleteConfirmationModal}
100
- props={{
101
- renderer: {
102
- Content: ({ open, setOpen, onConfirm, onCancel, loading, error }) => (
103
- <Modal
104
- open={open}
105
- setOpen={setOpen}
106
- className="w-full sm:w-[28rem]"
107
- portalId="masterpass-remove-card-modal"
108
- >
109
- <div className="flex flex-col items-center p-5">
110
- <div className="text-xs mb-3">
111
- Are you sure you want to delete your card?
112
- </div>
113
- <Button onClick={onConfirm} className="bg-red-600 text-black">
114
- {loading ? 'Deletion...' : 'Delete'}
115
- </Button>
116
- <Button appearance="outlined" onClick={onCancel}>
117
- Cancel
118
- </Button>
119
- {error && (
120
- <p className="text-red-500 text-sm mt-2 text-center">
121
- 🚨 {error}
122
- </p>
123
- )}
124
- </div>
125
- </Modal>
126
- )
127
- }
128
- }}
129
- />
130
- ```
131
-
132
69
  ### OTP Modal
133
70
 
134
- #### Props
135
-
136
- | Props | Type | Required | Description |
137
- | --- | --- | --- | --- |
138
- | translations | { [key: string]: string } | Optional | Translation object to customize all texts. Overrides default texts. |
139
- | renderer | RendererProps | Optional | Renderer functions that can be used to customize all subcomponents. |
140
-
141
- #### RendererProps
142
-
143
- | Props | Type | Description |
144
- | --- | --- | --- |
145
- | open | boolean | It is information whether the modal is open or not. |
146
- | setOpen | (open: boolean) => void | Used to manage modal on/off operation. |
147
- | onSubmit | (data: { otp_code: string }) => void | Sends the OTP code entered by the user. |
148
- | loading | boolean | Indicates the loading status during validation. |
149
- | error | string / null | Error message to be displayed if there is an error. |
150
- | resendSms | () => void | Function triggered when the user requests SMS again. |
151
- | resendSmsFetching | boolean | Indicates the loading status during the resending process. |
152
- | targetDate | number | When the countdown will end (as a timestamp). |
153
- | otpRef | string / null | Transaction reference number, if applicable. |
154
-
155
71
  ##### File Path: src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx
156
72
 
157
- ##### Default Usage
158
-
159
73
  ```javascript
160
74
  <PluginModule
161
75
  component={Component.MasterpassOtpModal}
@@ -172,127 +86,10 @@ npx @akinon/projectzero@latest --plugins
172
86
  />
173
87
  ```
174
88
 
175
- ##### Customized Usage with Renderer
176
-
177
- ```javascript
178
- <PluginModule
179
- component={Component.MasterpassOtpModal}
180
- props={{
181
- renderer: {
182
- Content: ({
183
- open,
184
- setOpen,
185
- onSubmit,
186
- loading,
187
- error,
188
- resendSms,
189
- resendSmsFetching,
190
- targetDate,
191
- otpRef
192
- }) => {
193
- const [code, setCode] = useState('');
194
- const [remainingSeconds, setRemainingSeconds] = useState(
195
- Math.ceil((targetDate - Date.now()) / 1000)
196
- );
197
- useEffect(() => {
198
- if (!targetDate) return;
199
- const interval = setInterval(() => {
200
- const secondsLeft = Math.ceil((targetDate - Date.now()) / 1000);
201
- setRemainingSeconds(secondsLeft);
202
- if (secondsLeft <= 0) {
203
- clearInterval(interval);
204
- }
205
- }, 1000);
206
- return () => clearInterval(interval);
207
- }, [targetDate]);
208
- return (
209
- <Modal
210
- open={open}
211
- setOpen={setOpen}
212
- className="w-full sm:w-[28rem]"
213
- portalId="otp-masterpass"
214
- >
215
- <div className="px-6 py-4">
216
- <h2 className="text-center text-xl text-primary-600 font-semibold">
217
- Verification Required
218
- </h2>
219
- <form
220
- onSubmit={(e) => {
221
- e.preventDefault();
222
- onSubmit({ otp_code: code });
223
- }}
224
- className="flex flex-col items-center mt-4"
225
- >
226
- <label
227
- htmlFor="otp_code"
228
- className="text-sm mb-1 text-gray-700"
229
- >
230
- SMS Code
231
- </label>
232
- <input
233
- id="otp_code"
234
- maxLength={6}
235
- value={code}
236
- onChange={(e) => setCode(e.target.value)}
237
- placeholder="••••••"
238
- className="border p-2 rounded w-full max-w-[200px] text-center tracking-widest"
239
- />
240
- <Button
241
- type="submit"
242
- className="mt-4 px-4 py-2 bg-blue-600 text-black rounded"
243
- >
244
- Verify
245
- </Button>
246
- {error && <p className="mt-2 text-xs text-red-500">{error}</p>}
247
- </form>
248
- <div className="mt-2 flex justify-center text-sm text-gray-600">
249
- {remainingSeconds > 0
250
- ? `Time remaining: ${remainingSeconds} seconds`
251
- : 'Time is up'}
252
- </div>
253
- <div className="mt-2 flex justify-center">
254
- <Button
255
- onClick={resendSms}
256
- disabled={loading}
257
- className="mt-4 text-sm underline text-secondary-500"
258
- >
259
- {resendSmsFetching ? 'Code sent' : 'Resend SMS code'}
260
- </Button>
261
- </div>
262
- </div>
263
- </Modal>
264
- );
265
- }
266
- }
267
- }}
268
- />
269
- ```
270
-
271
89
  ### Link Modal
272
90
 
273
- #### Props
274
-
275
- | Props | Type | Required | Description |
276
- | --- | --- | --- | --- |
277
- | translations | { [key: string]: string } | Optional | Translation object to customize all texts. Overrides default texts. |
278
- | renderer | RendererProps | Optional | Renderer functions that can be used to customize all subcomponents. |
279
-
280
- #### RendererProps
281
-
282
- | Props | Type | Description |
283
- | --- | --- | --- |
284
- | open | boolean | It is information whether the modal is open or not. |
285
- | setOpen | (open: boolean) => void | Used to manage modal on/off operation. |
286
- | onClick | () => void | It is the function that is called when the user clicks the "Use" button. |
287
- | loading | boolean | This is the loading status that will be displayed during the API request. |
288
- | error | string | If there is an error in the API response, a message is displayed in this field. |
289
-
290
91
  ##### File Path: src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx
291
92
 
292
- ### Usage Examples
293
-
294
- ##### Default Usage
295
-
296
93
  ```javascript
297
94
  <PluginModule
298
95
  component={Component.MasterpassLinkModal}
@@ -306,67 +103,10 @@ npx @akinon/projectzero@latest --plugins
306
103
  />
307
104
  ```
308
105
 
309
- ##### Customized Usage with Renderer
310
-
311
- ```javascript
312
- <PluginModule
313
- component={Component.MasterpassLinkModal}
314
- props={{
315
- renderer: {
316
- Content: ({ open, setOpen, onClick, loading, error }) => (
317
- <Modal
318
- open={open}
319
- setOpen={setOpen}
320
- className="w-full sm:w-[28rem]"
321
- portalId="masterpass-check-user"
322
- >
323
- <div className="p-10">
324
- <p className="text-sm text-center">
325
- You have cards registered to your Masterpass account. Do you want
326
- to use your cards?
327
- </p>
328
- <Button
329
- onClick={onClick}
330
- disabled={loading}
331
- className="bg-green-600 text-error w-full py-2 mt-4"
332
- >
333
- {loading ? 'Loading...' : 'Use'}
334
- </Button>
335
- {error && <p className="text-error text-sm">{error}</p>}
336
- </div>
337
- </Modal>
338
- )
339
- }
340
- }}
341
- />
342
- ```
343
-
344
106
  ### Card List
345
107
 
346
- #### Props
347
-
348
- | Props | Type | Required | Description |
349
- | --- | --- | --- | --- |
350
- | className | string | Optional | Gives an additional style class to the component's outer container. |
351
- | translations | { [key: string]: string } | Optional | Translation object to customize all texts. Overrides default texts. |
352
- | renderer | RendererProps | Optional | Renderer functions that can be used to customize all subcomponents. |
353
-
354
- #### RendererProps
355
-
356
- | Props | Type | Description |
357
- | --- | --- | --- |
358
- | Header | JSX.Element | Used to customize the title area at the top of the card list. |
359
- | CardItem | (params: { card, selectedCard, onSelect, DeleteButton }) => JSX.Element | It allows you to fully customize the card element. |
360
- | Loader | () => JSX.Element | Used to define a custom loader component to be displayed when loading cards. |
361
- | ErrorFallback | (params: { error: string; onRetry: () => void }) => JSX.Element | Custom widget to be shown if an error occurs while loading cards. |
362
- | SwitchPaymentButton | (props: { onClick: () => void; label: string }) => JSX.Element | Used to customize the "Pay with a new card" option. |
363
-
364
108
  ##### File Path: src/views/checkout/steps/payment/options/credit-card/index.tsx
365
109
 
366
- ### Usage Examples
367
-
368
- ##### Default Usage
369
-
370
110
  ```javascript
371
111
  <PluginModule
372
112
  component={Component.MasterpassCardList}
@@ -381,127 +121,10 @@ npx @akinon/projectzero@latest --plugins
381
121
  />
382
122
  ```
383
123
 
384
- ##### Customized Usage with Renderer
385
-
386
- ```javascript
387
- <PluginModule
388
- component={Component.MasterpassCardList}
389
- props={{
390
- className: 'px-10',
391
- form: {
392
- control,
393
- register,
394
- errors,
395
- setFormValue,
396
- clearErrors
397
- },
398
- renderer: {
399
- Header: () => (
400
- <div className="flex items-center gap-2 mt-4 px-10 text-success">
401
- Select a card to pay
402
- </div>
403
- ),
404
- Loader: () => (
405
- <div className="flex justify-center items-center p-10">
406
- <span className="text-lg font-bold text-error">
407
- Loading your cards...
408
- </span>
409
- </div>
410
- ),
411
- ErrorFallback: ({ error, onRetry }) => (
412
- <div className="text-center p-8">
413
- <h2 className="text-red-500 text-xl mb-4">Oops! {error}</h2>
414
- <Button onClick={onRetry}>Try Again</Button>
415
- </div>
416
- ),
417
- CardItem: ({ card, onSelect, DeleteButton, selectedCard }) => (
418
- <li
419
- key={card.UniqueId}
420
- className="p-4 cursor-pointer rounded-[10px] border-gray border space-x-5 pl-5 mb-6 md:mb-2.5"
421
- onClick={() => onSelect(card)}
422
- >
423
- <div className="flex justify-between items-center">
424
- <div className="flex items-center">
425
- <Checkbox
426
- key={
427
- selectedCard?.UniqueId === card.UniqueId
428
- ? 'selected'
429
- : 'not-selected'
430
- }
431
- checked={selectedCard?.UniqueId === card.UniqueId}
432
- onChange={() => onSelect(card)}
433
- className="mr-2"
434
- />
435
- <div>
436
- <h3 className="font-semibold">{card.Name}</h3>
437
- <p className="text-xs text-gray-500">{card.Value1}</p>
438
- </div>
439
- </div>
440
- <DeleteButton cardAliasName={card.Name} />
441
- </div>
442
- </li>
443
- ),
444
- SwitchPaymentButton: ({ onClick, label }) => (
445
- <div className="px-10">
446
- <button
447
- onClick={onClick}
448
- className="p-4 w-full text-left cursor-pointer rounded-[10px] border-gray border space-x-5 pl-5 mb-6 md:mb-2.5"
449
- >
450
- {label}
451
- </button>
452
- </div>
453
- )
454
- }
455
- }}
456
- />
457
- ```
458
-
459
124
  ### Card Registration
460
125
 
461
- #### Props
462
-
463
- | Props | Type | Required | Description |
464
- | --- | --- | --- | --- |
465
- | getValues | () => Record<string, string> | Required | Returns the values ​​of form fields. |
466
- | className | string | Optional | Gives an additional CSS class to the outer container. |
467
- | infoModalContent | React.ReactNode | Optional | Body content for the informational modal. |
468
- | infoModalIcon | React.ReactNode | Optional | Used to override the notification icon. |
469
- | translations | typeof defaultTranslations | Optional | Can be used to override default texts. |
470
- | renderer | RendererProps | Optional | Renderer functions that can be used to customize all subcomponents. |
471
-
472
- #### RendererProps
473
-
474
- | Props | Type | Description |
475
- | --- | --- | --- |
476
- | Content | (props: { isChecked, toggle, setIsInfoModalOpen, onChange, onSubmit, loading, error, showGoBackLink?, onClickGoBackLink? }) => JSX.Element | Used to render the main content. |
477
- | InfoModal | (props: { open: boolean; setOpen: (value: boolean) => void }) => JSX.Element | Can be used to override the notification modal. |
478
-
479
126
  ##### File Path: src/views/checkout/steps/payment/options/credit-card/index.tsx
480
127
 
481
- ### Usage Examples
482
-
483
- ##### Default Usage
484
-
485
- ```javascript
486
- <PluginModule
487
- component={Component.MasterpassCardRegistration}
488
- props={{
489
- // Do not remove getValues, it is used to get the form values
490
- getValues,
491
- translations: {
492
- enter_card_name: 'Enter card name',
493
- continue: 'Continue',
494
- pay_with_my_masterpass_card: 'Pay with my Masterpass card',
495
- terms_and_conditions: 'Masterpass terms and conditions',
496
- card_registration_consent:
497
- 'I want to store my card information in the Mastercard infrastructure and use it again in my next purchase.'
498
- }
499
- }}
500
- />
501
- ```
502
-
503
- ##### Customized Usage with className, infoModalContent, infoModalIcon
504
-
505
128
  ```javascript
506
129
  <PluginModule
507
130
  component={Component.MasterpassCardRegistration}
@@ -522,86 +145,3 @@ npx @akinon/projectzero@latest --plugins
522
145
  }}
523
146
  />
524
147
  ```
525
-
526
- ##### Customized Usage with Renderer
527
-
528
- ```javascript
529
- <PluginModule
530
- component={Component.MasterpassCardRegistration}
531
- props={{
532
- // Do not remove getValues, it is used to get the form values
533
- getValues,
534
- renderer: {
535
- InfoModal: ({ open, setOpen }) => (
536
- <Modal
537
- open={open}
538
- setOpen={setOpen}
539
- portalId="masterpass-info-modal"
540
- >
541
- masterpass information
542
- </Modal>
543
- ),
544
- Content: ({
545
- isChecked,
546
- toggle,
547
- setIsInfoModalOpen,
548
- onChange,
549
- onSubmit,
550
- loading,
551
- error,
552
- showGoBackLink,
553
- onClickGoBackLink
554
- }) => (
555
- <div className="bg-[#F8F8F8] mx-10 mb-5 px-2 py-1">
556
- <div className="flex items-center gap-2 pb-4 mb-4">
557
- <Checkbox checked={isChecked} onChange={toggle} />
558
- <h1>Masterpass</h1>
559
- <div>
560
- <Icon
561
- name="info"
562
- size={15}
563
- className="fill-[#000000] cursor-pointer"
564
- onClick={() => {
565
- setIsInfoModalOpen(true);
566
- }}
567
- />
568
- </div>
569
- </div>
570
- <p className="text-xs">
571
- I want to store my card information in the Mastercard infrastructure and use it again in my next purchase.
572
- </p>
573
- {isChecked && (
574
- <>
575
- <Input
576
- label="Give your card a name"
577
- onChange={(e) =>
578
- onChange((e.target as HTMLInputElement).value)
579
- }
580
- className="mt-2"
581
- />
582
- <Button
583
- onClick={onSubmit}
584
- className="bg-green-600 text-black w-full mt-3"
585
- >
586
- {loading ? 'Loading...' : 'Save'}
587
- </Button>
588
- {error && (
589
- <p className="text-xs text-red-600 mt-2">🚨 {error}</p>
590
- )}
591
- </>
592
- )}
593
- {showGoBackLink && (
594
- <div>
595
- <button
596
- onClick={onClickGoBackLink}
597
- className="text-xs text-red-600 underline mt-3"
598
- >
599
- I want to pay with my card registered to Masterpass.
600
- </button>
601
- </div>
602
- )}
603
- </div>
604
- )
605
- }
606
- }}
607
- ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass",
3
- "version": "1.91.0-rc.2",
3
+ "version": "1.91.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
@@ -48,25 +48,6 @@ const defaultTranslations = {
48
48
  security_code_info: 'What’s CVC?'
49
49
  };
50
50
 
51
- interface RendererProps {
52
- Header?: () => JSX.Element;
53
- CardItem?: (params: {
54
- card: any;
55
- selectedCard: any;
56
- onSelect: (card: any) => Promise<void>;
57
- DeleteButton?: React.FC<{ cardAliasName: string; onDelete: () => void }>;
58
- }) => JSX.Element;
59
- Loader?: () => JSX.Element;
60
- ErrorFallback?: (params: {
61
- error: string;
62
- onRetry: () => void;
63
- }) => JSX.Element;
64
- SwitchPaymentButton?: (props: {
65
- onClick: () => void;
66
- label: string;
67
- }) => JSX.Element;
68
- }
69
-
70
51
  export interface MasterpassCardListProps {
71
52
  className?: string;
72
53
  translations?: typeof defaultTranslations;
@@ -77,14 +58,12 @@ export interface MasterpassCardListProps {
77
58
  register: UseFormRegister<any>;
78
59
  setFormValue: UseFormSetValue<any>;
79
60
  };
80
- renderer?: RendererProps;
81
61
  }
82
62
 
83
63
  export const MasterpassCardList = ({
84
64
  className,
85
65
  translations,
86
- form,
87
- renderer
66
+ form
88
67
  }: MasterpassCardListProps) => {
89
68
  const { preOrder } = useAppSelector((state) => state.checkout);
90
69
  const { accountStatus, isDirectPurchase, selectedCard, cvcRequired } =
@@ -94,28 +73,7 @@ export const MasterpassCardList = ({
94
73
  const { DeleteButton } = useDeleteCard();
95
74
  const dispatch = useAppDispatch();
96
75
 
97
- const onSelectCard = async (card: any) => {
98
- if (selectedCard?.UniqueId !== card.UniqueId) {
99
- await setMasterpassBinNumber(card.Value1.substring(0, 6)).unwrap();
100
- dispatch(setSelectedCard(card));
101
- dispatch(setCvcRequired(false));
102
- if (form) {
103
- form.setFormValue('card_cvv', '');
104
- form.clearErrors('card_cvv');
105
- }
106
- }
107
- };
108
-
109
- const switchPaymentButton = renderer?.SwitchPaymentButton ? (
110
- renderer.SwitchPaymentButton({
111
- onClick: () => {
112
- dispatch(setIsDirectPurchase(true));
113
- dispatch(setInstallmentOptions([]));
114
- },
115
- label:
116
- translations?.pay_with_new_card ?? defaultTranslations.pay_with_new_card
117
- })
118
- ) : (
76
+ const switchPaymentButton = (
119
77
  <a
120
78
  href="#"
121
79
  className="text-xs underline"
@@ -134,9 +92,7 @@ export const MasterpassCardList = ({
134
92
  }
135
93
 
136
94
  if (loading) {
137
- return renderer?.Loader ? (
138
- renderer.Loader()
139
- ) : (
95
+ return (
140
96
  <div className="p-5">
141
97
  <LoaderSpinner className="w-8 h-8" />
142
98
  </div>
@@ -144,14 +100,18 @@ export const MasterpassCardList = ({
144
100
  }
145
101
 
146
102
  if (error && !isDirectPurchase) {
147
- return renderer?.ErrorFallback ? (
148
- renderer.ErrorFallback({ error, onRetry: refreshCards })
149
- ) : (
103
+ return (
150
104
  <div className="flex flex-col items-center">
151
105
  <div className="p-5">{error}</div>
152
- <Button className="w-48 mb-5" onClick={refreshCards}>
106
+ <Button
107
+ className="w-48 mb-5"
108
+ onClick={() => {
109
+ refreshCards();
110
+ }}
111
+ >
153
112
  {translations?.retryFetchCards ?? defaultTranslations.retryFetchCards}
154
113
  </Button>
114
+
155
115
  {switchPaymentButton}
156
116
  </div>
157
117
  );
@@ -166,75 +126,38 @@ export const MasterpassCardList = ({
166
126
  }
167
127
 
168
128
  return (
169
- <div className="w-full">
170
- {renderer?.Header ? (
171
- renderer.Header()
172
- ) : (
173
- <>
174
- <Image
175
- className="mb-4"
176
- width={140}
177
- height={25}
178
- src={masterpassLogo.src}
179
- alt="Masterpass Logo"
180
- />
181
- <p className="text-xs">
182
- {translations?.title ?? defaultTranslations.title}
183
- </p>
184
- </>
185
- )}
186
-
187
- <ul className={twMerge('mt-4 text-xs', className)}>
129
+ <div className={twMerge('w-full', className)}>
130
+ <Image
131
+ className="mb-4"
132
+ width={140}
133
+ height={25}
134
+ src={masterpassLogo.src}
135
+ alt="Masterpass Logo"
136
+ />
137
+ <p className="text-xs">
138
+ {translations?.title ?? defaultTranslations.title}
139
+ </p>
140
+ <ul className="mt-4 text-xs">
188
141
  {cards?.map((card) => {
189
- const cvcField =
190
- selectedCard?.UniqueId === card.UniqueId && form && cvcRequired ? (
191
- <div
192
- className={twMerge(
193
- clsx('flex items-center justify-start mt-2', {
194
- 'items-baseline': form.errors.card_cvv
195
- })
196
- )}
197
- >
198
- <label
199
- className="text-xs text-black-400 mr-1.5"
200
- htmlFor="card_cvv"
201
- >
202
- {translations?.security_code ??
203
- defaultTranslations.security_code}
204
- </label>
205
- <Input
206
- format="###"
207
- mask="_"
208
- control={form.control}
209
- allowEmptyFormatting={true}
210
- {...form.register('card_cvv')}
211
- error={form.errors.card_cvv}
212
- />
213
- <div className="group relative flex items-center justify-start text-gray-600 cursor-pointer ml-2 transition-all hover:text-secondary">
214
- <span className="text-xs underline">
215
- {translations?.security_code_info ??
216
- defaultTranslations.security_code_info}
217
- </span>
218
- <Icon name="cvc" size={16} className="leading-none ml-2" />
219
- <div className="hidden group-hover:block absolute right-0 bottom-5 w-[11rem] lg:w-[21rem] lg:left-auto lg:right-auto border-2">
220
- <Image src="/cvv.jpg" alt="Cvv" width={385} height={262} />
221
- </div>
222
- </div>
223
- </div>
224
- ) : null;
225
-
226
- return renderer?.CardItem ? (
227
- renderer.CardItem({
228
- card,
229
- selectedCard,
230
- onSelect: onSelectCard,
231
- DeleteButton
232
- })
233
- ) : (
142
+ return (
234
143
  <li
235
144
  key={card.UniqueId}
236
145
  className="p-4 mb-2 border-2 border-gray-200 flex flex-col space-x-2 cursor-pointer"
237
- onClick={() => onSelectCard(card)}
146
+ 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
+ }
160
+ }}
238
161
  >
239
162
  <div className="flex justify-between items-center">
240
163
  <input
@@ -260,9 +183,49 @@ export const MasterpassCardList = ({
260
183
  alt={card.Name}
261
184
  />
262
185
  </label>
186
+
263
187
  <DeleteButton cardAliasName={card.Name} />
264
188
  </div>
265
- {cvcField}
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
+ )}
266
229
  </li>
267
230
  );
268
231
  })}
@@ -32,31 +32,13 @@ export const MasterpassCardRegistration = ({
32
32
  className,
33
33
  infoModalContent,
34
34
  infoModalIcon,
35
- translations,
36
- renderer = {}
35
+ translations
37
36
  }: {
38
37
  getValues: () => Record<string, string | number | boolean>;
39
38
  className?: string;
40
39
  infoModalContent?: React.ReactNode;
41
40
  infoModalIcon?: React.ReactNode;
42
41
  translations?: typeof defaultTranslations;
43
- renderer?: {
44
- Content?: (props: {
45
- isChecked: boolean;
46
- toggle: () => void;
47
- setIsInfoModalOpen: (value: boolean) => void;
48
- onChange: (value: string) => void;
49
- onSubmit: () => void;
50
- loading: boolean;
51
- error: string | null;
52
- showGoBackLink?: boolean;
53
- onClickGoBackLink?: () => void;
54
- }) => JSX.Element;
55
- InfoModal?: (props: {
56
- open: boolean;
57
- setOpen: (value: boolean) => void;
58
- }) => JSX.Element;
59
- };
60
42
  }) => {
61
43
  const { preOrder } = useAppSelector((state: RootState) => state.checkout);
62
44
  const { msisdn, token, language, otp, isDirectPurchase, accountStatus } =
@@ -186,56 +168,13 @@ export const MasterpassCardRegistration = ({
186
168
  return null;
187
169
  }
188
170
 
189
- if (renderer.Content) {
190
- return (
191
- <>
192
- {renderer.InfoModal ? (
193
- <renderer.InfoModal
194
- open={isInfoModalOpen}
195
- setOpen={setIsInfoModalOpen}
196
- />
197
- ) : (
198
- <InfoModal
199
- open={isInfoModalOpen}
200
- setOpen={setIsInfoModalOpen}
201
- content={infoModalContent}
202
- />
203
- )}
204
-
205
- <renderer.Content
206
- isChecked={isAgreementChecked}
207
- toggle={() => setIsAgreementChecked(!isAgreementChecked)}
208
- setIsInfoModalOpen={setIsInfoModalOpen}
209
- onChange={(value) => setAccountAliasName(value)}
210
- onSubmit={registerCard}
211
- loading={isBusy}
212
- error={formError}
213
- showGoBackLink={
214
- accountStatus !== MasterpassStatus.NoAccount && cards?.length > 0
215
- }
216
- onClickGoBackLink={() => {
217
- dispatch(setIsDirectPurchase(false));
218
- dispatch(setInstallmentOptions([]));
219
- }}
220
- />
221
- </>
222
- );
223
- }
224
-
225
171
  return (
226
172
  <div className={twMerge('w-full', className)}>
227
- {renderer.InfoModal ? (
228
- <renderer.InfoModal
229
- open={isInfoModalOpen}
230
- setOpen={setIsInfoModalOpen}
231
- />
232
- ) : (
233
- <InfoModal
234
- open={isInfoModalOpen}
235
- setOpen={setIsInfoModalOpen}
236
- content={infoModalContent}
237
- />
238
- )}
173
+ <InfoModal
174
+ open={isInfoModalOpen}
175
+ setOpen={setIsInfoModalOpen}
176
+ content={infoModalContent}
177
+ />
239
178
 
240
179
  <div className="border border-[#ddd]">
241
180
  <div className="p-4">
@@ -15,39 +15,15 @@ const defaultTranslations = {
15
15
 
16
16
  export interface MasterpassDeleteConfirmationModalProps {
17
17
  translations?: typeof defaultTranslations;
18
- renderer?: {
19
- Content?: (props: {
20
- open: boolean;
21
- setOpen: (open: boolean) => void;
22
- onConfirm: () => void;
23
- onCancel: () => void;
24
- loading: boolean;
25
- error: string | null;
26
- }) => JSX.Element;
27
- };
28
18
  }
29
19
 
30
20
  export const MasterpassDeleteConfirmationModal = ({
31
- translations,
32
- renderer = {}
21
+ translations
33
22
  }: MasterpassDeleteConfirmationModalProps) => {
34
23
  const { deletion } = useAppSelector((state) => state.masterpass);
35
24
  const { deleteCard, isLoading, error } = useDeleteCard();
36
25
  const dispatch = useAppDispatch();
37
26
 
38
- if (renderer.Content) {
39
- return (
40
- <renderer.Content
41
- open={deletion.isModalVisible}
42
- setOpen={() => dispatch(setDeletionModalVisible(false))}
43
- onConfirm={deleteCard}
44
- onCancel={() => dispatch(setDeletionModalVisible(false))}
45
- loading={isLoading}
46
- error={error}
47
- />
48
- );
49
- }
50
-
51
27
  return (
52
28
  <Modal
53
29
  portalId="masterpass-remove-card-modal"
@@ -21,20 +21,10 @@ const defaultTranslations = {
21
21
 
22
22
  export interface MasterpassLinkModalProps {
23
23
  translations?: typeof defaultTranslations;
24
- renderer?: {
25
- Content?: (props: {
26
- open: boolean;
27
- setOpen: (open: boolean) => void;
28
- onClick: () => void;
29
- loading: boolean;
30
- error: string | null;
31
- }) => JSX.Element;
32
- };
33
24
  }
34
25
 
35
26
  export const MasterpassLinkModal = ({
36
- translations,
37
- renderer = {}
27
+ translations
38
28
  }: MasterpassLinkModalProps) => {
39
29
  const { msisdn, token, accountStatus, otp, language } = useAppSelector(
40
30
  (state) => state.masterpass
@@ -103,18 +93,6 @@ export const MasterpassLinkModal = ({
103
93
  }
104
94
  }, [otp.response]);
105
95
 
106
- if (renderer.Content) {
107
- return (
108
- <renderer.Content
109
- open={isOpen}
110
- setOpen={setIsOpen}
111
- onClick={onLinkButtonClick}
112
- loading={isLoading}
113
- error={error}
114
- />
115
- );
116
- }
117
-
118
96
  return (
119
97
  <Modal
120
98
  portalId="masterpass-check-user"
@@ -17,24 +17,10 @@ export interface MasterpassOtpModalProps {
17
17
  translations?: {
18
18
  5001?: string;
19
19
  } & OtpFormProps['translations'];
20
- renderer?: {
21
- Content?: (props: {
22
- open: boolean;
23
- setOpen: (open: boolean) => void;
24
- onSubmit: (data: { otp_code: string }) => void;
25
- loading: boolean;
26
- error: string | null;
27
- resendSms: () => void;
28
- resendSmsFetching: boolean;
29
- targetDate: number;
30
- otpRef: string | null;
31
- }) => JSX.Element;
32
- };
33
20
  }
34
21
 
35
22
  export const MasterpassOtpModal = ({
36
- translations,
37
- renderer = {}
23
+ translations
38
24
  }: MasterpassOtpModalProps) => {
39
25
  const { token, otp, language } = useAppSelector((state) => state.masterpass);
40
26
  const [isModalOpen, setIsModalOpen] = useState(false);
@@ -125,22 +111,6 @@ export const MasterpassOtpModal = ({
125
111
  }
126
112
  }, [isModalOpen]);
127
113
 
128
- if (renderer.Content) {
129
- return (
130
- <renderer.Content
131
- open={isModalOpen}
132
- setOpen={handleModalVisibility}
133
- onSubmit={onFormSubmit}
134
- loading={isBusy}
135
- error={otpError}
136
- resendSms={resendSms}
137
- resendSmsFetching={isBusy}
138
- targetDate={otpTime}
139
- otpRef={otpRef}
140
- />
141
- );
142
- }
143
-
144
114
  return (
145
115
  <Modal
146
116
  portalId="otp-masterpass"