@traxionpay/cbsmiddleware 0.0.2 → 0.0.4
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/dist/banking/dto/account-transfer.dto.d.ts +1 -1
- package/dist/banking/dto/account-transfer.dto.js +2 -2
- package/dist/banking/dto/account.dto.d.ts +1 -1
- package/dist/banking/dto/account.dto.js +2 -2
- package/dist/banking/dto/fetch-bank-balance.dto.d.ts +1 -1
- package/dist/banking/dto/fetch-bank-balance.dto.d.ts.map +1 -1
- package/dist/banking/dto/fetch-bank-balance.dto.js +2 -2
- package/dist/banking/dto/fetch-bank-balance.dto.js.map +1 -1
- package/dist/banking/dto/transaction-history.dto.d.ts +1 -1
- package/dist/banking/dto/transaction-history.dto.js +2 -2
- package/dist/banking/services/ASPAC.service.d.ts +8 -1
- package/dist/banking/services/ASPAC.service.d.ts.map +1 -1
- package/dist/banking/services/ASPAC.service.js +208 -76
- package/dist/banking/services/ASPAC.service.js.map +1 -1
- package/dist/banking/services/WelcomeBank.service.d.ts +6 -1
- package/dist/banking/services/WelcomeBank.service.d.ts.map +1 -1
- package/dist/banking/services/WelcomeBank.service.js +317 -127
- package/dist/banking/services/WelcomeBank.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/banking/dto/account-transfer.dto.ts +2 -2
- package/src/banking/dto/account.dto.ts +2 -2
- package/src/banking/dto/fetch-bank-balance.dto.ts +4 -3
- package/src/banking/dto/transaction-history.dto.ts +2 -2
- package/src/banking/services/ASPAC.service.ts +256 -79
- package/src/banking/services/WelcomeBank.service.ts +399 -158
|
@@ -85,8 +85,8 @@ __decorate([
|
|
|
85
85
|
], AccountTransferDto.prototype, "particulars", void 0);
|
|
86
86
|
__decorate([
|
|
87
87
|
(0, class_validator_1.IsOptional)(),
|
|
88
|
-
(0, class_validator_1.
|
|
89
|
-
__metadata("design:type",
|
|
88
|
+
(0, class_validator_1.IsString)(),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
90
|
], AccountTransferDto.prototype, "mobile", void 0);
|
|
91
91
|
__decorate([
|
|
92
92
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -49,8 +49,8 @@ __decorate([
|
|
|
49
49
|
], AccountDto.prototype, "accountType", void 0);
|
|
50
50
|
__decorate([
|
|
51
51
|
(0, class_validator_1.IsOptional)(),
|
|
52
|
-
(0, class_validator_1.
|
|
53
|
-
__metadata("design:type",
|
|
52
|
+
(0, class_validator_1.IsString)(),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
54
|
], AccountDto.prototype, "mobile", void 0);
|
|
55
55
|
__decorate([
|
|
56
56
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-bank-balance.dto.d.ts","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-bank-balance.dto.d.ts","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":"AAQA,qBAAa,mBAAmB;IAI5B,MAAM,EAAE,MAAM,CAAA;IAId,KAAK,CAAC,EAAE,MAAM,CAAA;IAId,aAAa,CAAC,EAAE,MAAM,CAAA;IAItB,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,MAAM,CAAC,EAAE,MAAM,CAAA;IAIf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,SAAS,CAAC,EAAE,MAAM,CAAC;CAEtB"}
|
|
@@ -55,8 +55,8 @@ __decorate([
|
|
|
55
55
|
], FetchBankBalanceDto.prototype, "accountType", void 0);
|
|
56
56
|
__decorate([
|
|
57
57
|
(0, class_validator_1.IsOptional)(),
|
|
58
|
-
(0, class_validator_1.
|
|
59
|
-
__metadata("design:type",
|
|
58
|
+
(0, class_validator_1.IsString)(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
60
|
], FetchBankBalanceDto.prototype, "mobile", void 0);
|
|
61
61
|
__decorate([
|
|
62
62
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-bank-balance.dto.js","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"fetch-bank-balance.dto.js","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAMyB;AAEzB,MAAa,mBAAmB;IAI5B,MAAM,CAAQ;IAId,KAAK,CAAS;IAId,aAAa,CAAS;IAItB,OAAO,CAAU;IAIjB,MAAM,CAAU;IAIhB,WAAW,CAAU;IAIrB,MAAM,CAAS;IAIf,QAAQ,CAAU;IAIlB,SAAS,CAAU;CAEtB;AAtCD,kDAsCC;AAlCG;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,0BAAQ,GAAE;;mDACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;0DACW;AAItB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACM;AAIjB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACK;AAIhB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;wDACU;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACO;AAIlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sDACQ"}
|
|
@@ -73,8 +73,8 @@ __decorate([
|
|
|
73
73
|
], TransactionHistoryDto.prototype, "page", void 0);
|
|
74
74
|
__decorate([
|
|
75
75
|
(0, class_validator_1.IsOptional)(),
|
|
76
|
-
(0, class_validator_1.
|
|
77
|
-
__metadata("design:type",
|
|
76
|
+
(0, class_validator_1.IsString)(),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
78
|
], TransactionHistoryDto.prototype, "mobile", void 0);
|
|
79
79
|
__decorate([
|
|
80
80
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -9,6 +9,7 @@ export declare class ASPACService implements BankService {
|
|
|
9
9
|
private readonly config;
|
|
10
10
|
private readonly logger;
|
|
11
11
|
constructor(config: BankingConfig, logger: Logger);
|
|
12
|
+
combineDateTime(date: string, time: string): string;
|
|
12
13
|
generateToken(): Promise<any>;
|
|
13
14
|
refreshToken(refreshToken: string): Promise<any>;
|
|
14
15
|
linkAccount(accountDto: AccountDto): Promise<any>;
|
|
@@ -16,7 +17,13 @@ export declare class ASPACService implements BankService {
|
|
|
16
17
|
processBalanceTransaction(fetchBalanceDto: FetchBankBalanceDto): Promise<any>;
|
|
17
18
|
accountCashIn(accountTransferDto: AccountTransferDto): Promise<any>;
|
|
18
19
|
accountDeposit(accountTransferDto: AccountTransferDto): Promise<any>;
|
|
19
|
-
getTransactionHistory(transactionHistoryDto: TransactionHistoryDto): Promise<
|
|
20
|
+
getTransactionHistory(transactionHistoryDto: TransactionHistoryDto): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
message: any;
|
|
23
|
+
correlationId: any;
|
|
24
|
+
timestamp: any;
|
|
25
|
+
transactions: any;
|
|
26
|
+
}>;
|
|
20
27
|
findAccountDetailsRaw(token: string, userid: number): Promise<string>;
|
|
21
28
|
accountTransfer(token: string, useridFrom: string, useridTo: string, amount: number): Promise<string>;
|
|
22
29
|
generateOtp(mobile: string, acc: string, bankid: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ASPAC.service.d.ts","sourceRoot":"","sources":["../../../src/banking/services/ASPAC.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAGpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,qBACa,YAAa,YAAW,WAAW;IAI5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"ASPAC.service.d.ts","sourceRoot":"","sources":["../../../src/banking/services/ASPAC.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAGpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,qBACa,YAAa,YAAW,WAAW;IAI5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM;IAIjC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAS7C,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;IAkC7B,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAyDhD,WAAW,CAAC,UAAU,EAAE,UAAU;IAoGlC,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAiFnD,yBAAyB,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAuE7E,aAAa,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAoGnE,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAmGpE,qBAAqB,CAAC,qBAAqB,EAAE,qBAAqB,GACtE,OAAO,CAAC;QACN,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,GAAG,CAAC;QACb,aAAa,EAAE,GAAG,CAAC;QACnB,SAAS,EAAE,GAAG,CAAC;QACf,YAAY,EAAE,GAAG,CAAC;KACnB,CAAC;IAmJE,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAInD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAIzF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAIhE,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAG1C"}
|
|
@@ -62,6 +62,12 @@ let ASPACService = class ASPACService {
|
|
|
62
62
|
this.config = config;
|
|
63
63
|
this.logger = logger;
|
|
64
64
|
}
|
|
65
|
+
combineDateTime(date, time) {
|
|
66
|
+
const isoString = `${date}T${time.padEnd(8, '0')}.000Z`;
|
|
67
|
+
const d = new Date(isoString);
|
|
68
|
+
const isoWithOffset = d.toISOString().replace('Z', '+00:00');
|
|
69
|
+
return isoWithOffset;
|
|
70
|
+
}
|
|
65
71
|
async generateToken() {
|
|
66
72
|
this.logger.log("Generating WelcomeBank Token");
|
|
67
73
|
try {
|
|
@@ -90,8 +96,8 @@ let ASPACService = class ASPACService {
|
|
|
90
96
|
if (!refreshToken) {
|
|
91
97
|
throw new common_1.HttpException({
|
|
92
98
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
93
|
-
code:
|
|
94
|
-
message: '
|
|
99
|
+
code: 400010205,
|
|
100
|
+
message: 'Refresh token is required.',
|
|
95
101
|
data: { refreshToken }
|
|
96
102
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
97
103
|
}
|
|
@@ -118,47 +124,46 @@ let ASPACService = class ASPACService {
|
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
126
|
catch (error) {
|
|
127
|
+
if (error.response.data.message === "Invalid refresh token") {
|
|
128
|
+
throw new common_1.HttpException({
|
|
129
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
130
|
+
code: 400010206,
|
|
131
|
+
message: 'Invalid refresh token.',
|
|
132
|
+
data: { refreshToken }
|
|
133
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
134
|
+
}
|
|
121
135
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
122
136
|
}
|
|
123
137
|
}
|
|
124
138
|
async linkAccount(accountDto) {
|
|
125
|
-
const {
|
|
126
|
-
if (!token) {
|
|
127
|
-
throw new common_1.HttpException({
|
|
128
|
-
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
129
|
-
code: 4000,
|
|
130
|
-
message: 'Bank token should not be empty.',
|
|
131
|
-
data: { accountDto }
|
|
132
|
-
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
133
|
-
}
|
|
139
|
+
const { account, accountType, mobile } = accountDto;
|
|
134
140
|
if (!account) {
|
|
135
141
|
throw new common_1.HttpException({
|
|
136
142
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
137
|
-
code:
|
|
138
|
-
message: '
|
|
139
|
-
data: { accountDto }
|
|
143
|
+
code: 400010306,
|
|
144
|
+
message: 'Account number is required.',
|
|
145
|
+
data: { ...accountDto }
|
|
140
146
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
141
147
|
}
|
|
142
148
|
if (!accountType) {
|
|
143
149
|
throw new common_1.HttpException({
|
|
144
150
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
145
|
-
code:
|
|
146
|
-
message: '
|
|
147
|
-
data: { accountDto }
|
|
151
|
+
code: 400010308,
|
|
152
|
+
message: 'Account type is required.',
|
|
153
|
+
data: { ...accountDto }
|
|
148
154
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
149
155
|
}
|
|
150
156
|
if (!mobile) {
|
|
151
157
|
throw new common_1.HttpException({
|
|
152
158
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
153
|
-
code:
|
|
154
|
-
message: 'Mobile
|
|
155
|
-
data: { accountDto }
|
|
159
|
+
code: 4000103011,
|
|
160
|
+
message: 'Mobile number is required.',
|
|
161
|
+
data: { ...accountDto }
|
|
156
162
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
157
163
|
}
|
|
158
164
|
this.logger.log("Welcome Bank Link Account");
|
|
159
165
|
try {
|
|
160
166
|
const headers = {
|
|
161
|
-
'Authorization': `Bearer ${token}`,
|
|
162
167
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
163
168
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
164
169
|
};
|
|
@@ -176,39 +181,62 @@ let ASPACService = class ASPACService {
|
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
catch (error) {
|
|
184
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
185
|
+
throw new common_1.HttpException({
|
|
186
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
187
|
+
code: 400010305,
|
|
188
|
+
message: 'Account not found',
|
|
189
|
+
data: { ...accountDto }
|
|
190
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
191
|
+
}
|
|
192
|
+
if (error.response.data.message === "Invalid account type. Only deposit accounts (01) allowed") {
|
|
193
|
+
throw new common_1.HttpException({
|
|
194
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
195
|
+
code: 400010307,
|
|
196
|
+
message: 'Account type is not supported.',
|
|
197
|
+
data: { ...accountDto }
|
|
198
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
199
|
+
}
|
|
200
|
+
if (error.response.data.message === "Mobile number does not match registered mobile") {
|
|
201
|
+
throw new common_1.HttpException({
|
|
202
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
203
|
+
code: 400010309,
|
|
204
|
+
message: 'Mobile number is not registered in the account.',
|
|
205
|
+
data: { ...accountDto }
|
|
206
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
207
|
+
}
|
|
208
|
+
if (error.response.data.message === "Mobile number must be 12 digits (63XXXXXXXXXX)") {
|
|
209
|
+
throw new common_1.HttpException({
|
|
210
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
211
|
+
code: 4220103010,
|
|
212
|
+
message: 'Invalid mobile number format.',
|
|
213
|
+
data: { ...accountDto }
|
|
214
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
215
|
+
}
|
|
179
216
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
180
217
|
}
|
|
181
218
|
}
|
|
182
219
|
async validateOtp(validateOtp) {
|
|
183
|
-
const {
|
|
184
|
-
if (!token) {
|
|
185
|
-
throw new common_1.HttpException({
|
|
186
|
-
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
187
|
-
code: 4000,
|
|
188
|
-
message: 'Bank token should not be empty.',
|
|
189
|
-
data: { validateOtp }
|
|
190
|
-
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
191
|
-
}
|
|
220
|
+
const { account, otp } = validateOtp;
|
|
192
221
|
if (!account) {
|
|
193
222
|
throw new common_1.HttpException({
|
|
194
223
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
195
|
-
code:
|
|
196
|
-
message: '
|
|
197
|
-
data: { validateOtp }
|
|
224
|
+
code: 400010406,
|
|
225
|
+
message: 'Account number is required.',
|
|
226
|
+
data: { ...validateOtp }
|
|
198
227
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
199
228
|
}
|
|
200
229
|
if (!otp) {
|
|
201
230
|
throw new common_1.HttpException({
|
|
202
231
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
203
|
-
code:
|
|
204
|
-
message: '
|
|
205
|
-
data: { validateOtp }
|
|
232
|
+
code: 400010408,
|
|
233
|
+
message: 'OTP is required.',
|
|
234
|
+
data: { ...validateOtp }
|
|
206
235
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
207
236
|
}
|
|
208
237
|
this.logger.log("Welcome Bank Validate OTP");
|
|
209
238
|
try {
|
|
210
239
|
const headers = {
|
|
211
|
-
'Authorization': `Bearer ${token}`,
|
|
212
240
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
213
241
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
214
242
|
};
|
|
@@ -230,6 +258,22 @@ let ASPACService = class ASPACService {
|
|
|
230
258
|
};
|
|
231
259
|
}
|
|
232
260
|
catch (error) {
|
|
261
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
262
|
+
throw new common_1.HttpException({
|
|
263
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
264
|
+
code: 400010405,
|
|
265
|
+
message: 'Account not found.',
|
|
266
|
+
data: { ...validateOtp }
|
|
267
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
268
|
+
}
|
|
269
|
+
if (error.response.data.message === "Invalid OTP format. OTP must be exactly 6 digits" || error.response.data.message === "Invalid OTP code") {
|
|
270
|
+
throw new common_1.HttpException({
|
|
271
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
272
|
+
code: 400010407,
|
|
273
|
+
message: 'Invalid or expired OTP.',
|
|
274
|
+
data: { ...validateOtp }
|
|
275
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
276
|
+
}
|
|
233
277
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
234
278
|
}
|
|
235
279
|
}
|
|
@@ -238,17 +282,17 @@ let ASPACService = class ASPACService {
|
|
|
238
282
|
if (!token) {
|
|
239
283
|
throw new common_1.HttpException({
|
|
240
284
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
241
|
-
code:
|
|
285
|
+
code: 401010506,
|
|
242
286
|
message: 'Bank token should not be empty.',
|
|
243
|
-
data: { fetchBalanceDto }
|
|
287
|
+
data: { ...fetchBalanceDto }
|
|
244
288
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
245
289
|
}
|
|
246
290
|
if (!account) {
|
|
247
291
|
throw new common_1.HttpException({
|
|
248
292
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
249
|
-
code:
|
|
250
|
-
message: '
|
|
251
|
-
data: { fetchBalanceDto }
|
|
293
|
+
code: 400010508,
|
|
294
|
+
message: 'Account number is required.',
|
|
295
|
+
data: { ...fetchBalanceDto }
|
|
252
296
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
253
297
|
}
|
|
254
298
|
this.logger.log("Welcome Bank Balance Inquiry");
|
|
@@ -275,6 +319,14 @@ let ASPACService = class ASPACService {
|
|
|
275
319
|
};
|
|
276
320
|
}
|
|
277
321
|
catch (error) {
|
|
322
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
323
|
+
throw new common_1.HttpException({
|
|
324
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
325
|
+
code: 400010507,
|
|
326
|
+
message: 'Account not found.',
|
|
327
|
+
data: { fetchBalanceDto }
|
|
328
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
329
|
+
}
|
|
278
330
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
279
331
|
}
|
|
280
332
|
}
|
|
@@ -283,33 +335,33 @@ let ASPACService = class ASPACService {
|
|
|
283
335
|
if (!token) {
|
|
284
336
|
throw new common_1.HttpException({
|
|
285
337
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
286
|
-
code:
|
|
338
|
+
code: 401010606,
|
|
287
339
|
message: 'Bank token should not be empty.',
|
|
288
|
-
data: { accountTransferDto }
|
|
340
|
+
data: { ...accountTransferDto }
|
|
289
341
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
290
342
|
}
|
|
291
343
|
if (!sourceAccount) {
|
|
292
344
|
throw new common_1.HttpException({
|
|
293
345
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
294
|
-
code:
|
|
295
|
-
message: '
|
|
296
|
-
data: { accountTransferDto }
|
|
346
|
+
code: 400010608,
|
|
347
|
+
message: 'Account number is required',
|
|
348
|
+
data: { ...accountTransferDto }
|
|
297
349
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
298
350
|
}
|
|
299
351
|
if (!amount) {
|
|
300
352
|
throw new common_1.HttpException({
|
|
301
353
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
302
|
-
code:
|
|
303
|
-
message: '
|
|
304
|
-
data: { accountTransferDto }
|
|
354
|
+
code: 400010609,
|
|
355
|
+
message: 'Transaction amount is required.',
|
|
356
|
+
data: { ...accountTransferDto }
|
|
305
357
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
306
358
|
}
|
|
307
359
|
if (!particulars) {
|
|
308
360
|
throw new common_1.HttpException({
|
|
309
361
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
310
|
-
code:
|
|
311
|
-
message: '
|
|
312
|
-
data: { accountTransferDto }
|
|
362
|
+
code: 400010611,
|
|
363
|
+
message: 'Transaction particulars is required.',
|
|
364
|
+
data: { ...accountTransferDto }
|
|
313
365
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
314
366
|
}
|
|
315
367
|
this.logger.log("Welcome Bank cash in");
|
|
@@ -338,6 +390,22 @@ let ASPACService = class ASPACService {
|
|
|
338
390
|
};
|
|
339
391
|
}
|
|
340
392
|
catch (error) {
|
|
393
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
394
|
+
throw new common_1.HttpException({
|
|
395
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
396
|
+
code: 400010607,
|
|
397
|
+
message: 'Account not found.',
|
|
398
|
+
data: { ...accountTransferDto }
|
|
399
|
+
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
400
|
+
}
|
|
401
|
+
if (error.response.data.message === "Amount must be between 0.01 and 500,000.00" || error.response.data.message === "Invalid amount format") {
|
|
402
|
+
throw new common_1.HttpException({
|
|
403
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
404
|
+
code: 422010610,
|
|
405
|
+
message: 'Invalid transaction amount value.',
|
|
406
|
+
data: { ...accountTransferDto }
|
|
407
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
408
|
+
}
|
|
341
409
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
342
410
|
}
|
|
343
411
|
}
|
|
@@ -346,33 +414,33 @@ let ASPACService = class ASPACService {
|
|
|
346
414
|
if (!token) {
|
|
347
415
|
throw new common_1.HttpException({
|
|
348
416
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
349
|
-
code:
|
|
417
|
+
code: 401010706,
|
|
350
418
|
message: 'Bank token should not be empty.',
|
|
351
|
-
data: { accountTransferDto }
|
|
419
|
+
data: { ...accountTransferDto }
|
|
352
420
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
353
421
|
}
|
|
354
422
|
if (!destinationAccount) {
|
|
355
423
|
throw new common_1.HttpException({
|
|
356
424
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
357
|
-
code:
|
|
358
|
-
message: '
|
|
359
|
-
data: { accountTransferDto }
|
|
425
|
+
code: 400010708,
|
|
426
|
+
message: 'Account number is required.',
|
|
427
|
+
data: { ...accountTransferDto }
|
|
360
428
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
361
429
|
}
|
|
362
430
|
if (!amount) {
|
|
363
431
|
throw new common_1.HttpException({
|
|
364
432
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
365
|
-
code:
|
|
366
|
-
message: 'amount
|
|
367
|
-
data: { accountTransferDto }
|
|
433
|
+
code: 400010709,
|
|
434
|
+
message: 'Transaction amount is required.',
|
|
435
|
+
data: { ...accountTransferDto }
|
|
368
436
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
369
437
|
}
|
|
370
438
|
if (!particulars) {
|
|
371
439
|
throw new common_1.HttpException({
|
|
372
440
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
373
|
-
code:
|
|
374
|
-
message: '
|
|
375
|
-
data: { accountTransferDto }
|
|
441
|
+
code: 400010711,
|
|
442
|
+
message: 'Transaction particulars is required.',
|
|
443
|
+
data: { ...accountTransferDto }
|
|
376
444
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
377
445
|
}
|
|
378
446
|
this.logger.log("Welcome Bank deposit");
|
|
@@ -401,43 +469,77 @@ let ASPACService = class ASPACService {
|
|
|
401
469
|
};
|
|
402
470
|
}
|
|
403
471
|
catch (error) {
|
|
472
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
473
|
+
throw new common_1.HttpException({
|
|
474
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
475
|
+
code: 400010707,
|
|
476
|
+
message: 'Account not found.',
|
|
477
|
+
data: { ...accountTransferDto }
|
|
478
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
479
|
+
}
|
|
480
|
+
if (error.response.data.message === "Amount must be between 0.01 and 500,000.00" || error.response.data.message === "Invalid amount format") {
|
|
481
|
+
throw new common_1.HttpException({
|
|
482
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
483
|
+
code: 422010710,
|
|
484
|
+
message: 'Invalid transaction amount value.',
|
|
485
|
+
data: { ...accountTransferDto }
|
|
486
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
487
|
+
}
|
|
404
488
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
405
489
|
}
|
|
406
490
|
}
|
|
407
491
|
async getTransactionHistory(transactionHistoryDto) {
|
|
408
492
|
const { token, account, dateFrom, dateTo, page } = transactionHistoryDto;
|
|
493
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
494
|
+
const reformattedTransactions = {};
|
|
409
495
|
if (!token) {
|
|
410
496
|
throw new common_1.HttpException({
|
|
411
497
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
412
|
-
code:
|
|
498
|
+
code: 401010806,
|
|
413
499
|
message: 'Bank token should not be empty.',
|
|
414
|
-
data: { transactionHistoryDto }
|
|
500
|
+
data: { ...transactionHistoryDto }
|
|
415
501
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
416
502
|
}
|
|
417
503
|
if (!account) {
|
|
418
504
|
throw new common_1.HttpException({
|
|
419
505
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
420
|
-
code:
|
|
421
|
-
message: '
|
|
422
|
-
data: { transactionHistoryDto }
|
|
506
|
+
code: 400010808,
|
|
507
|
+
message: 'Account number is required.',
|
|
508
|
+
data: { ...transactionHistoryDto }
|
|
423
509
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
424
510
|
}
|
|
425
511
|
if (!dateFrom) {
|
|
426
512
|
throw new common_1.HttpException({
|
|
427
513
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
428
|
-
code:
|
|
429
|
-
message: '
|
|
430
|
-
data: { transactionHistoryDto }
|
|
514
|
+
code: 400010810,
|
|
515
|
+
message: 'Starting date is required.',
|
|
516
|
+
data: { ...transactionHistoryDto }
|
|
431
517
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
432
518
|
}
|
|
519
|
+
if (!dateRegex.test(dateFrom)) {
|
|
520
|
+
throw new common_1.HttpException({
|
|
521
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
522
|
+
code: 422010809,
|
|
523
|
+
message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
|
|
524
|
+
data: { ...transactionHistoryDto }
|
|
525
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
526
|
+
}
|
|
433
527
|
if (!dateTo) {
|
|
434
528
|
throw new common_1.HttpException({
|
|
435
529
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
436
|
-
code:
|
|
437
|
-
message: '
|
|
438
|
-
data: { transactionHistoryDto }
|
|
530
|
+
code: 400010812,
|
|
531
|
+
message: 'Ending date is required.',
|
|
532
|
+
data: { ...transactionHistoryDto }
|
|
439
533
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
440
534
|
}
|
|
535
|
+
if (!dateRegex.test(dateTo)) {
|
|
536
|
+
throw new common_1.HttpException({
|
|
537
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
538
|
+
code: 422010811,
|
|
539
|
+
message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
|
|
540
|
+
data: { ...transactionHistoryDto }
|
|
541
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
542
|
+
}
|
|
441
543
|
this.logger.log("Welcome Bank transaction history");
|
|
442
544
|
try {
|
|
443
545
|
const headers = {
|
|
@@ -459,12 +561,42 @@ let ASPACService = class ASPACService {
|
|
|
459
561
|
httpsAgent
|
|
460
562
|
});
|
|
461
563
|
this.logger.log({ responseData: response.data }, 'Welcome Bank Transaction History Successful');
|
|
564
|
+
response.data.data.transactions.forEach((txn, index) => {
|
|
565
|
+
const key = `${index + 1}`;
|
|
566
|
+
const dateTime = this.combineDateTime(txn.tranDate, txn.tranTime);
|
|
567
|
+
reformattedTransactions[key] = {
|
|
568
|
+
dateTime,
|
|
569
|
+
amount: txn.tranAmount,
|
|
570
|
+
type: txn.tranType,
|
|
571
|
+
description: txn.description,
|
|
572
|
+
transactionReference: txn.tranReference
|
|
573
|
+
};
|
|
574
|
+
});
|
|
462
575
|
return {
|
|
463
576
|
success: true,
|
|
464
|
-
|
|
577
|
+
message: response.data.data.message,
|
|
578
|
+
correlationId: response.data.correlationId,
|
|
579
|
+
timestamp: response.data.timestamp,
|
|
580
|
+
transactions: reformattedTransactions,
|
|
465
581
|
};
|
|
466
582
|
}
|
|
467
583
|
catch (error) {
|
|
584
|
+
if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
|
|
585
|
+
throw new common_1.HttpException({
|
|
586
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
587
|
+
code: 400010807,
|
|
588
|
+
message: 'Account not found.',
|
|
589
|
+
data: { ...transactionHistoryDto }
|
|
590
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
591
|
+
}
|
|
592
|
+
if (error.response.data.message === "Invalid page number format") {
|
|
593
|
+
throw new common_1.HttpException({
|
|
594
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
595
|
+
code: 422010813,
|
|
596
|
+
message: 'Invalid page number format.',
|
|
597
|
+
data: { ...transactionHistoryDto }
|
|
598
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
599
|
+
}
|
|
468
600
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
469
601
|
}
|
|
470
602
|
}
|