-
Notifications
You must be signed in to change notification settings - Fork 0
/
Payments.postman_collection.json
338 lines (338 loc) · 11.2 KB
/
Payments.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
{
"info": {
"_postman_id": "1c7fdc6a-19a0-40b8-b7b6-f9047dcbebb8",
"name": "Payments",
"description": "# 👤 Get started here\n\nThis template demonstrates how to structure endpoints for a user management REST API that contains endpoints for user registration, login, profile management, and more.\n\nUsers created using this API can perform tasks like registering, logging in, and updating their profiles. Users who are assigned an 'admin' role can perform all tasks, including getting a list of all users and deleting user profiles.\n\n### 🔐 Authentication and authorization\n\nYou must have a valid bearer token to use the API added in this template. When you send the `Register` request, you will receive a token in the response. The `Register` request also contains a test script that sets the token in the `accessToken` collection variable so you can reuse it in other requests easily.\n\nTo send the requests in the `Admin` folder, you need to have admin permissions. You can grant yourself admin permissions using the `Register` request by adding a key named \"role\" with \"admin\" as the value in the request body.\n\n## 🔖 How to use this template?\n\n#### **Step 1: Send the requests**\n\nCheck out the different parts of the requests, including the request body, documentation, headers, tests, and path parameters. Send the requests to view the response returned by the API.\n\nYou can explore the API in the order given below to understand the workflow without running into any hiccups:\n\n`Register → Log in → Get profile → Update profile → Change user role → Get all users → Delete user`\n\n#### **Step 2: Customize the requests**\n\nAdd your API’s base URL in the `url` collection variable. Update the request body wherever needed and send the requests to test your API.\n\n#### **Step 3: Continue building the collection**\n\nCreate requests in this collection to test the new API endpoints you develop.\n\n## 💡Related templates\n\n[Authorization methods](https://go.postman.co/redirect/workspace?type=personal&collectionTemplateId=31a9a6ed-4cdf-4ced-984c-d12c9aec1c27&sourceTemplateId=18238f01-dfc7-4a9a-9330-1f8e7c928daf) \n[Payment gateway and processing API](https://go.postman.co/redirect/workspace?type=personal&collectionTemplateId=2ef318a1-e16c-4761-b8dc-1ccb1167ee8d&sourceTemplateId=18238f01-dfc7-4a9a-9330-1f8e7c928daf) \n[File storage API](https://go.postman.co/redirect/workspace?type=personal&collectionTemplateId=45d1f394-35cd-44fa-aecc-fa329a7752a3&sourceTemplateId=18238f01-dfc7-4a9a-9330-1f8e7c928daf) \n[Push notification API](https://go.postman.co/redirect/workspace?type=personal&collectionTemplateId=de8244f9-136a-4a6a-a695-d4516fd20308&sourceTemplateId=18238f01-dfc7-4a9a-9330-1f8e7c928daf) \n[Search API](https://go.postman.co/redirect/workspace?type=personal&collectionTemplateId=da8172d0-679b-4173-9104-0ecef2c32cd3&sourceTemplateId=18238f01-dfc7-4a9a-9330-1f8e7c928daf)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "15728449"
},
"item": [
{
"name": "Authentication",
"item": [
{
"name": "RegisterUser1",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var responseData = pm.response.json();",
"pm.environment.set(\"userId1\", responseData._id);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "\n{\n \"username\": \"{{$randomUserName}}\",\n \"password\": \"{{$randomPassword}}\",\n \"email\": \"{{$randomEmail}}\",\n \"imgUrl\": \"{{$randomImageUrl}}\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/api/user/register",
"host": [
"{{url}}"
],
"path": [
"api",
"user",
"register"
]
},
"description": "This request creates a new user.\n\n**Note:** If you want to add yourself as an admin, you can add a key named \"role\" and set the value \"admin\" as a part of the request body.\n\nThis request also has a test script that sets the authorization token received in the response in the `accessToken` collection variable. This helps you reuse the token in other requests easily."
},
"response": []
},
{
"name": "RegisterUser2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var responseData = pm.response.json();",
"pm.environment.set(\"userId2\", responseData._id);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "\n{\n \"username\": \"{{$randomUserName}}\",\n \"password\": \"{{$randomPassword}}\",\n \"email\": \"{{$randomEmail}}\",\n \"imgUrl\": \"{{$randomImageUrl}}\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/api/user/register",
"host": [
"{{url}}"
],
"path": [
"api",
"user",
"register"
]
},
"description": "This request creates a new user.\n\n**Note:** If you want to add yourself as an admin, you can add a key named \"role\" and set the value \"admin\" as a part of the request body.\n\nThis request also has a test script that sets the authorization token received in the response in the `accessToken` collection variable. This helps you reuse the token in other requests easily."
},
"response": []
}
],
"description": "This folder contains requests related to creating a user profile and logging in.",
"auth": {
"type": "noauth"
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "Accounts",
"item": [
{
"name": "addAccountForUser1",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var responseData = pm.response.json();",
"pm.environment.set(\"account1\", responseData.account.accountId);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"userId\" : \"{{userId1}}\",\n \"accountDetails\" : {\n \"accountNumber\": \"{{$randomBankAccount}}\", // Encrypted\n \"accountType\": \"{{$randomBankAccountName}}\",\n \"balance\": {{$randomInt}},\n \"limitations\": {\n \"withdrawalLimit\": {{$randomInt}},\n \"transferLimit\": {{$randomInt}},\n \"otherLimitations\": \"No Limit\"\n\n },\n \"securityTags\": [],\n \"details\": {\n \"IBAN\" : \"{{$randomBankAccountIban}}\"\n }// Encrypted string of sensitive data\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/api/account",
"host": [
"{{url}}"
],
"path": [
"api",
"account"
]
}
},
"response": []
},
{
"name": "addAccountForUser2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var responseData = pm.response.json();",
"pm.environment.set(\"account2\", responseData.account.accountId);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"userId\" : \"{{userId2}}\",\n \"accountDetails\" : {\n \"accountNumber\": \"{{$randomBankAccount}}\", // Encrypted\n \"accountType\": \"{{$randomBankAccountName}}\",\n \"balance\": {{$randomInt}},\n \"limitations\": {\n \"withdrawalLimit\": {{$randomInt}},\n \"transferLimit\": {{$randomInt}},\n \"otherLimitations\": \"No Limit\"\n\n },\n \"securityTags\": [],\n \"details\": {\n \"IBAN\" : \"{{$randomBankAccountIban}}\"\n }// Encrypted string of sensitive data\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/api/account",
"host": [
"{{url}}"
],
"path": [
"api",
"account"
]
}
},
"response": []
}
]
},
{
"name": "Transaction",
"item": [
{
"name": "addTransactionUser1ToUser2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var responseData = pm.response.json();",
"pm.environment.set(\"txId\", responseData.txId);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"accountId\": \"{{account1}}\", // Reference to the Account Document of the transaction \n \"amount\": {{$randomInt}},\n \"type\": \"credit\", // e.g., 'debit', 'credit'\n \"details\": {\n\n },\n \"referenceData\": {\n \"receiver\": {\n \"userId\" : \"{{userId2}}\",\n \"accountId\" : \"{{account2}}\"\n }\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/api/transaction/{{userId1}}",
"host": [
"{{url}}"
],
"path": [
"api",
"transaction",
"{{userId1}}"
]
}
},
"response": []
},
{
"name": "getTransaction",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{url}}/api/transaction/{{txId}}",
"host": [
"{{url}}"
],
"path": [
"api",
"transaction",
"{{txId}}"
]
}
},
"response": []
},
{
"name": "getAllTrx",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{url}}/api/transaction?accountId={{account1}}",
"host": [
"{{url}}"
],
"path": [
"api",
"transaction"
],
"query": [
{
"key": "accountId",
"value": "{{account1}}"
}
]
}
},
"response": []
}
]
}
],
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "url",
"value": "http://localhost:3030",
"type": "string"
},
{
"key": "accessToken",
"value": "",
"type": "string"
}
]
}