File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 4
4
"listen" : " prerequest" ,
5
5
"script" : {
6
6
"exec" : [
7
- " "
7
+ " const path = pm.request.url.toString();" ,
8
+ " const isPostRequest = pm.request.method.toString() === \" POST\" ;" ,
9
+ " const isPaymentCreation = path.match(/\\ /payments$/) && isPostRequest;" ,
10
+ " " ,
11
+ " if (isPaymentCreation) {" ,
12
+ " try {" ,
13
+ " const request = JSON.parse(pm.request.body.toJSON().raw);" ,
14
+ " " ,
15
+ " // Attach routing" ,
16
+ " const routing = { type: \" single\" , data: \" paypal\" };" ,
17
+ " request[\" routing\" ] = routing;" ,
18
+ " " ,
19
+ " let updatedRequest = {" ,
20
+ " mode: \" raw\" ," ,
21
+ " raw: JSON.stringify(request)," ,
22
+ " options: {" ,
23
+ " raw: {" ,
24
+ " language: \" json\" ," ,
25
+ " }," ,
26
+ " }," ,
27
+ " };" ,
28
+ " pm.request.body.update(updatedRequest);" ,
29
+ " } catch (error) {" ,
30
+ " console.error(\" Failed to inject routing in the request\" );" ,
31
+ " console.error(error);" ,
32
+ " }" ,
33
+ " }"
8
34
],
9
35
"type" : " text/javascript"
10
36
}
You can’t perform that action at this time.
0 commit comments