@akinon/pz-masterpass-rest 1.111.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 +8 -0
- package/README.md +96 -0
- package/package.json +36 -0
- package/src/assets/img/mp_amex.jpg +0 -0
- package/src/assets/img/mp_mastercard.png +0 -0
- package/src/assets/img/mp_masterpass-logo.png +0 -0
- package/src/assets/img/mp_other.png +0 -0
- package/src/assets/img/mp_troy.png +0 -0
- package/src/assets/img/mp_visa.png +0 -0
- package/src/assets/masterpass-javascript-sdk-web.min.js +1 -0
- package/src/components/card-list.tsx +192 -0
- package/src/components/confirmation-modal.tsx +65 -0
- package/src/components/credit-card-form.tsx +341 -0
- package/src/components/installment-list.tsx +177 -0
- package/src/components/link-modal.tsx +61 -0
- package/src/components/otp-modal.tsx +129 -0
- package/src/components/payment-method-selector.tsx +137 -0
- package/src/hooks/useMasterpassAccount.ts +393 -0
- package/src/hooks/useMasterpassPayment.ts +231 -0
- package/src/hooks/useMasterpassScript.ts +138 -0
- package/src/hooks/useMasterpassToken.ts +79 -0
- package/src/index.d.ts +84 -0
- package/src/index.ts +23 -0
- package/src/redux/api.ts +244 -0
- package/src/redux/reducer.ts +279 -0
- package/src/services/account.ts +109 -0
- package/src/services/payment.ts +131 -0
- package/src/services/verify.ts +39 -0
- package/src/types/account.types.ts +179 -0
- package/src/types/custom-render.types.ts +212 -0
- package/src/types/payment.types.ts +139 -0
- package/src/types/verify.types.ts +14 -0
- package/src/utils/card-utils.ts +121 -0
- package/src/utils/constants.ts +4 -0
- package/src/utils/masterpass-sdk.ts +31 -0
- package/src/utils/payment-constants.ts +31 -0
- package/src/utils/payment-utils.ts +100 -0
- package/src/utils/response-handler.ts +179 -0
- package/src/utils/validation-schemas.ts +93 -0
- package/src/views/masterpass-rest-option.tsx +756 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { store } from 'redux/store';
|
|
2
|
+
import {
|
|
3
|
+
DirectPaymentRequest,
|
|
4
|
+
DirectPaymentResponse,
|
|
5
|
+
MPResponse,
|
|
6
|
+
type PaymentProcessRequest
|
|
7
|
+
} from '../types/payment.types';
|
|
8
|
+
|
|
9
|
+
export interface PaymentResponse {
|
|
10
|
+
success: boolean;
|
|
11
|
+
data?: any;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class PaymentService {
|
|
16
|
+
private get token(): string {
|
|
17
|
+
return store.getState().masterpassRest.token || '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private get merchantId(): string {
|
|
21
|
+
return store.getState().masterpassRest.tokenData?.MerchantId || '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
this.initialize();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private initialize(): void {
|
|
29
|
+
window.Masterpass.setToken(this.token);
|
|
30
|
+
window.Masterpass.setMerchantId(this.merchantId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async processPayment(
|
|
34
|
+
paymentData: PaymentProcessRequest
|
|
35
|
+
): Promise<PaymentResponse> {
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
try {
|
|
38
|
+
this.initialize();
|
|
39
|
+
|
|
40
|
+
window.Masterpass.paymentService.payment(
|
|
41
|
+
{
|
|
42
|
+
requestReferenceNo: paymentData.requestReferenceNo,
|
|
43
|
+
cvc: paymentData.cvc,
|
|
44
|
+
cardAlias: paymentData.cardAlias,
|
|
45
|
+
accountKey: paymentData.accountKey,
|
|
46
|
+
amount: paymentData.amount,
|
|
47
|
+
orderNo: paymentData.orderNo,
|
|
48
|
+
currencyCode: paymentData.currencyCode,
|
|
49
|
+
paymentType: paymentData.paymentType,
|
|
50
|
+
acquirerIcaNumber: paymentData.acquirerIcaNumber,
|
|
51
|
+
installmentCount: paymentData.installmentCount,
|
|
52
|
+
authenticationMethod: paymentData.authenticationMethod,
|
|
53
|
+
secure3DModel: paymentData.secure3DModel,
|
|
54
|
+
terminalGroupId: paymentData.terminalGroupId
|
|
55
|
+
},
|
|
56
|
+
(statusCode, response) => {
|
|
57
|
+
if (response && response.statusCode === 200) {
|
|
58
|
+
resolve({
|
|
59
|
+
success: true,
|
|
60
|
+
data: response
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
resolve({
|
|
64
|
+
success: false,
|
|
65
|
+
error: response?.description || 'Payment failed',
|
|
66
|
+
data: response
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
resolve({
|
|
73
|
+
success: false,
|
|
74
|
+
error: 'Payment service initialization failed'
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async directPayment(
|
|
81
|
+
paymentData: DirectPaymentRequest
|
|
82
|
+
): Promise<PaymentResponse> {
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
try {
|
|
85
|
+
this.initialize();
|
|
86
|
+
|
|
87
|
+
window.Masterpass.paymentService.directPayment(
|
|
88
|
+
{
|
|
89
|
+
requestReferenceNo: paymentData.requestReferenceNo,
|
|
90
|
+
cvc: paymentData.cvc,
|
|
91
|
+
cardNumber: paymentData.cardNumber,
|
|
92
|
+
cardHolderName: paymentData.cardHolderName,
|
|
93
|
+
expiryDate: paymentData.expiryDate,
|
|
94
|
+
accountKey: paymentData.accountKey,
|
|
95
|
+
amount: paymentData.amount,
|
|
96
|
+
orderNo: paymentData.orderNo,
|
|
97
|
+
currencyCode: paymentData.currencyCode,
|
|
98
|
+
paymentType: paymentData.paymentType,
|
|
99
|
+
acquirerIcaNumber: paymentData.acquirerIcaNumber,
|
|
100
|
+
installmentCount: paymentData.installmentCount,
|
|
101
|
+
authenticationMethod: paymentData.authenticationMethod,
|
|
102
|
+
secure3DModel: paymentData.secure3DModel,
|
|
103
|
+
terminalGroupId: paymentData.terminalGroupId
|
|
104
|
+
},
|
|
105
|
+
(statusCode: number, response: MPResponse<DirectPaymentResponse>) => {
|
|
106
|
+
if (response && response.statusCode === 200) {
|
|
107
|
+
resolve({
|
|
108
|
+
success: true,
|
|
109
|
+
data: response
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
resolve({
|
|
113
|
+
success: false,
|
|
114
|
+
error:
|
|
115
|
+
response?.result?.responseDescription ||
|
|
116
|
+
response?.exception?.message ||
|
|
117
|
+
'Direct payment failed',
|
|
118
|
+
data: response
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
resolve({
|
|
125
|
+
success: false,
|
|
126
|
+
error: 'Direct payment service initialization failed'
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MPResponse } from '../types/payment.types';
|
|
2
|
+
import { VerifyRequest, VerifyResponse } from '../types/verify.types';
|
|
3
|
+
import { store } from 'redux/store';
|
|
4
|
+
|
|
5
|
+
export class VerifyService {
|
|
6
|
+
private get token(): string {
|
|
7
|
+
return store.getState().masterpassRest.token || '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
private get merchantId(): string {
|
|
11
|
+
return store.getState().masterpassRest.tokenData?.MerchantId || '';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.initialize();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private initialize(): void {
|
|
19
|
+
window.Masterpass.setToken(this.token);
|
|
20
|
+
window.Masterpass.setMerchantId(this.merchantId);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
verifyOtp(request: VerifyRequest): Promise<MPResponse<VerifyResponse>> {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
try {
|
|
26
|
+
this.initialize();
|
|
27
|
+
|
|
28
|
+
window.Masterpass.verifyService.verifyOtp(
|
|
29
|
+
request,
|
|
30
|
+
(statusCode, response) => {
|
|
31
|
+
resolve(response);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
reject(error);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
export type AccountKeyType = 'Msisdn' | 'Email' | 'CardNumber';
|
|
2
|
+
|
|
3
|
+
export interface AccountAccessRequest {
|
|
4
|
+
accountKey: string;
|
|
5
|
+
accountKeyType: AccountKeyType;
|
|
6
|
+
userId: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ValidationError {
|
|
10
|
+
field: string;
|
|
11
|
+
message: string;
|
|
12
|
+
code: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ExceptionResponse {
|
|
16
|
+
level: string;
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
validationErrors: ValidationError[] | null;
|
|
20
|
+
details: any[] | null;
|
|
21
|
+
vposErrorCode: string | null;
|
|
22
|
+
vposErrorMessage: string | null;
|
|
23
|
+
retrievalReferenceNumber: string | null;
|
|
24
|
+
thirdPartyApiResponse: any | null;
|
|
25
|
+
acquirerIcaNumber: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CardModel {
|
|
29
|
+
cardAlias: string;
|
|
30
|
+
cardState: 'Draft' | 'Activated' | 'Blocked' | 'Removed' | '';
|
|
31
|
+
maskedCardNumber: string;
|
|
32
|
+
uniqueCardNumber: string;
|
|
33
|
+
cardType: 'Credit' | 'Debit' | 'Unknown' | '';
|
|
34
|
+
productName: string;
|
|
35
|
+
cardBin: string;
|
|
36
|
+
cardIssuerIcaNumber: string;
|
|
37
|
+
cardValidationType: 'OTP' | 'RTA' | '_3D' | 'Unknown' | '';
|
|
38
|
+
isDefaultCard: boolean;
|
|
39
|
+
expireSoon: boolean;
|
|
40
|
+
isExpired: boolean;
|
|
41
|
+
isMasterpassMember: boolean;
|
|
42
|
+
isCardCreditOrSupportedDebit?: boolean;
|
|
43
|
+
isIssuerOtpSupported?: boolean;
|
|
44
|
+
eftCode?: string | null;
|
|
45
|
+
sourceMerchantId?: number;
|
|
46
|
+
sourceMerchantName?: string | null;
|
|
47
|
+
expireDate?: string | null;
|
|
48
|
+
systemEntryDatetime?: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CardResponse {
|
|
52
|
+
accountKey: string;
|
|
53
|
+
accountState: string;
|
|
54
|
+
cards: CardModel[];
|
|
55
|
+
recipientCards?: any[] | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface LinkToMerchantResponse {
|
|
59
|
+
retrievalReferenceNumber: string;
|
|
60
|
+
responseCode: string;
|
|
61
|
+
description: string;
|
|
62
|
+
token: string;
|
|
63
|
+
cardIssuerName: string;
|
|
64
|
+
maskedPan: string;
|
|
65
|
+
url3D?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface AccountAccessErrorResponse {
|
|
69
|
+
version: string | null;
|
|
70
|
+
buildId: string;
|
|
71
|
+
statusCode: number;
|
|
72
|
+
message: string;
|
|
73
|
+
correlationId: string | null;
|
|
74
|
+
requestId: string | null;
|
|
75
|
+
result: null;
|
|
76
|
+
exception: ExceptionResponse;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface AccountAccessSuccessResponse {
|
|
80
|
+
version: string | null;
|
|
81
|
+
buildId: string;
|
|
82
|
+
statusCode: number;
|
|
83
|
+
message: string;
|
|
84
|
+
correlationId: string | null;
|
|
85
|
+
requestId: string | null;
|
|
86
|
+
result: CardResponse;
|
|
87
|
+
exception: null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface LinkToMerchantSuccessResponse {
|
|
91
|
+
version: string | null;
|
|
92
|
+
buildId: string;
|
|
93
|
+
statusCode: number;
|
|
94
|
+
message: string;
|
|
95
|
+
correlationId: string | null;
|
|
96
|
+
requestId: string | null;
|
|
97
|
+
result: LinkToMerchantResponse;
|
|
98
|
+
exception: null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type AccountAccessResponse =
|
|
102
|
+
| AccountAccessErrorResponse
|
|
103
|
+
| AccountAccessSuccessResponse;
|
|
104
|
+
|
|
105
|
+
export type LinkToMerchantResponseType =
|
|
106
|
+
| AccountAccessErrorResponse
|
|
107
|
+
| LinkToMerchantSuccessResponse;
|
|
108
|
+
|
|
109
|
+
export interface RemoveCardRequest {
|
|
110
|
+
accountKey: string;
|
|
111
|
+
cardAlias: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface RemoveCardResponse {
|
|
115
|
+
clientId: number;
|
|
116
|
+
refNo: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface RemoveCardServiceResponse {
|
|
120
|
+
version: string;
|
|
121
|
+
buildId: string;
|
|
122
|
+
statusCode: number;
|
|
123
|
+
message: string;
|
|
124
|
+
correlationId: string;
|
|
125
|
+
requestId: string;
|
|
126
|
+
result: RemoveCardResponse | null;
|
|
127
|
+
exception: ExceptionResponse | null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface AddCardRequest {
|
|
131
|
+
requestReferenceNumber: string;
|
|
132
|
+
accountKey: string;
|
|
133
|
+
accountKeyType: AccountKeyType;
|
|
134
|
+
cardNumber: string;
|
|
135
|
+
cardHolderName: string;
|
|
136
|
+
expiryDate: string;
|
|
137
|
+
cvv: string;
|
|
138
|
+
accountAliasName: string;
|
|
139
|
+
userId: string;
|
|
140
|
+
isMsisdnValidatedByMerchant: boolean;
|
|
141
|
+
authenticationMethod: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface AddCard3DSecureResult {
|
|
145
|
+
retrievalReferenceNumber: string;
|
|
146
|
+
responseCode: string;
|
|
147
|
+
description: string;
|
|
148
|
+
token: string;
|
|
149
|
+
url3d: string;
|
|
150
|
+
url3dSuccess: string;
|
|
151
|
+
url3dFail: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface AddCardSuccessResponse {
|
|
155
|
+
version: string | null;
|
|
156
|
+
buildId: string;
|
|
157
|
+
statusCode: number;
|
|
158
|
+
message: string;
|
|
159
|
+
correlationId: string | null;
|
|
160
|
+
requestId: string | null;
|
|
161
|
+
result: CardResponse;
|
|
162
|
+
exception: null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface AddCard3DSecureResponse {
|
|
166
|
+
version: string | null;
|
|
167
|
+
buildId: string;
|
|
168
|
+
statusCode: number;
|
|
169
|
+
message: string;
|
|
170
|
+
correlationId: string | null;
|
|
171
|
+
requestId: string | null;
|
|
172
|
+
result: AddCard3DSecureResult;
|
|
173
|
+
exception: null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type AddCardResponse =
|
|
177
|
+
| AccountAccessErrorResponse
|
|
178
|
+
| AddCardSuccessResponse
|
|
179
|
+
| AddCard3DSecureResponse;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import type { CreditCardFormData } from '../utils/validation-schemas';
|
|
3
|
+
|
|
4
|
+
export type PaymentMethodSelectorProps = {
|
|
5
|
+
cards: any[];
|
|
6
|
+
selectedMethod: 'stored_card' | 'new_card';
|
|
7
|
+
onMethodChange: (method: 'stored_card' | 'new_card') => void;
|
|
8
|
+
texts: MasterpassRestOptionTexts;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type CardListProps = {
|
|
12
|
+
cards: any[];
|
|
13
|
+
onCardSelect: (card: any) => Promise<void>;
|
|
14
|
+
selectedCard: any;
|
|
15
|
+
onRemove: (card: any) => void;
|
|
16
|
+
removingCardId: string | null;
|
|
17
|
+
cvc: string;
|
|
18
|
+
onCvcChange: (cvc: string) => void;
|
|
19
|
+
texts: MasterpassRestOptionTexts;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type CreditCardFormProps = {
|
|
23
|
+
onSaveCard: (cardData: CreditCardFormData) => Promise<void>;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
showSaveOption: boolean;
|
|
26
|
+
onBinChange: (bin: string) => Promise<void>;
|
|
27
|
+
texts: MasterpassRestOptionTexts;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type InstallmentListProps = {
|
|
31
|
+
installments: any[];
|
|
32
|
+
cardType: string | null;
|
|
33
|
+
onInstallmentSelect: (installment: any) => Promise<void>;
|
|
34
|
+
selectedInstallment: any;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
onProceedToPayment: () => Promise<void>;
|
|
37
|
+
paymentLoading: boolean;
|
|
38
|
+
requiresCvc: boolean;
|
|
39
|
+
cvc: string;
|
|
40
|
+
texts: MasterpassRestOptionTexts;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type LinkModalProps = {
|
|
44
|
+
open: boolean;
|
|
45
|
+
onClose: () => void;
|
|
46
|
+
onConfirm: () => void;
|
|
47
|
+
texts: MasterpassRestOptionTexts;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type OTPModalProps = {
|
|
51
|
+
open: boolean;
|
|
52
|
+
onClose: () => void;
|
|
53
|
+
onSubmit: (otp: string) => Promise<{ success: boolean; message?: string }>;
|
|
54
|
+
type: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
texts: MasterpassRestOptionTexts;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type ConfirmationModalProps = {
|
|
60
|
+
open: boolean;
|
|
61
|
+
onClose: () => void;
|
|
62
|
+
onConfirm: () => void;
|
|
63
|
+
title: string;
|
|
64
|
+
message: string;
|
|
65
|
+
confirmText: string;
|
|
66
|
+
cancelText: string;
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
loadingText: string;
|
|
69
|
+
texts: MasterpassRestOptionTexts;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type ErrorDisplayProps = {
|
|
73
|
+
error: any;
|
|
74
|
+
onDismiss: () => void;
|
|
75
|
+
getErrorInfo: (error: any) => { message: string; type: string } | null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type LoadingStateProps = {
|
|
79
|
+
message: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type EmptyStateProps = {
|
|
83
|
+
paymentMethod: 'stored_card' | 'new_card';
|
|
84
|
+
cardNumberLength: number;
|
|
85
|
+
isCheckoutLoading: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type MasterpassRestOptionCustomRender = {
|
|
89
|
+
paymentMethodSelector?: (props: PaymentMethodSelectorProps) => ReactElement;
|
|
90
|
+
cardList?: (props: CardListProps) => ReactElement;
|
|
91
|
+
creditCardForm?: (props: CreditCardFormProps) => ReactElement;
|
|
92
|
+
installmentList?: (props: InstallmentListProps) => ReactElement;
|
|
93
|
+
linkModal?: (props: LinkModalProps) => ReactElement;
|
|
94
|
+
otpModal?: (props: OTPModalProps) => ReactElement;
|
|
95
|
+
confirmationModal?: (props: ConfirmationModalProps) => ReactElement;
|
|
96
|
+
errorDisplay?: (props: ErrorDisplayProps) => ReactElement;
|
|
97
|
+
loadingState?: (props: LoadingStateProps) => ReactElement;
|
|
98
|
+
emptyState?: (props: EmptyStateProps) => ReactElement;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type MasterpassRestOptionTexts = {
|
|
102
|
+
title?: string;
|
|
103
|
+
newCardTitle?: string;
|
|
104
|
+
selectCardTitle?: string;
|
|
105
|
+
installmentOptionsTitle?: string;
|
|
106
|
+
enterCardDetailsTitle?: string;
|
|
107
|
+
loadingMessage?: string;
|
|
108
|
+
scriptLoadingMessage?: string;
|
|
109
|
+
selectCardMessage?: string;
|
|
110
|
+
enterCardMessage?: string;
|
|
111
|
+
enterCardSubMessage?: string;
|
|
112
|
+
enterDigitsMessage?: string;
|
|
113
|
+
noInstallmentMessage?: string;
|
|
114
|
+
loadingInstallmentMessage?: string;
|
|
115
|
+
removeCardTitle?: string;
|
|
116
|
+
removeCardMessage?: string;
|
|
117
|
+
removeCardConfirmText?: string;
|
|
118
|
+
removeCardCancelText?: string;
|
|
119
|
+
removeCardLoadingText?: string;
|
|
120
|
+
dismissButtonText?: string;
|
|
121
|
+
paymentErrorTitle?: string;
|
|
122
|
+
paymentErrorDefaultMessage?: string;
|
|
123
|
+
|
|
124
|
+
// Payment Method Selector
|
|
125
|
+
paymentMethodTitle?: string;
|
|
126
|
+
paymentMethodDescription?: string;
|
|
127
|
+
savedCardsText?: string;
|
|
128
|
+
savedCardsDescription?: string;
|
|
129
|
+
newCardText?: string;
|
|
130
|
+
newCardDescription?: string;
|
|
131
|
+
noPaymentMethodsText?: string;
|
|
132
|
+
|
|
133
|
+
// Error Messages
|
|
134
|
+
failedToSaveCardText?: string;
|
|
135
|
+
paymentFailedText?: string;
|
|
136
|
+
otpHandlerNotAvailableText?: string;
|
|
137
|
+
failedToSelectCardText?: string;
|
|
138
|
+
failedToSelectInstallmentText?: string;
|
|
139
|
+
|
|
140
|
+
// Validation Error Messages
|
|
141
|
+
cardNumberRequiredText?: string;
|
|
142
|
+
cardNumberInvalidText?: string;
|
|
143
|
+
expiryDateRequiredText?: string;
|
|
144
|
+
expiryDateInvalidText?: string;
|
|
145
|
+
expiryDateExpiredText?: string;
|
|
146
|
+
cvvRequiredText?: string;
|
|
147
|
+
cvvInvalidText?: string;
|
|
148
|
+
cardholderNameRequiredText?: string;
|
|
149
|
+
cardholderNameTooShortText?: string;
|
|
150
|
+
cardholderNameTooLongText?: string;
|
|
151
|
+
cardholderNameInvalidText?: string;
|
|
152
|
+
cardAliasRequiredText?: string;
|
|
153
|
+
cardAliasTooShortText?: string;
|
|
154
|
+
cardAliasTooLongText?: string;
|
|
155
|
+
|
|
156
|
+
creditCardInfoTitle?: string;
|
|
157
|
+
checkingCardText?: string;
|
|
158
|
+
cardNumberLabel?: string;
|
|
159
|
+
cardNumberPlaceholder?: string;
|
|
160
|
+
cardholderNameLabel?: string;
|
|
161
|
+
cardholderNamePlaceholder?: string;
|
|
162
|
+
expiryDateLabel?: string;
|
|
163
|
+
expiryDatePlaceholder?: string;
|
|
164
|
+
cvcLabel?: string;
|
|
165
|
+
cvcPlaceholder3?: string;
|
|
166
|
+
cvcPlaceholder4?: string;
|
|
167
|
+
saveCardLabel?: string;
|
|
168
|
+
cardAliasLabel?: string;
|
|
169
|
+
cardAliasPlaceholder?: string;
|
|
170
|
+
addCardButton?: string;
|
|
171
|
+
cancelButton?: string;
|
|
172
|
+
secureText?: string;
|
|
173
|
+
cvcHelpText?: string;
|
|
174
|
+
cvcFrontText?: string;
|
|
175
|
+
cvcBackText?: string;
|
|
176
|
+
|
|
177
|
+
defaultCardText?: string;
|
|
178
|
+
expiresSoonText?: string;
|
|
179
|
+
removeCardTitleText?: string;
|
|
180
|
+
cvcCardLabel?: string;
|
|
181
|
+
secureCardText?: string;
|
|
182
|
+
cvcCardHelpText?: string;
|
|
183
|
+
|
|
184
|
+
confirmText?: string;
|
|
185
|
+
cancelText?: string;
|
|
186
|
+
loadingText?: string;
|
|
187
|
+
|
|
188
|
+
installmentOptionsText?: string;
|
|
189
|
+
cardTypeLabel?: string;
|
|
190
|
+
singlePaymentText?: string;
|
|
191
|
+
installmentsText?: string;
|
|
192
|
+
noInterestText?: string;
|
|
193
|
+
perMonthText?: string;
|
|
194
|
+
proceedToPaymentText?: string;
|
|
195
|
+
processingPaymentText?: string;
|
|
196
|
+
cvcRequiredText?: string;
|
|
197
|
+
|
|
198
|
+
linkModalTitle?: string;
|
|
199
|
+
linkModalDescription?: string;
|
|
200
|
+
linkAccountButton?: string;
|
|
201
|
+
linkModalCancelButton?: string;
|
|
202
|
+
|
|
203
|
+
rtaVerificationTitle?: string;
|
|
204
|
+
cvvVerificationTitle?: string;
|
|
205
|
+
otpVerificationTitle?: string;
|
|
206
|
+
rtaVerificationDescription?: string;
|
|
207
|
+
cvvVerificationDescription?: string;
|
|
208
|
+
otpVerificationDescription?: string;
|
|
209
|
+
verifyButton?: string;
|
|
210
|
+
otpModalCancelButton?: string;
|
|
211
|
+
otpModalErrorText?: string;
|
|
212
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ValidationError } from './account.types';
|
|
2
|
+
|
|
3
|
+
export interface Installment {
|
|
4
|
+
pk: number;
|
|
5
|
+
installment_count: number;
|
|
6
|
+
label: string;
|
|
7
|
+
price_with_accrued_interest: string;
|
|
8
|
+
monthly_price_with_accrued_interest: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CardType {
|
|
12
|
+
name: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
logo: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PaymentProcessRequest {
|
|
18
|
+
requestReferenceNo: string;
|
|
19
|
+
cvc: string;
|
|
20
|
+
cardAlias: string;
|
|
21
|
+
accountKey: string;
|
|
22
|
+
amount: string;
|
|
23
|
+
orderNo: string;
|
|
24
|
+
currencyCode: string;
|
|
25
|
+
paymentType: string;
|
|
26
|
+
acquirerIcaNumber: string;
|
|
27
|
+
installmentCount: number;
|
|
28
|
+
authenticationMethod: string;
|
|
29
|
+
secure3DModel: string;
|
|
30
|
+
terminalGroupId: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface OrderData {
|
|
34
|
+
pre_order?: {
|
|
35
|
+
total_amount: string;
|
|
36
|
+
currency_type_label: string;
|
|
37
|
+
redirect_to_three_d?: boolean;
|
|
38
|
+
installment?: {
|
|
39
|
+
installment_count: number;
|
|
40
|
+
monthly_price_with_accrued_interest: string;
|
|
41
|
+
};
|
|
42
|
+
payment_option?: {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
application_date?: string;
|
|
46
|
+
};
|
|
47
|
+
context_list?: Array<{
|
|
48
|
+
page_context?: {
|
|
49
|
+
order_no: string;
|
|
50
|
+
installments?: Installment[];
|
|
51
|
+
msisdn?: string;
|
|
52
|
+
three_d?: boolean;
|
|
53
|
+
extras?: {
|
|
54
|
+
user_id: string;
|
|
55
|
+
bank_ica: string | null;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
page_name?: string;
|
|
59
|
+
page_slug?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type OTPType = 'RTA' | 'OTP' | 'CVV';
|
|
64
|
+
|
|
65
|
+
export type TransactionType =
|
|
66
|
+
| 'PURCHASE'
|
|
67
|
+
| 'PURCHASE_3D'
|
|
68
|
+
| 'DIRECT_PURCHASE'
|
|
69
|
+
| 'DIRECT_PURCHASE_3D';
|
|
70
|
+
|
|
71
|
+
export interface PaymentState {
|
|
72
|
+
selectedCard: any | null;
|
|
73
|
+
selectedInstallment: Installment | null;
|
|
74
|
+
installments: Installment[];
|
|
75
|
+
cardType: CardType | null;
|
|
76
|
+
orderData: OrderData | null;
|
|
77
|
+
orderCompleted: boolean;
|
|
78
|
+
cvc: string;
|
|
79
|
+
useThreeD: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ModalState {
|
|
83
|
+
showLinkModal: boolean;
|
|
84
|
+
showOTPModal: boolean;
|
|
85
|
+
show3DSecureModal: boolean;
|
|
86
|
+
otpType: OTPType;
|
|
87
|
+
verificationData: any | null;
|
|
88
|
+
cardToDelete: any | null;
|
|
89
|
+
removingCardId: string | null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface DirectPaymentRequest {
|
|
93
|
+
requestReferenceNo: string;
|
|
94
|
+
cvc: string;
|
|
95
|
+
cardNumber: string;
|
|
96
|
+
cardHolderName: string;
|
|
97
|
+
expiryDate: string;
|
|
98
|
+
accountKey: string;
|
|
99
|
+
amount: string;
|
|
100
|
+
orderNo: string;
|
|
101
|
+
currencyCode: string;
|
|
102
|
+
paymentType: string;
|
|
103
|
+
acquirerIcaNumber: string;
|
|
104
|
+
installmentCount: number;
|
|
105
|
+
authenticationMethod: string;
|
|
106
|
+
secure3DModel: string;
|
|
107
|
+
terminalGroupId: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface DirectPaymentResponse {
|
|
111
|
+
responseCode: string;
|
|
112
|
+
responseDescription: string;
|
|
113
|
+
token?: string;
|
|
114
|
+
retrievalReferenceNumber?: string;
|
|
115
|
+
maskedNumber?: string;
|
|
116
|
+
terminalGroupId?: string;
|
|
117
|
+
url3d?: string;
|
|
118
|
+
url3dSuccess?: string;
|
|
119
|
+
url3dFail?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface MPResponse<T = any> {
|
|
123
|
+
version: string;
|
|
124
|
+
buildId: string;
|
|
125
|
+
statusCode: number;
|
|
126
|
+
message: string;
|
|
127
|
+
correlationId: string;
|
|
128
|
+
requestId: string;
|
|
129
|
+
result: T;
|
|
130
|
+
exception?: ExceptionResponse;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ExceptionResponse {
|
|
134
|
+
level: string;
|
|
135
|
+
code: string;
|
|
136
|
+
message: string;
|
|
137
|
+
validationErrors: ValidationError[];
|
|
138
|
+
details: string[];
|
|
139
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface VerifyResponse {
|
|
2
|
+
retrievalReferenceNumber: string;
|
|
3
|
+
isVerified: boolean;
|
|
4
|
+
cardUniqueNumber: string;
|
|
5
|
+
token: string | null;
|
|
6
|
+
responseCode: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
url3d?: string;
|
|
9
|
+
url3D?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface VerifyRequest {
|
|
13
|
+
otpCode: string;
|
|
14
|
+
}
|