Skip to content

Commit 5cffd86

Browse files
authored
Merge pull request #106 from ONDC-Official/feat/TRV14
feat:TRV14 added
2 parents 057ce6f + 5bf0238 commit 5cffd86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3377
-4
lines changed

constants/index.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,27 @@ export const FIS14ApiSequence = {
197197
ON_UPDATE: 'on_update',
198198
ON_UPDATE_1: 'on_update_1',
199199
}
200-
200+
export const TRV14ApiSequence = {
201+
SEARCH: 'search',
202+
ON_SEARCH1: 'on_search_1',
203+
ON_SEARCH2: 'on_search_2',
204+
SELECT1: 'select_1',
205+
ON_SELECT1: 'on_select_1',
206+
SELECT2: 'select_2',
207+
ON_SELECT2: 'on_select_2',
208+
INIT: 'init',
209+
ON_INIT: 'on_init',
210+
CONFIRM: 'confirm',
211+
ON_CONFIRM: 'on_confirm',
212+
STATUS: 'status',
213+
ON_STATUS: 'on_status',
214+
SOFT_CANCEL: 'soft_cancel',
215+
SOFT_ON_CANCEL: 'soft_on_cancel',
216+
CANCEL: 'cancel',
217+
ON_CANCEL: 'on_cancel',
218+
UPDATE: 'update',
219+
ON_UPDATE: 'on_update',
220+
}
201221
export const mobilitySequence = {
202222
SEARCH: 'search',
203223
SEARCH_INC: 'search_inc',

controller/validate/helper.ts

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { validateLogsForFIS10 } from '../../shared/Actions/FIS10Actions'
1010
import { validateLogsForFIS13 } from '../../shared/Actions/FIS13Actions'
1111
import { validateLogsForTRV13 } from '../../shared/Actions/TRV13Actions'
1212
import { getFis14Format, validateLogsForFIS14 } from '../../shared/Actions/FIS14Actions'
13+
import { validateLogsForTRV14 } from '../../shared/Actions/TRV14Actions'
1314

1415
const createSignature = async ({ message }: { message: string }) => {
1516
const privateKey = process.env.SIGN_PRIVATE_KEY as string
@@ -126,6 +127,7 @@ const validateMobility = async (domain: string, payload: string, version: string
126127
let success = false
127128
let message = ERROR_MESSAGE.LOG_VERIFICATION_UNSUCCESSFUL
128129

130+
129131
if (!flow) throw new Error('Flow not defined')
130132

131133
switch (domain) {
@@ -156,8 +158,16 @@ const validateMobility = async (domain: string, payload: string, version: string
156158
success = true
157159
message = ERROR_MESSAGE.LOG_VERIFICATION_SUCCESSFUL
158160
}
161+
break
162+
case 'ONDC:TRV14':
163+
response = validateLogsForTRV14(payload, flow, version)
159164

165+
if (_.isEmpty(response)) {
166+
success = true
167+
message = ERROR_MESSAGE.LOG_VERIFICATION_SUCCESSFUL
168+
}
160169
break
170+
161171
default:
162172
message = ERROR_MESSAGE.LOG_VERIFICATION_INVALID_DOMAIN
163173
logger.warn('Invalid Domain!!')

index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { logger } from './shared/logger'
33
import createServer from './app'
44

55
dotenv.config()
6-
const port = process.env.PORT || 3008
6+
const port = process.env.PORT
77

88
const app = createServer()
99

schema/TRV-14/cancel1.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const cancel1SchemaTRV14 = {
2+
type: 'object',
3+
required: ['context', 'message'],
4+
properties: {
5+
context: {
6+
type: 'object',
7+
required: [
8+
'location',
9+
'domain',
10+
'timestamp',
11+
'bap_id',
12+
'transaction_id',
13+
'message_id',
14+
'version',
15+
'action',
16+
'bap_uri',
17+
'ttl',
18+
'bpp_id',
19+
'bpp_uri',
20+
],
21+
properties: {
22+
location: {
23+
type: 'object',
24+
required: ['country', 'city'],
25+
properties: {
26+
country: {
27+
type: 'object',
28+
required: ['code'],
29+
properties: {
30+
code: { type: 'string', enum: ['IND'] },
31+
},
32+
},
33+
city: {
34+
type: 'object',
35+
required: ['code'],
36+
properties: {
37+
code: { type: 'string' },
38+
},
39+
},
40+
},
41+
},
42+
domain: { type: 'string', enum: ['ONDC:TRV14'] },
43+
timestamp: { type: 'string', format: 'date-time' },
44+
bap_id: { type: 'string' },
45+
transaction_id: { type: 'string' },
46+
message_id: { type: 'string' },
47+
version: { type: 'string', enum: ['2.0.0'] },
48+
action: { type: 'string', enum: ['cancel_1'] },
49+
bap_uri: { type: 'string', format: 'uri' },
50+
ttl: { type: 'string', pattern: '^PT\\d+S$' },
51+
bpp_id: { type: 'string' },
52+
bpp_uri: { type: 'string', format: 'uri' },
53+
},
54+
},
55+
message: {
56+
type: 'object',
57+
required: ['order_id', 'cancellation_reason_id', 'descriptor'],
58+
properties: {
59+
order_id: { type: 'string' },
60+
cancellation_reason_id: { type: 'string' },
61+
descriptor: {
62+
type: 'object',
63+
required: ['name', 'code'],
64+
properties: {
65+
name: { type: 'string' },
66+
code: { type: 'string' },
67+
},
68+
},
69+
},
70+
},
71+
},
72+
}
73+
74+
export default cancel1SchemaTRV14

schema/TRV-14/cancel2.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const cancel2SchemaTRV14 = {
2+
type: 'object',
3+
required: ['context', 'message'],
4+
properties: {
5+
context: {
6+
type: 'object',
7+
required: [
8+
'location',
9+
'domain',
10+
'timestamp',
11+
'bap_id',
12+
'transaction_id',
13+
'message_id',
14+
'version',
15+
'action',
16+
'bap_uri',
17+
'ttl',
18+
'bpp_id',
19+
'bpp_uri',
20+
],
21+
properties: {
22+
location: {
23+
type: 'object',
24+
required: ['country', 'city'],
25+
properties: {
26+
country: {
27+
type: 'object',
28+
required: ['code'],
29+
properties: {
30+
code: { type: 'string', enum: ['IND'] },
31+
},
32+
},
33+
city: {
34+
type: 'object',
35+
required: ['code'],
36+
properties: {
37+
code: { type: 'string' },
38+
},
39+
},
40+
},
41+
},
42+
domain: { type: 'string', enum: ['ONDC:TRV14'] },
43+
timestamp: { type: 'string', format: 'date-time' },
44+
bap_id: { type: 'string' },
45+
transaction_id: { type: 'string' },
46+
message_id: { type: 'string' },
47+
version: { type: 'string', enum: ['2.0.0'] },
48+
action: { type: 'string', enum: ['cancel_2'] },
49+
bap_uri: { type: 'string', format: 'uri' },
50+
ttl: { type: 'string', pattern: '^PT\\d+S$' },
51+
bpp_id: { type: 'string' },
52+
bpp_uri: { type: 'string', format: 'uri' },
53+
},
54+
},
55+
message: {
56+
type: 'object',
57+
required: ['order_id', 'cancellation_reason_id', 'descriptor'],
58+
properties: {
59+
order_id: { type: 'string' },
60+
cancellation_reason_id: { type: 'string' },
61+
descriptor: {
62+
type: 'object',
63+
required: ['name', 'code'],
64+
properties: {
65+
name: { type: 'string' },
66+
code: { type: 'string', enum: ['CONFIRM_CANCEL'] },
67+
},
68+
},
69+
},
70+
},
71+
},
72+
}
73+
74+
export default cancel2SchemaTRV14

schema/TRV-14/confirm.ts

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
const confirmSchemaTRV14 = {
2+
type: 'object',
3+
required: ['context', 'message'],
4+
properties: {
5+
context: {
6+
type: 'object',
7+
required: [
8+
'location',
9+
'domain',
10+
'timestamp',
11+
'bap_id',
12+
'transaction_id',
13+
'message_id',
14+
'version',
15+
'action',
16+
'bap_uri',
17+
'ttl',
18+
'bpp_id',
19+
'bpp_uri',
20+
],
21+
properties: {
22+
location: {
23+
type: 'object',
24+
required: ['country', 'city'],
25+
properties: {
26+
country: {
27+
type: 'object',
28+
required: ['code'],
29+
properties: {
30+
code: { type: 'string', enum: ['IND'] },
31+
},
32+
},
33+
city: {
34+
type: 'object',
35+
required: ['code'],
36+
properties: {
37+
code: { type: 'string' },
38+
},
39+
},
40+
},
41+
},
42+
domain: { type: 'string', enum: ['ONDC:TRV14'] },
43+
timestamp: { type: 'string', format: 'date-time' },
44+
bap_id: { type: 'string' },
45+
transaction_id: { type: 'string' },
46+
message_id: { type: 'string' },
47+
version: { type: 'string', enum: ['2.0.0'] },
48+
action: { type: 'string', enum: ['confirm'] },
49+
bap_uri: { type: 'string', format: 'uri' },
50+
ttl: { type: 'string', pattern: '^PT\\d+S$' },
51+
bpp_id: { type: 'string' },
52+
bpp_uri: { type: 'string', format: 'uri' },
53+
},
54+
},
55+
message: {
56+
type: 'object',
57+
required: ['order'],
58+
properties: {
59+
order: {
60+
type: 'object',
61+
required: ['items', 'fulfillments', 'provider', 'billing', 'payments', 'tags'],
62+
properties: {
63+
items: {
64+
type: 'array',
65+
items: {
66+
type: 'object',
67+
required: ['id', 'parent_item_id', 'quantity'],
68+
properties: {
69+
id: { type: 'string' },
70+
parent_item_id: { type: 'string' },
71+
quantity: {
72+
type: 'object',
73+
properties: {
74+
selected: {
75+
type: 'object',
76+
properties: {
77+
count: { type: 'integer' },
78+
},
79+
},
80+
},
81+
},
82+
add_ons: {
83+
type: 'array',
84+
items: {
85+
type: 'object',
86+
properties: {
87+
id: { type: 'string' },
88+
quantity: {
89+
type: 'object',
90+
properties: {
91+
selected: {
92+
type: 'object',
93+
properties: {
94+
count: { type: 'integer' },
95+
},
96+
},
97+
},
98+
},
99+
},
100+
},
101+
},
102+
},
103+
},
104+
},
105+
fulfillments: {
106+
type: 'array',
107+
items: {
108+
type: 'object',
109+
properties: {
110+
id: { type: 'string' },
111+
stops: {
112+
type: 'array',
113+
items: {
114+
type: 'object',
115+
properties: {
116+
type: { type: 'string' },
117+
time: {
118+
type: 'object',
119+
properties: {
120+
timestamp: { type: 'string', format: 'date-time' },
121+
},
122+
},
123+
},
124+
},
125+
},
126+
},
127+
},
128+
},
129+
billing: {
130+
type: 'object',
131+
properties: {
132+
name: { type: 'string' },
133+
email: { type: 'string', format: 'email' },
134+
phone: { type: 'string' },
135+
},
136+
},
137+
provider: {
138+
type: 'object',
139+
properties: {
140+
id: { type: 'string' },
141+
},
142+
},
143+
payments: {
144+
type: 'array',
145+
items: {
146+
type: 'object',
147+
properties: {
148+
collected_by: { type: 'string' },
149+
status: { type: 'string' },
150+
type: { type: 'string' },
151+
params: {
152+
type: 'object',
153+
properties: {
154+
transaction_id: { type: 'string' },
155+
currency: { type: 'string' },
156+
amount: { type: 'string' },
157+
},
158+
},
159+
},
160+
},
161+
},
162+
tags: {
163+
type: 'array',
164+
items: { type: 'object' },
165+
},
166+
},
167+
},
168+
},
169+
},
170+
},
171+
}
172+
173+
export default confirmSchemaTRV14

0 commit comments

Comments
 (0)