@akinon/pz-masterpass-rest 2.0.33-rc.0 → 2.0.33
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 +1 -5
- package/package.json +2 -2
- package/src/components/credit-card-form.tsx +1 -1
- package/src/components/installment-list.tsx +1 -1
- package/src/components/otp-modal.tsx +4 -12
- package/src/hooks/useMasterpassAccount.ts +5 -21
- package/src/hooks/useMasterpassPayment.ts +7 -3
- package/src/utils/card-utils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
# @akinon/pz-masterpass-rest
|
|
2
2
|
|
|
3
|
-
## 2.0.33
|
|
3
|
+
## 2.0.33
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- 823a4449: ZERO-4193: Upgrade TypeScript to version 5.2.2 across multiple packages
|
|
8
|
-
- 5da13fff: ZERO-4358: fix masterpass-rest guest checkout flow
|
|
9
|
-
- fb4aa9b4: ZERO-4333: update maxLength for cardNumber input and enhance button styling in installment list
|
|
10
7
|
- d51fa68e: ZERO-4399: add card rewards to pz-masterpass-rest
|
|
11
|
-
- 63a72000: ZERO-3895: enhance payment processing with additional fields support
|
|
12
8
|
|
|
13
9
|
## 2.0.32
|
|
14
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/pz-masterpass-rest",
|
|
3
|
-
"version": "2.0.33
|
|
3
|
+
"version": "2.0.33",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"description": "Modern React-based Masterpass REST API integration package for ProjectZero e-commerce platform",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "18.2.27",
|
|
33
33
|
"@types/react-dom": "18.2.12",
|
|
34
|
-
"typescript": "
|
|
34
|
+
"typescript": "5.2.2"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -184,7 +184,7 @@ const CreditCardForm: React.FC<CreditCardFormProps> = ({
|
|
|
184
184
|
setValue('cardNumber', formatted, { shouldValidate: true });
|
|
185
185
|
}}
|
|
186
186
|
error={errors.cardNumber}
|
|
187
|
-
maxLength={
|
|
187
|
+
maxLength={23}
|
|
188
188
|
className="pr-20"
|
|
189
189
|
/>
|
|
190
190
|
{cardType !== 'unknown' && (
|
|
@@ -118,7 +118,7 @@ const InstallmentList: React.FC<InstallmentListProps> = ({
|
|
|
118
118
|
<Button
|
|
119
119
|
onClick={onProceedToPayment}
|
|
120
120
|
disabled={isLoading || paymentLoading}
|
|
121
|
-
className="w-full cursor-pointer
|
|
121
|
+
className="w-full cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
|
122
122
|
>
|
|
123
123
|
{paymentLoading ? (
|
|
124
124
|
<div className="flex items-center justify-center">
|
|
@@ -204,21 +204,15 @@ const OTPModal: React.FC<OTPModalProps> = ({
|
|
|
204
204
|
>
|
|
205
205
|
<div className="px-6">
|
|
206
206
|
{getTitle() && (
|
|
207
|
-
<h3 className="text-center mt-4 text-lg font-semibold">
|
|
208
|
-
{getTitle()}
|
|
209
|
-
</h3>
|
|
207
|
+
<h3 className="text-center mt-4 text-lg font-semibold">{getTitle()}</h3>
|
|
210
208
|
)}
|
|
211
|
-
<p className="text-center mt-2 text-sm text-gray-600">
|
|
212
|
-
{getDescription()}
|
|
213
|
-
</p>
|
|
209
|
+
<p className="text-center mt-2 text-sm text-gray-600">{getDescription()}</p>
|
|
214
210
|
<div className="flex flex-col gap-3 p-5 w-3/4 m-auto">
|
|
215
211
|
<Input
|
|
216
212
|
type="text"
|
|
217
213
|
value={otp}
|
|
218
214
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
219
|
-
setOtp(
|
|
220
|
-
e.target.value.replace(/\D/g, '').slice(0, getMaxLength())
|
|
221
|
-
);
|
|
215
|
+
setOtp(e.target.value.replace(/\D/g, '').slice(0, getMaxLength()));
|
|
222
216
|
setError(null);
|
|
223
217
|
}}
|
|
224
218
|
maxLength={getMaxLength()}
|
|
@@ -228,9 +222,7 @@ const OTPModal: React.FC<OTPModalProps> = ({
|
|
|
228
222
|
placeholder={getPlaceholder()}
|
|
229
223
|
/>
|
|
230
224
|
{getHelperText() && (
|
|
231
|
-
<p className="text-xs text-gray-500 text-center">
|
|
232
|
-
{getHelperText()}
|
|
233
|
-
</p>
|
|
225
|
+
<p className="text-xs text-gray-500 text-center">{getHelperText()}</p>
|
|
234
226
|
)}
|
|
235
227
|
{error && (
|
|
236
228
|
<p className="text-[#d72b01] text-xs text-center">{error}</p>
|
|
@@ -40,16 +40,7 @@ export const useMasterpassAccount = () => {
|
|
|
40
40
|
|
|
41
41
|
const initializeAccount = useCallback(
|
|
42
42
|
async (newTokenData: any, rawToken?: string) => {
|
|
43
|
-
if (!newTokenData?.AccountKey)
|
|
44
|
-
dispatch(
|
|
45
|
-
setAccountStatus({
|
|
46
|
-
isAccountNotFound: false,
|
|
47
|
-
isAccountNotLinked: true,
|
|
48
|
-
shouldShowDirectForm: true
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
43
|
+
if (!newTokenData?.AccountKey) return;
|
|
53
44
|
|
|
54
45
|
const accountService = new AccountService(rawToken || token, newTokenData?.MerchantId);
|
|
55
46
|
|
|
@@ -135,10 +126,7 @@ export const useMasterpassAccount = () => {
|
|
|
135
126
|
dispatch(resetState());
|
|
136
127
|
}, [dispatch]);
|
|
137
128
|
|
|
138
|
-
const refreshToken = async (options?: {
|
|
139
|
-
three_d?: boolean;
|
|
140
|
-
skipReset?: boolean;
|
|
141
|
-
}) => {
|
|
129
|
+
const refreshToken = async (options?: { three_d?: boolean; skipReset?: boolean }) => {
|
|
142
130
|
if (options?.three_d !== false && !options?.skipReset) {
|
|
143
131
|
resetData();
|
|
144
132
|
}
|
|
@@ -230,12 +218,8 @@ export const useMasterpassAccount = () => {
|
|
|
230
218
|
informationModalData: {
|
|
231
219
|
type: 'warning',
|
|
232
220
|
title: texts?.sessionExpiredTitle || 'Session Expired',
|
|
233
|
-
message:
|
|
234
|
-
|
|
235
|
-
'Your session has expired due to inactivity. Please restart the process to continue.',
|
|
236
|
-
secondaryMessage:
|
|
237
|
-
texts?.sessionExpiredSecondaryMessage ||
|
|
238
|
-
'For security reasons, verification codes are only valid for a limited time.',
|
|
221
|
+
message: texts?.sessionExpiredMessage || 'Your session has expired due to inactivity. Please restart the process to continue.',
|
|
222
|
+
secondaryMessage: texts?.sessionExpiredSecondaryMessage || 'For security reasons, verification codes are only valid for a limited time.',
|
|
239
223
|
buttonText: texts?.sessionExpiredButton || 'Start Again'
|
|
240
224
|
}
|
|
241
225
|
})
|
|
@@ -351,7 +335,7 @@ export const useMasterpassAccount = () => {
|
|
|
351
335
|
const activeMerchantId = freshResult?.merchantId || tokenData?.MerchantId;
|
|
352
336
|
|
|
353
337
|
if (!activeTokenData?.AccountKey) {
|
|
354
|
-
|
|
338
|
+
throw new Error('Token data not available');
|
|
355
339
|
}
|
|
356
340
|
|
|
357
341
|
const accountService = new AccountService(activeToken, activeMerchantId);
|
|
@@ -347,6 +347,10 @@ export const useMasterpassPayment = (
|
|
|
347
347
|
const activeToken = freshResult?.token;
|
|
348
348
|
const activeMerchantId = freshResult?.merchantId || tokenData?.MerchantId;
|
|
349
349
|
|
|
350
|
+
if (!activeTokenData?.AccountKey) {
|
|
351
|
+
return { success: false, message: 'Token data not available' };
|
|
352
|
+
}
|
|
353
|
+
|
|
350
354
|
const prepareResult = await prepareMasterpassOrder({
|
|
351
355
|
use_three_d: paymentState.useThreeD
|
|
352
356
|
}).unwrap();
|
|
@@ -360,13 +364,13 @@ export const useMasterpassPayment = (
|
|
|
360
364
|
cardHolderName: newCardFormData.cardholderName || '',
|
|
361
365
|
cardAlias: newCardFormData.cardAlias || '',
|
|
362
366
|
expiryDate: newCardFormData.expiryDate,
|
|
363
|
-
accountKey: activeTokenData
|
|
367
|
+
accountKey: activeTokenData.AccountKey,
|
|
364
368
|
amount: prepareResult.pre_order?.total_amount_with_interest,
|
|
365
369
|
orderNo: prepareResult.context_list?.[0]?.page_context?.order_no,
|
|
366
370
|
currencyCode: currency,
|
|
367
371
|
installmentCount: selectedInstallment.installment_count,
|
|
368
|
-
authenticationMethod: activeTokenData
|
|
369
|
-
secure3DModel: activeTokenData
|
|
372
|
+
authenticationMethod: activeTokenData.AuthenticationMethod,
|
|
373
|
+
secure3DModel: activeTokenData.Secure3dType,
|
|
370
374
|
terminalGroupId,
|
|
371
375
|
acquirerIcaNumber: bankIca,
|
|
372
376
|
additionalFields:
|
package/src/utils/card-utils.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const formatCardNumber = (value: string): string => {
|
|
|
9
9
|
|
|
10
10
|
const formatted = cleanValue.replace(/(\d{4})(?=\d)/g, '$1 ');
|
|
11
11
|
|
|
12
|
-
return formatted.substring(0,
|
|
12
|
+
return formatted.substring(0, 23);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const formatExpiryDate = (value: string): string => {
|