gateway.http91 lines, 2.2 KB
| 1 | # The payments API through the gateway. Send the requests in order. |
| 2 | @baseUrl = http://localhost:8080 |
| 3 | @password = correct horse battery staple |
| 4 | @token = {{login.response.body.access_token}} |
| 5 | @walletId = {{wallet.response.body.id}} |
| 6 | |
| 7 | ### Register |
| 8 | POST {{baseUrl}}/v1/auth/register |
| 9 | Content-Type: application/json |
| 10 | |
| 11 | {"email": "alice@example.com", "password": "{{password}}"} |
| 12 | |
| 13 | ### Log in |
| 14 | # @name login |
| 15 | POST {{baseUrl}}/v1/auth/login |
| 16 | Content-Type: application/json |
| 17 | |
| 18 | {"email": "alice@example.com", "password": "{{password}}"} |
| 19 | |
| 20 | ### Open a wallet |
| 21 | # @name wallet |
| 22 | POST {{baseUrl}}/v1/wallets |
| 23 | Authorization: Bearer {{token}} |
| 24 | Content-Type: application/json |
| 25 | |
| 26 | {"currency": "USD"} |
| 27 | |
| 28 | ### Deposit fifty dollars |
| 29 | POST {{baseUrl}}/v1/wallets/{{walletId}}/deposits |
| 30 | Authorization: Bearer {{token}} |
| 31 | Idempotency-Key: {{$guid}} |
| 32 | Content-Type: application/json |
| 33 | |
| 34 | {"amount": 5000, "currency": "USD"} |
| 35 | |
| 36 | ### Bob, so Alice has someone to pay |
| 37 | POST {{baseUrl}}/v1/auth/register |
| 38 | Content-Type: application/json |
| 39 | |
| 40 | {"email": "bob@example.com", "password": "{{password}}"} |
| 41 | |
| 42 | ### |
| 43 | # @name bob |
| 44 | POST {{baseUrl}}/v1/auth/login |
| 45 | Content-Type: application/json |
| 46 | |
| 47 | {"email": "bob@example.com", "password": "{{password}}"} |
| 48 | |
| 49 | ### |
| 50 | # @name bobsWallet |
| 51 | POST {{baseUrl}}/v1/wallets |
| 52 | Authorization: Bearer {{bob.response.body.access_token}} |
| 53 | Content-Type: application/json |
| 54 | |
| 55 | {"currency": "USD"} |
| 56 | |
| 57 | ### Pay Bob fifteen dollars |
| 58 | POST {{baseUrl}}/v1/transfers |
| 59 | Authorization: Bearer {{token}} |
| 60 | Idempotency-Key: {{$guid}} |
| 61 | X-Request-ID: alice-pays-bob |
| 62 | Content-Type: application/json |
| 63 | |
| 64 | { |
| 65 | "from": "{{walletId}}", |
| 66 | "to": "{{bobsWallet.response.body.id}}", |
| 67 | "amount": 1500, |
| 68 | "currency": "USD" |
| 69 | } |
| 70 | |
| 71 | ### Balance |
| 72 | GET {{baseUrl}}/v1/wallets/{{walletId}}/balance |
| 73 | Authorization: Bearer {{token}} |
| 74 | |
| 75 | ### Without a token |
| 76 | GET {{baseUrl}}/v1/wallets/{{walletId}}/balance |
| 77 | |
| 78 | ### Bob's wallet, with Alice's token |
| 79 | GET {{baseUrl}}/v1/wallets/{{bobsWallet.response.body.id}}/balance |
| 80 | Authorization: Bearer {{token}} |
| 81 | |
| 82 | ### CORS preflight, from a browser app |
| 83 | OPTIONS {{baseUrl}}/v1/transfers |
| 84 | Origin: http://localhost:5173 |
| 85 | Access-Control-Request-Method: POST |
| 86 | Access-Control-Request-Headers: authorization, content-type, idempotency-key |
| 87 | |
| 88 | ### The same, from an origin we don't know |
| 89 | OPTIONS {{baseUrl}}/v1/transfers |
| 90 | Origin: https://evil.example |
| 91 | Access-Control-Request-Method: POST |