Skip to content

Commit d11e7fd

Browse files
test(postman): update postman collection files
1 parent 25245b9 commit d11e7fd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

postman/collection-json/paypal.postman_collection.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@
44
"listen": "prerequest",
55
"script": {
66
"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+
"}"
834
],
935
"type": "text/javascript"
1036
}

0 commit comments

Comments
 (0)