Skip to content

Commit 057ce6f

Browse files
authored
Merge pull request #99 from JyotiSharma0711/master
RSF version 2.0.0 utility changes
2 parents 390eafd + 9ccc38d commit 057ce6f

24 files changed

+1724
-19
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,29 @@ curl --location 'https://localhost:3006/api/validate/trv' \
688688
}
689689
}'
690690
```
691+
### For RSF V2 Sample Curl Request (Local)
692+
693+
```shell
694+
curl --location 'http://localhost:3008/api/validate/rsf' \
695+
--header 'Content-Type: application/json' \
696+
--data '{
697+
"domain": "ONDC:NTS10",
698+
"version": "2.0.0",
699+
"bap_id": "BUYER_APP_SUBSCRIBER_ID",
700+
"bpp_id": "SELLER_APP_SUBSCRIBER_ID",
701+
"payload": {
702+
703+
"settle":{},
704+
"on_settle":{},
705+
"report":{},
706+
"on_report":{},
707+
"recon":{},
708+
"on_recon":{}
709+
}
710+
}'
711+
712+
```
713+
691714

692715
Using Postman, you can import the above `curl` command into Postman and replace the empty objects in the payload with your actual data. This allows for easy testing and validation of transaction logs on your local environment.
693716

constants/RSFv2ErrorCodes.ts

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
export const RSF_v2_Errors = {
2+
"70000": {
3+
From: "Any",
4+
Event: "NACK",
5+
Description: "Invalid Signature",
6+
},
7+
"70001": {
8+
From: "Any",
9+
Event: "NACK",
10+
Description: "Missing mandatory 'Authorization' header param",
11+
},
12+
"70002": {
13+
From: "Any",
14+
Event: "NACK",
15+
Description: "Invalid schema",
16+
},
17+
"70003": {
18+
From: "Any",
19+
Event: "OnSettle",
20+
Description: "Invalid bap id",
21+
},
22+
"70004": {
23+
From: "Any",
24+
Event: "OnSettle",
25+
Description: "Inactive bap id",
26+
},
27+
"70005": {
28+
From: "Any",
29+
Event: "OnSettle",
30+
Description: "Invalid bpp id",
31+
},
32+
"70006": {
33+
From: "Any",
34+
Event: "OnSettle",
35+
Description: "Duplicate transaction id",
36+
},
37+
"70007": {
38+
From: "Any",
39+
Event: "OnSettle",
40+
Description: "Duplicate message id",
41+
},
42+
"70008": {
43+
From: "Any",
44+
Event: "OnSettle",
45+
Description: "Duplicate settlement id",
46+
},
47+
"70009": {
48+
From: "Any",
49+
Event: "OnSettle",
50+
Description: "Bap id doesn't match collector app id or receiver app id",
51+
},
52+
"70010": {
53+
From: "Any",
54+
Event: "OnSettle",
55+
Description: "Collector account not available",
56+
},
57+
"70011": {
58+
From: "Any",
59+
Event: "OnSettle",
60+
Description: "Invalid collector app id",
61+
},
62+
"70012": {
63+
From: "Any",
64+
Event: "OnSettle",
65+
Description: "Inactive collector app id",
66+
},
67+
"70013": {
68+
From: "Any",
69+
Event: "OnSettle",
70+
Description: "Invalid receiver app id",
71+
},
72+
"70014": {
73+
From: "Any",
74+
Event: "OnSettle",
75+
Description: "Inactive receiver app id",
76+
},
77+
"70015": {
78+
From: "Any",
79+
Event: "OnSettle",
80+
Description: "Receiver app id same as Collector app id",
81+
},
82+
"70016": {
83+
From: "Any",
84+
Event: "OnSettle",
85+
Description: "Duplicate order id",
86+
},
87+
"70017": {
88+
From: "Any",
89+
Event: "OnSettle",
90+
Description: "Collector account inoperable",
91+
},
92+
"70018": {
93+
From: "Any",
94+
Event: "OnSettle",
95+
Description: "Receiver account inoperable",
96+
},
97+
"70019": {
98+
From: "Any",
99+
Event: "OnSettle",
100+
Description: "No response from bank for collector account",
101+
},
102+
"70020": {
103+
From: "Any",
104+
Event: "OnSettle",
105+
Description: "No response from bank for receiver account",
106+
},
107+
"70021": {
108+
From: "Any",
109+
Event: "OnSettle",
110+
Description: "No file shared by counterparty",
111+
},
112+
"70022": {
113+
From: "Any",
114+
Event: "OnSettle",
115+
Description: "Order id not shared by counterparty",
116+
},
117+
"70023": {
118+
From: "Any",
119+
Event: "OnSettle",
120+
Description: "Collector value mismatch",
121+
},
122+
"70024": {
123+
From: "Any",
124+
Event: "OnSettle",
125+
Description: "Interparticipant value mismatch",
126+
},
127+
"70025": {
128+
From: "Any",
129+
Event: "OnSettle",
130+
Description: "Insufficient balance in collector account",
131+
},
132+
"70026": {
133+
From: "Any",
134+
Event: "OnSettle",
135+
Description: "Collector NDC breach",
136+
},
137+
"70027": {
138+
From: "Any",
139+
Event: "OnSettle",
140+
Description: "Collector bank NDC breach",
141+
},
142+
"503": {
143+
From: "Any",
144+
Event: "https error",
145+
Description: "Internal server error",
146+
},
147+
};
148+

constants/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export default Object.freeze({
4343
RET_ONISSUE_STATUS: 'on_issue_status',
4444
RECEIVER_RECON: 'receiver_recon',
4545
ON_RECEIVER_RECON: 'on_receiver_recon',
46+
SETTLE: 'settle',
47+
ON_SETTLE: 'on_settle',
48+
REPORT: 'report',
49+
ON_REPORT: 'on_report',
50+
RECON: 'recon',
51+
ON_RECON: 'on_recon',
4652
})
4753

4854
export const ApiSequence = {
@@ -364,6 +370,14 @@ export const RSFapiSequence = {
364370
ON_RECEIVER_RECON: 'on_receiver_recon',
365371
}
366372

373+
export const RSF_v2_apiSequence = {
374+
SETTLE: 'settle',
375+
ON_SETTLE: 'on_settle',
376+
REPORT: 'report',
377+
ON_REPORT: 'on_report',
378+
RECON: 'recon',
379+
ON_RECON: 'on_recon',
380+
}
367381
export const actionsArray = [
368382
'search',
369383
'on_search',

controller/validate/helper.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _ from 'lodash'
22
import { sign, hash } from '../../shared/crypto'
33
import { logger } from '../../shared/logger'
44
import { DOMAIN, ERROR_MESSAGE } from '../../shared/types'
5-
import { IGMvalidateLogs, validateLogs, RSFvalidateLogs } from '../../shared/validateLogs'
5+
import { IGMvalidateLogs, validateLogs, RSFvalidateLogs, RSFvalidateLogsV2 } from '../../shared/validateLogs'
66
import { validateLogsForFIS12 } from '../../shared/Actions/FIS12Actions'
77
import { validateLogsForMobility } from '../../shared/Actions/mobilityActions'
88
import { validateLogsForMetro } from '../../shared/Actions/metroActions'
@@ -188,6 +188,7 @@ const validateIGM = async (payload: string, version: string) => {
188188
return { response, success, message }
189189
}
190190
const validateRSF = async (payload: string, version: string) => {
191+
logger.info('Entering validateRSF function')
191192
let response
192193
let success = false
193194
let message = ERROR_MESSAGE.LOG_VERIFICATION_UNSUCCESSFUL
@@ -199,8 +200,18 @@ const validateRSF = async (payload: string, version: string) => {
199200
success = true
200201
message = ERROR_MESSAGE.LOG_VERIFICATION_SUCCESSFUL
201202
}
203+
break;
204+
205+
case '2.0.0':
206+
response = RSFvalidateLogsV2(payload)
207+
logger.info('RSF 2.0.0 validation response:', response)
208+
209+
if (_.isEmpty(response)) {
210+
success = true
211+
message = ERROR_MESSAGE.LOG_VERIFICATION_SUCCESSFUL
212+
}
213+
break;
202214

203-
break
204215
default:
205216
message = ERROR_MESSAGE.LOG_VERIFICATION_INVALID_VERSION
206217
logger.warn('Invalid Version!!')

controller/validate/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const controller = {
1616
let result: { response?: string; success?: boolean; message?: string } = {}
1717
const splitPath = req.originalUrl.split('/')
1818
const pathUrl = splitPath[splitPath.length - 1]
19-
2019
const normalisedDomain = helper.getEnumForDomain(pathUrl)
2120

2221
switch (normalisedDomain) {

schema/RSF/RSF_v2/on_reconSchema.ts

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
const on_reconSchema = {
2+
type: "object",
3+
required: ["context", "message"],
4+
properties: {
5+
context: {
6+
type: "object",
7+
required: [
8+
"domain",
9+
"location",
10+
"version",
11+
"action",
12+
"bap_id",
13+
"bap_uri",
14+
"bpp_id",
15+
"bpp_uri",
16+
"transaction_id",
17+
"message_id",
18+
"timestamp",
19+
"ttl"
20+
],
21+
properties: {
22+
domain: { type: "string", const: "ONDC:NTS10" },
23+
location: {
24+
type: "object",
25+
required: ["country", "city"],
26+
properties: {
27+
country: {
28+
type: "object",
29+
required: ["code"],
30+
properties: {
31+
code: { type: "string", const: "IND" }
32+
}
33+
},
34+
city: {
35+
type: "object",
36+
required: ["code"],
37+
properties: {
38+
code: { type: "string", const: "*" }
39+
}
40+
}
41+
}
42+
},
43+
version: { type: "string", const: "2.0.0" },
44+
action: { type: "string", const: "on_recon" },
45+
bap_id: { type: "string" },
46+
bap_uri: { type: "string", format: "uri" },
47+
bpp_id: { type: "string" },
48+
bpp_uri: { type: "string", format: "uri" },
49+
transaction_id: { type: "string" },
50+
message_id: { type: "string" },
51+
timestamp: { type: "string", format: "date-time" },
52+
ttl: { type: "string"}
53+
}
54+
},
55+
message: {
56+
type: "object",
57+
required: ["orders"],
58+
properties: {
59+
orders: {
60+
type: "array",
61+
items: {
62+
type: "object",
63+
required: ["id", "amount", "recon_accord", "settlements"],
64+
properties: {
65+
id: { type: "string" },
66+
amount: {
67+
type: "object",
68+
required: ["currency", "value"],
69+
properties: {
70+
currency: { type: "string", const: "INR" },
71+
value: { type: "string" }
72+
}
73+
},
74+
recon_accord: { type: "boolean" },
75+
settlements: {
76+
type: "array",
77+
items: {
78+
type: "object",
79+
required: ["id", "payment_id", "status", "amount", "commission", "withholding_amount", "tcs", "tds", "updated_at"],
80+
properties: {
81+
id: { type: "string" },
82+
payment_id: { type: "string" },
83+
status: { type: "string", enum: ["PENDING", "SETTLED", "TO-BE-INITIATED"] },
84+
settlement_ref_no: { type: "string" },
85+
amount: {
86+
type: "object",
87+
required: ["currency", "value"],
88+
properties: {
89+
currency: { type: "string", const: "INR" },
90+
value: { type: "string", pattern: "^\\d+\\.\\d{2}$" },
91+
diff_value: { type: "string", pattern: "^\\d+\\.\\d{2}$" }
92+
}
93+
},
94+
commission: {
95+
type: "object",
96+
required: ["currency", "value"],
97+
properties: {
98+
currency: { type: "string", const: "INR" },
99+
value: { type: "string", pattern: "^\\d+\\.\\d{2}$" },
100+
diff_value: { type: "string", pattern: "^\\d+\\.\\d{2}$" }
101+
}
102+
},
103+
withholding_amount: {
104+
type: "object",
105+
required: ["currency", "value"],
106+
properties: {
107+
currency: { type: "string", const: "INR" },
108+
value: { type: "string", pattern: "^\\d+\\.\\d{2}$" },
109+
diff_value: { type: "string", pattern: "^\\d+\\.\\d{2}$" }
110+
}
111+
},
112+
tcs: {
113+
type: "object",
114+
required: ["currency", "value"],
115+
properties: {
116+
currency: { type: "string", const: "INR" },
117+
value: { type: "string", pattern: "^\\d+\\.\\d{2}$" },
118+
diff_value: { type: "string", pattern: "^\\d+\\.\\d{2}$" }
119+
}
120+
},
121+
tds: {
122+
type: "object",
123+
required: ["currency", "value"],
124+
properties: {
125+
currency: { type: "string", const: "INR" },
126+
value: { type: "string", pattern: "^\\d+\\.\\d{2}$" },
127+
diff_value: { type: "string", pattern: "^\\d+\\.\\d{2}$" }
128+
}
129+
},
130+
updated_at: { type: "string", format: "date-time" }
131+
}
132+
}
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}
140+
};
141+
142+
export default on_reconSchema;

0 commit comments

Comments
 (0)