@akinon/pz-masterpass-rest 2.0.9 → 2.0.10-rc.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,5 +1,14 @@
1
1
  # @akinon/pz-masterpass-rest
2
2
 
3
+ ## 2.0.10-rc.0
4
+
5
+ ### Patch Changes
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
+ - 63a72000: ZERO-3895: enhance payment processing with additional fields support
11
+
3
12
  ## 2.0.9
4
13
 
5
14
  ## 2.0.8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass-rest",
3
- "version": "2.0.9",
3
+ "version": "2.0.10-rc.0",
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": "5.2.2"
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={23}
187
+ maxLength={19}
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 disabled:opacity-50 disabled:cursor-not-allowed"
121
+ className="w-full cursor-pointer bg-[#000000] text-[#ffffff] hover:bg-[#ffffff] hover:text-[#000000] border border-solid border-[#000000] disabled:opacity-50 disabled:cursor-not-allowed"
122
122
  >
123
123
  {paymentLoading ? (
124
124
  <div className="flex items-center justify-center">
@@ -204,15 +204,21 @@ 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">{getTitle()}</h3>
207
+ <h3 className="text-center mt-4 text-lg font-semibold">
208
+ {getTitle()}
209
+ </h3>
208
210
  )}
209
- <p className="text-center mt-2 text-sm text-gray-600">{getDescription()}</p>
211
+ <p className="text-center mt-2 text-sm text-gray-600">
212
+ {getDescription()}
213
+ </p>
210
214
  <div className="flex flex-col gap-3 p-5 w-3/4 m-auto">
211
215
  <Input
212
216
  type="text"
213
217
  value={otp}
214
218
  onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
215
- setOtp(e.target.value.replace(/\D/g, '').slice(0, getMaxLength()));
219
+ setOtp(
220
+ e.target.value.replace(/\D/g, '').slice(0, getMaxLength())
221
+ );
216
222
  setError(null);
217
223
  }}
218
224
  maxLength={getMaxLength()}
@@ -222,7 +228,9 @@ const OTPModal: React.FC<OTPModalProps> = ({
222
228
  placeholder={getPlaceholder()}
223
229
  />
224
230
  {getHelperText() && (
225
- <p className="text-xs text-gray-500 text-center">{getHelperText()}</p>
231
+ <p className="text-xs text-gray-500 text-center">
232
+ {getHelperText()}
233
+ </p>
226
234
  )}
227
235
  {error && (
228
236
  <p className="text-[#d72b01] text-xs text-center">{error}</p>
@@ -40,7 +40,16 @@ export const useMasterpassAccount = () => {
40
40
 
41
41
  const initializeAccount = useCallback(
42
42
  async (newTokenData: any, rawToken?: string) => {
43
- if (!newTokenData?.AccountKey) return;
43
+ if (!newTokenData?.AccountKey) {
44
+ dispatch(
45
+ setAccountStatus({
46
+ isAccountNotFound: false,
47
+ isAccountNotLinked: true,
48
+ shouldShowDirectForm: true
49
+ })
50
+ );
51
+ return;
52
+ }
44
53
 
45
54
  const accountService = new AccountService(rawToken || token, newTokenData?.MerchantId);
46
55
 
@@ -126,7 +135,10 @@ export const useMasterpassAccount = () => {
126
135
  dispatch(resetState());
127
136
  }, [dispatch]);
128
137
 
129
- const refreshToken = async (options?: { three_d?: boolean; skipReset?: boolean }) => {
138
+ const refreshToken = async (options?: {
139
+ three_d?: boolean;
140
+ skipReset?: boolean;
141
+ }) => {
130
142
  if (options?.three_d !== false && !options?.skipReset) {
131
143
  resetData();
132
144
  }
@@ -218,8 +230,12 @@ export const useMasterpassAccount = () => {
218
230
  informationModalData: {
219
231
  type: 'warning',
220
232
  title: texts?.sessionExpiredTitle || 'Session Expired',
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.',
233
+ message:
234
+ texts?.sessionExpiredMessage ||
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.',
223
239
  buttonText: texts?.sessionExpiredButton || 'Start Again'
224
240
  }
225
241
  })
@@ -335,7 +351,7 @@ export const useMasterpassAccount = () => {
335
351
  const activeMerchantId = freshResult?.merchantId || tokenData?.MerchantId;
336
352
 
337
353
  if (!activeTokenData?.AccountKey) {
338
- throw new Error('Token data not available');
354
+ return { success: false, message: '' };
339
355
  }
340
356
 
341
357
  const accountService = new AccountService(activeToken, activeMerchantId);
@@ -251,10 +251,6 @@ export const useMasterpassPayment = () => {
251
251
  const activeToken = freshResult?.token;
252
252
  const activeMerchantId = freshResult?.merchantId || tokenData?.MerchantId;
253
253
 
254
- if (!activeTokenData?.AccountKey) {
255
- return { success: false, message: 'Token data not available' };
256
- }
257
-
258
254
  const prepareResult = await prepareMasterpassOrder({
259
255
  use_three_d: paymentState.useThreeD
260
256
  }).unwrap();
@@ -268,13 +264,13 @@ export const useMasterpassPayment = () => {
268
264
  cardHolderName: newCardFormData.cardholderName || '',
269
265
  cardAlias: newCardFormData.cardAlias || '',
270
266
  expiryDate: newCardFormData.expiryDate,
271
- accountKey: activeTokenData.AccountKey,
267
+ accountKey: activeTokenData?.AccountKey || '',
272
268
  amount: prepareResult.pre_order?.total_amount_with_interest,
273
269
  orderNo: prepareResult.context_list?.[0]?.page_context?.order_no,
274
270
  currencyCode: currency,
275
271
  installmentCount: selectedInstallment.installment_count,
276
- authenticationMethod: activeTokenData.AuthenticationMethod,
277
- secure3DModel: activeTokenData.Secure3dType,
272
+ authenticationMethod: activeTokenData?.AuthenticationMethod,
273
+ secure3DModel: activeTokenData?.Secure3dType,
278
274
  terminalGroupId,
279
275
  acquirerIcaNumber: bankIca,
280
276
  additionalFields:
@@ -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, 23);
12
+ return formatted.substring(0, 19);
13
13
  };
14
14
 
15
15
  export const formatExpiryDate = (value: string): string => {