@akinon/pz-masterpass-rest 2.0.10-rc.0 → 2.0.11-beta.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,13 +1,8 @@
1
1
  # @akinon/pz-masterpass-rest
2
2
 
3
- ## 2.0.10-rc.0
3
+ ## 2.0.11-beta.0
4
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
5
+ ## 2.0.10
11
6
 
12
7
  ## 2.0.9
13
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass-rest",
3
- "version": "2.0.10-rc.0",
3
+ "version": "2.0.11-beta.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={19}
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 bg-[#000000] text-[#ffffff] hover:bg-[#ffffff] hover:text-[#000000] border border-solid border-[#000000] disabled:opacity-50 disabled:cursor-not-allowed"
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
- 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.',
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
- return { success: false, message: '' };
338
+ throw new Error('Token data not available');
355
339
  }
356
340
 
357
341
  const accountService = new AccountService(activeToken, activeMerchantId);
@@ -251,6 +251,10 @@ 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
+
254
258
  const prepareResult = await prepareMasterpassOrder({
255
259
  use_three_d: paymentState.useThreeD
256
260
  }).unwrap();
@@ -264,13 +268,13 @@ export const useMasterpassPayment = () => {
264
268
  cardHolderName: newCardFormData.cardholderName || '',
265
269
  cardAlias: newCardFormData.cardAlias || '',
266
270
  expiryDate: newCardFormData.expiryDate,
267
- accountKey: activeTokenData?.AccountKey || '',
271
+ accountKey: activeTokenData.AccountKey,
268
272
  amount: prepareResult.pre_order?.total_amount_with_interest,
269
273
  orderNo: prepareResult.context_list?.[0]?.page_context?.order_no,
270
274
  currencyCode: currency,
271
275
  installmentCount: selectedInstallment.installment_count,
272
- authenticationMethod: activeTokenData?.AuthenticationMethod,
273
- secure3DModel: activeTokenData?.Secure3dType,
276
+ authenticationMethod: activeTokenData.AuthenticationMethod,
277
+ secure3DModel: activeTokenData.Secure3dType,
274
278
  terminalGroupId,
275
279
  acquirerIcaNumber: bankIca,
276
280
  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, 19);
12
+ return formatted.substring(0, 23);
13
13
  };
14
14
 
15
15
  export const formatExpiryDate = (value: string): string => {