@@ -22,10 +22,9 @@ class OndcService {
22
22
23
23
const order = payload ;
24
24
const selectMessageId = payload . context . message_id ;
25
-
26
25
this . postSearchRequest ( order , selectMessageId )
27
26
28
- return { }
27
+ return { "message" : { "ack" : { "status" : "ACK" } } }
29
28
} catch ( err ) {
30
29
logger . error ( 'error' , `[Ondc Service] search logistics payload - search logistics payload : param :` , err ) ;
31
30
throw err ;
@@ -55,46 +54,14 @@ class OndcService {
55
54
let totalPrice = 0
56
55
let itemData = { } ;
57
56
for ( let item of payload . message . order . items ) {
58
- let tags = item . tags ;
59
- if ( tags && tags . length > 0 ) {
60
- let tagData = tags . find ( ( tag ) => {
61
- return tag . code === 'type'
62
- } )
63
- let tagTypeData = tagData . list . find ( ( tagType ) => {
64
- return tagType . code === 'type'
65
- } )
66
- itemType = tagTypeData . value ;
67
- if ( itemType === 'customization' ) {
68
- resultData = itemData ?. customizationDetails ?. customizations . find ( ( row ) => {
69
- return row . _id === item . id
70
- } )
71
- if ( resultData ) {
72
-
73
- if ( resultData ) {
74
- let price = resultData ?. price * item . quantity . count
75
- totalPrice += price
76
- }
77
- }
78
- } else {
79
- resultData = await productService . getForOndc ( item . id )
80
- if ( Object . keys ( resultData ) . length > 0 ) {
81
-
82
- if ( resultData ?. commonDetails ) {
83
- let price = resultData ?. commonDetails ?. MRP * item . quantity . count
84
- totalPrice += price
85
- }
86
-
87
- }
88
- }
89
-
90
- } else {
91
- resultData = await productService . getForOndc ( item . id )
92
- if ( Object . keys ( resultData ) . length > 0 ) {
93
-
94
- if ( resultData ?. commonDetails ) {
95
- let price = resultData ?. commonDetails ?. MRP * item . quantity . count
96
- totalPrice += price
97
- }
57
+ resultData = await productService . getForOndc ( item . id )
58
+ if ( Object . keys ( resultData ) . length > 0 ) {
59
+ if ( resultData ?. commonDetails ) {
60
+ let price = resultData ?. commonDetails ?. MRP * item . quantity . count
61
+ totalProductValue += price
62
+ } else {
63
+ let price = resultData ?. MRP * item . quantity . count
64
+ totalProductValue += price
98
65
}
99
66
}
100
67
}
@@ -274,7 +241,7 @@ class OndcService {
274
241
//process select request and send it to protocol layer
275
242
this . postSelectRequest ( searchRequest , logisticsMessageId , selectMessageId )
276
243
277
- return searchRequest
244
+ return { "message" : { "ack" : { "status" : "ACK" } } }
278
245
} catch ( err ) {
279
246
logger . error ( 'error' , `[Ondc Service] search logistics payload - search logistics payload : param :` , err ) ;
280
247
throw err ;
@@ -829,7 +796,7 @@ class OndcService {
829
796
830
797
this . postInitRequest ( initRequest , logisticsMessageId , initMessageId )
831
798
832
- return { ' status' : ' ACK' }
799
+ return { "message" : { "ack" : { " status" : " ACK" } } }
833
800
} catch ( err ) {
834
801
logger . error ( 'error' , `[Ondc Service] build init request :` , { error : err . stack , message : err . message } ) ;
835
802
console . log ( err )
@@ -1087,7 +1054,8 @@ class OndcService {
1087
1054
"message_id" : logisticsMessageId ,
1088
1055
"city" : logistics . context . city ,
1089
1056
"country" : "IND" ,
1090
- "timestamp" : contextTimestamp
1057
+ "timestamp" : contextTimestamp ,
1058
+ "ttl" : "PT30S"
1091
1059
} ,
1092
1060
"message" : {
1093
1061
"order" : {
@@ -1227,7 +1195,7 @@ class OndcService {
1227
1195
this . postConfirmRequest ( confirmRequest , logisticsMessageId , selectMessageId )
1228
1196
//}, 10000); //TODO move to config
1229
1197
1230
- return { status : "ACK" }
1198
+ return { "message" : { "ack" : { " status" : "ACK" } } }
1231
1199
} catch ( err ) {
1232
1200
throw err ;
1233
1201
}
@@ -1416,7 +1384,8 @@ class OndcService {
1416
1384
"message_id" : logisticsMessageId ,
1417
1385
"city" : "std:080" ,
1418
1386
"country" : "IND" ,
1419
- "timestamp" : new Date ( )
1387
+ "timestamp" : new Date ( ) ,
1388
+ "ttl" : "PT30S"
1420
1389
} ,
1421
1390
"message" :
1422
1391
{
@@ -1431,7 +1400,7 @@ class OndcService {
1431
1400
this . postTrackRequest ( trackRequest , logisticsMessageId , selectMessageId )
1432
1401
// }, 5000); //TODO move to config
1433
1402
1434
- return { status : ' ACK' }
1403
+ return { "message" : { "ack" : { " status" : " ACK" } } }
1435
1404
} catch ( err ) {
1436
1405
throw err ;
1437
1406
}
@@ -1549,7 +1518,8 @@ class OndcService {
1549
1518
"message_id" : logisticsMessageId ,
1550
1519
"city" : "std:080" ,
1551
1520
"country" : "IND" ,
1552
- "timestamp" : new Date ( )
1521
+ "timestamp" : new Date ( ) ,
1522
+ "ttl" : "PT30S"
1553
1523
} ,
1554
1524
"message" :
1555
1525
{
@@ -1564,7 +1534,7 @@ class OndcService {
1564
1534
this . postStatusRequest ( statusRequest , logisticsMessageId , selectMessageId , unsoliciated , payload )
1565
1535
//}, 5000); //TODO move to config
1566
1536
1567
- return { status : ' ACK' }
1537
+ return { "message" : { "ack" : { " status" : " ACK" } } }
1568
1538
} catch ( err ) {
1569
1539
throw err ;
1570
1540
}
@@ -1622,7 +1592,8 @@ class OndcService {
1622
1592
"message_id" : logisticsMessageId ,
1623
1593
"city" : "std:080" , //TODO: take it from request
1624
1594
"country" : "IND" ,
1625
- "timestamp" : new Date ( )
1595
+ "timestamp" : new Date ( ) ,
1596
+ "ttl" : "PT30S"
1626
1597
} ,
1627
1598
"message" : {
1628
1599
"order" : {
@@ -1716,16 +1687,17 @@ class OndcService {
1716
1687
"context" : {
1717
1688
"domain" : "nic2004:60232" ,
1718
1689
"action" : "cancel" ,
1719
- "core_version" : "1.1 .0" ,
1690
+ "core_version" : "1.2 .0" ,
1720
1691
"bap_id" : config . get ( "sellerConfig" ) . BPP_ID ,
1721
- "bap_uri" : config . get ( "sellerConfig" ) . BPP_URI ,
1692
+ "bap_uri" : config . get ( "sellerConfig" ) . BAP_URI ,
1722
1693
"bpp_id" : logistics . context . bpp_id , //STORED OBJECT
1723
1694
"bpp_uri" : logistics . context . bpp_uri , //STORED OBJECT
1724
1695
"transaction_id" : confirmRequest . logisticsTransactionId ,
1725
1696
"message_id" : logisticsMessageId ,
1726
1697
"city" : "std:080" , //TODO: take it from request
1727
1698
"country" : "IND" ,
1728
- "timestamp" : new Date ( )
1699
+ "timestamp" : new Date ( ) ,
1700
+ "ttl" : "PT30S"
1729
1701
} ,
1730
1702
"message" : {
1731
1703
"order_id" : order . orderId ,
@@ -1778,7 +1750,8 @@ class OndcService {
1778
1750
"message_id" : logisticsMessageId ,
1779
1751
"city" : "std:080" , //TODO: take it from request
1780
1752
"country" : "IND" ,
1781
- "timestamp" : new Date ( )
1753
+ "timestamp" : new Date ( ) ,
1754
+ "ttl" : "PT30S"
1782
1755
} ,
1783
1756
"message" : {
1784
1757
"order" : {
@@ -1842,7 +1815,7 @@ class OndcService {
1842
1815
//process select request and send it to protocol layer
1843
1816
this . postUpdateRequestV2 ( searchRequest , null , updateMessageId )
1844
1817
1845
- return { status : ' ACK' }
1818
+ return { "message" : { "ack" : { " status" : " ACK" } } }
1846
1819
} catch ( err ) {
1847
1820
throw err ;
1848
1821
}
@@ -2238,7 +2211,8 @@ class OndcService {
2238
2211
"message_id" : logisticsMessageId ,
2239
2212
"city" : "std:080" ,
2240
2213
"country" : "IND" ,
2241
- "timestamp" : new Date ( )
2214
+ "timestamp" : new Date ( ) ,
2215
+ "ttl" : "PT30S"
2242
2216
} ,
2243
2217
"message" :
2244
2218
{
@@ -2254,7 +2228,7 @@ class OndcService {
2254
2228
this . postCancelRequest ( trackRequest , logisticsMessageId , selectMessageId )
2255
2229
//}, 5000); //TODO move to config
2256
2230
2257
- return { status : ' ACK' }
2231
+ return { "message" : { "ack" : { " status" : " ACK" } } }
2258
2232
} catch ( err ) {
2259
2233
throw err ;
2260
2234
}
@@ -2636,7 +2610,8 @@ class OndcService {
2636
2610
"message_id" : logisticsMessageId ,
2637
2611
"city" : "std:080" ,
2638
2612
"country" : "IND" ,
2639
- "timestamp" : new Date ( )
2613
+ "timestamp" : new Date ( ) ,
2614
+ "ttl" : "PT30S"
2640
2615
} ,
2641
2616
"message" :
2642
2617
{
0 commit comments