@traxionpay/cbsmiddleware 0.0.1 → 0.0.3
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 -84
- 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 +311 -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 -87
- package/src/banking/services/WelcomeBank.service.ts +389 -160
|
@@ -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,11 +62,16 @@ 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 {
|
|
68
74
|
const headers = {
|
|
69
|
-
'Content-Type': 'application/json',
|
|
70
75
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
71
76
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
72
77
|
};
|
|
@@ -91,15 +96,14 @@ let ASPACService = class ASPACService {
|
|
|
91
96
|
if (!refreshToken) {
|
|
92
97
|
throw new common_1.HttpException({
|
|
93
98
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
94
|
-
code:
|
|
95
|
-
message: '
|
|
99
|
+
code: 400010205,
|
|
100
|
+
message: 'Refresh token is required.',
|
|
96
101
|
data: { refreshToken }
|
|
97
102
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
98
103
|
}
|
|
99
104
|
this.logger.log("Welcome Bank refresh token");
|
|
100
105
|
try {
|
|
101
106
|
const headers = {
|
|
102
|
-
'Content-Type': 'application/json',
|
|
103
107
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
104
108
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
105
109
|
};
|
|
@@ -120,48 +124,46 @@ let ASPACService = class ASPACService {
|
|
|
120
124
|
};
|
|
121
125
|
}
|
|
122
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
|
+
}
|
|
123
135
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
124
136
|
}
|
|
125
137
|
}
|
|
126
138
|
async linkAccount(accountDto) {
|
|
127
|
-
const {
|
|
128
|
-
if (!token) {
|
|
129
|
-
throw new common_1.HttpException({
|
|
130
|
-
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
131
|
-
code: 4000,
|
|
132
|
-
message: 'Bank token should not be empty.',
|
|
133
|
-
data: { accountDto }
|
|
134
|
-
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
135
|
-
}
|
|
139
|
+
const { account, accountType, mobile } = accountDto;
|
|
136
140
|
if (!account) {
|
|
137
141
|
throw new common_1.HttpException({
|
|
138
142
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
139
|
-
code:
|
|
140
|
-
message: '
|
|
141
|
-
data: { accountDto }
|
|
143
|
+
code: 400010306,
|
|
144
|
+
message: 'Account number is required.',
|
|
145
|
+
data: { ...accountDto }
|
|
142
146
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
143
147
|
}
|
|
144
148
|
if (!accountType) {
|
|
145
149
|
throw new common_1.HttpException({
|
|
146
150
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
147
|
-
code:
|
|
148
|
-
message: '
|
|
149
|
-
data: { accountDto }
|
|
151
|
+
code: 400010308,
|
|
152
|
+
message: 'Account type is required.',
|
|
153
|
+
data: { ...accountDto }
|
|
150
154
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
151
155
|
}
|
|
152
156
|
if (!mobile) {
|
|
153
157
|
throw new common_1.HttpException({
|
|
154
158
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
155
|
-
code:
|
|
156
|
-
message: 'Mobile
|
|
157
|
-
data: { accountDto }
|
|
159
|
+
code: 4000103011,
|
|
160
|
+
message: 'Mobile number is required.',
|
|
161
|
+
data: { ...accountDto }
|
|
158
162
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
159
163
|
}
|
|
160
164
|
this.logger.log("Welcome Bank Link Account");
|
|
161
165
|
try {
|
|
162
166
|
const headers = {
|
|
163
|
-
'Authorization': `Bearer ${token}`,
|
|
164
|
-
'Content-Type': 'application/json',
|
|
165
167
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
166
168
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
167
169
|
};
|
|
@@ -179,40 +181,62 @@ let ASPACService = class ASPACService {
|
|
|
179
181
|
};
|
|
180
182
|
}
|
|
181
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
|
+
}
|
|
182
216
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
183
217
|
}
|
|
184
218
|
}
|
|
185
219
|
async validateOtp(validateOtp) {
|
|
186
|
-
const {
|
|
187
|
-
if (!token) {
|
|
188
|
-
throw new common_1.HttpException({
|
|
189
|
-
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
190
|
-
code: 4000,
|
|
191
|
-
message: 'Bank token should not be empty.',
|
|
192
|
-
data: { validateOtp }
|
|
193
|
-
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
194
|
-
}
|
|
220
|
+
const { account, otp } = validateOtp;
|
|
195
221
|
if (!account) {
|
|
196
222
|
throw new common_1.HttpException({
|
|
197
223
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
198
|
-
code:
|
|
199
|
-
message: '
|
|
200
|
-
data: { validateOtp }
|
|
224
|
+
code: 400010406,
|
|
225
|
+
message: 'Account number is required.',
|
|
226
|
+
data: { ...validateOtp }
|
|
201
227
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
202
228
|
}
|
|
203
229
|
if (!otp) {
|
|
204
230
|
throw new common_1.HttpException({
|
|
205
231
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
206
|
-
code:
|
|
207
|
-
message: '
|
|
208
|
-
data: { validateOtp }
|
|
232
|
+
code: 400010408,
|
|
233
|
+
message: 'OTP is required.',
|
|
234
|
+
data: { ...validateOtp }
|
|
209
235
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
210
236
|
}
|
|
211
237
|
this.logger.log("Welcome Bank Validate OTP");
|
|
212
238
|
try {
|
|
213
239
|
const headers = {
|
|
214
|
-
'Authorization': `Bearer ${token}`,
|
|
215
|
-
'Content-Type': 'application/json',
|
|
216
240
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
217
241
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
218
242
|
};
|
|
@@ -234,6 +258,22 @@ let ASPACService = class ASPACService {
|
|
|
234
258
|
};
|
|
235
259
|
}
|
|
236
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
|
+
}
|
|
237
277
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
238
278
|
}
|
|
239
279
|
}
|
|
@@ -242,24 +282,23 @@ let ASPACService = class ASPACService {
|
|
|
242
282
|
if (!token) {
|
|
243
283
|
throw new common_1.HttpException({
|
|
244
284
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
245
|
-
code:
|
|
285
|
+
code: 401010506,
|
|
246
286
|
message: 'Bank token should not be empty.',
|
|
247
|
-
data: { fetchBalanceDto }
|
|
287
|
+
data: { ...fetchBalanceDto }
|
|
248
288
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
249
289
|
}
|
|
250
290
|
if (!account) {
|
|
251
291
|
throw new common_1.HttpException({
|
|
252
292
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
253
|
-
code:
|
|
254
|
-
message: '
|
|
255
|
-
data: { fetchBalanceDto }
|
|
293
|
+
code: 400010508,
|
|
294
|
+
message: 'Account number is required.',
|
|
295
|
+
data: { ...fetchBalanceDto }
|
|
256
296
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
257
297
|
}
|
|
258
298
|
this.logger.log("Welcome Bank Balance Inquiry");
|
|
259
299
|
try {
|
|
260
300
|
const headers = {
|
|
261
301
|
'Authorization': `Bearer ${token}`,
|
|
262
|
-
'Content-Type': 'application/json',
|
|
263
302
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
264
303
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
265
304
|
};
|
|
@@ -280,6 +319,14 @@ let ASPACService = class ASPACService {
|
|
|
280
319
|
};
|
|
281
320
|
}
|
|
282
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
|
+
}
|
|
283
330
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
284
331
|
}
|
|
285
332
|
}
|
|
@@ -288,40 +335,39 @@ let ASPACService = class ASPACService {
|
|
|
288
335
|
if (!token) {
|
|
289
336
|
throw new common_1.HttpException({
|
|
290
337
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
291
|
-
code:
|
|
338
|
+
code: 401010606,
|
|
292
339
|
message: 'Bank token should not be empty.',
|
|
293
|
-
data: { accountTransferDto }
|
|
340
|
+
data: { ...accountTransferDto }
|
|
294
341
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
295
342
|
}
|
|
296
343
|
if (!sourceAccount) {
|
|
297
344
|
throw new common_1.HttpException({
|
|
298
345
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
299
|
-
code:
|
|
300
|
-
message: '
|
|
301
|
-
data: { accountTransferDto }
|
|
346
|
+
code: 400010608,
|
|
347
|
+
message: 'Account number is required',
|
|
348
|
+
data: { ...accountTransferDto }
|
|
302
349
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
303
350
|
}
|
|
304
351
|
if (!amount) {
|
|
305
352
|
throw new common_1.HttpException({
|
|
306
353
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
307
|
-
code:
|
|
308
|
-
message: '
|
|
309
|
-
data: { accountTransferDto }
|
|
354
|
+
code: 400010609,
|
|
355
|
+
message: 'Transaction amount is required.',
|
|
356
|
+
data: { ...accountTransferDto }
|
|
310
357
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
311
358
|
}
|
|
312
359
|
if (!particulars) {
|
|
313
360
|
throw new common_1.HttpException({
|
|
314
361
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
315
|
-
code:
|
|
316
|
-
message: '
|
|
317
|
-
data: { accountTransferDto }
|
|
362
|
+
code: 400010611,
|
|
363
|
+
message: 'Transaction particulars is required.',
|
|
364
|
+
data: { ...accountTransferDto }
|
|
318
365
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
319
366
|
}
|
|
320
367
|
this.logger.log("Welcome Bank cash in");
|
|
321
368
|
try {
|
|
322
369
|
const headers = {
|
|
323
370
|
'Authorization': `Bearer ${token}`,
|
|
324
|
-
'Content-Type': 'application/json',
|
|
325
371
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
326
372
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
327
373
|
};
|
|
@@ -344,6 +390,22 @@ let ASPACService = class ASPACService {
|
|
|
344
390
|
};
|
|
345
391
|
}
|
|
346
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
|
+
}
|
|
347
409
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
348
410
|
}
|
|
349
411
|
}
|
|
@@ -352,40 +414,39 @@ let ASPACService = class ASPACService {
|
|
|
352
414
|
if (!token) {
|
|
353
415
|
throw new common_1.HttpException({
|
|
354
416
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
355
|
-
code:
|
|
417
|
+
code: 401010706,
|
|
356
418
|
message: 'Bank token should not be empty.',
|
|
357
|
-
data: { accountTransferDto }
|
|
419
|
+
data: { ...accountTransferDto }
|
|
358
420
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
359
421
|
}
|
|
360
422
|
if (!destinationAccount) {
|
|
361
423
|
throw new common_1.HttpException({
|
|
362
424
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
363
|
-
code:
|
|
364
|
-
message: '
|
|
365
|
-
data: { accountTransferDto }
|
|
425
|
+
code: 400010708,
|
|
426
|
+
message: 'Account number is required.',
|
|
427
|
+
data: { ...accountTransferDto }
|
|
366
428
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
367
429
|
}
|
|
368
430
|
if (!amount) {
|
|
369
431
|
throw new common_1.HttpException({
|
|
370
432
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
371
|
-
code:
|
|
372
|
-
message: 'amount
|
|
373
|
-
data: { accountTransferDto }
|
|
433
|
+
code: 400010709,
|
|
434
|
+
message: 'Transaction amount is required.',
|
|
435
|
+
data: { ...accountTransferDto }
|
|
374
436
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
375
437
|
}
|
|
376
438
|
if (!particulars) {
|
|
377
439
|
throw new common_1.HttpException({
|
|
378
440
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
379
|
-
code:
|
|
380
|
-
message: '
|
|
381
|
-
data: { accountTransferDto }
|
|
441
|
+
code: 400010711,
|
|
442
|
+
message: 'Transaction particulars is required.',
|
|
443
|
+
data: { ...accountTransferDto }
|
|
382
444
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
383
445
|
}
|
|
384
446
|
this.logger.log("Welcome Bank deposit");
|
|
385
447
|
try {
|
|
386
448
|
const headers = {
|
|
387
449
|
'Authorization': `Bearer ${token}`,
|
|
388
|
-
'Content-Type': 'application/json',
|
|
389
450
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
390
451
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
391
452
|
};
|
|
@@ -408,48 +469,81 @@ let ASPACService = class ASPACService {
|
|
|
408
469
|
};
|
|
409
470
|
}
|
|
410
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
|
+
}
|
|
411
488
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
412
489
|
}
|
|
413
490
|
}
|
|
414
491
|
async getTransactionHistory(transactionHistoryDto) {
|
|
415
492
|
const { token, account, dateFrom, dateTo, page } = transactionHistoryDto;
|
|
493
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
494
|
+
const reformattedTransactions = {};
|
|
416
495
|
if (!token) {
|
|
417
496
|
throw new common_1.HttpException({
|
|
418
497
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
419
|
-
code:
|
|
498
|
+
code: 401010806,
|
|
420
499
|
message: 'Bank token should not be empty.',
|
|
421
|
-
data: { transactionHistoryDto }
|
|
500
|
+
data: { ...transactionHistoryDto }
|
|
422
501
|
}, common_1.HttpStatus.UNAUTHORIZED);
|
|
423
502
|
}
|
|
424
503
|
if (!account) {
|
|
425
504
|
throw new common_1.HttpException({
|
|
426
505
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
427
|
-
code:
|
|
428
|
-
message: '
|
|
429
|
-
data: { transactionHistoryDto }
|
|
506
|
+
code: 400010808,
|
|
507
|
+
message: 'Account number is required.',
|
|
508
|
+
data: { ...transactionHistoryDto }
|
|
430
509
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
431
510
|
}
|
|
432
511
|
if (!dateFrom) {
|
|
433
512
|
throw new common_1.HttpException({
|
|
434
513
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
435
|
-
code:
|
|
436
|
-
message: '
|
|
437
|
-
data: { transactionHistoryDto }
|
|
514
|
+
code: 400010810,
|
|
515
|
+
message: 'Starting date is required.',
|
|
516
|
+
data: { ...transactionHistoryDto }
|
|
438
517
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
439
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
|
+
}
|
|
440
527
|
if (!dateTo) {
|
|
441
528
|
throw new common_1.HttpException({
|
|
442
529
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
443
|
-
code:
|
|
444
|
-
message: '
|
|
445
|
-
data: { transactionHistoryDto }
|
|
530
|
+
code: 400010812,
|
|
531
|
+
message: 'Ending date is required.',
|
|
532
|
+
data: { ...transactionHistoryDto }
|
|
446
533
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
447
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
|
+
}
|
|
448
543
|
this.logger.log("Welcome Bank transaction history");
|
|
449
544
|
try {
|
|
450
545
|
const headers = {
|
|
451
546
|
'Authorization': `Bearer ${token}`,
|
|
452
|
-
'Content-Type': 'application/json',
|
|
453
547
|
'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
|
|
454
548
|
'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
|
|
455
549
|
};
|
|
@@ -467,12 +561,42 @@ let ASPACService = class ASPACService {
|
|
|
467
561
|
httpsAgent
|
|
468
562
|
});
|
|
469
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
|
+
});
|
|
470
575
|
return {
|
|
471
576
|
success: true,
|
|
472
|
-
|
|
577
|
+
message: response.data.data.message,
|
|
578
|
+
correlationId: response.data.correlationId,
|
|
579
|
+
timestamp: response.data.timestamp,
|
|
580
|
+
transactions: reformattedTransactions,
|
|
473
581
|
};
|
|
474
582
|
}
|
|
475
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
|
+
}
|
|
476
600
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
477
601
|
}
|
|
478
602
|
}
|