An event-driven payment API built to learn the basic features of Spring Web, Spring Security and Kafka.
- Method:
GET
- Description: Health check endpoint.
- Response: Returns a 200 OK status if the service is running, along with a simple "Healthy" message. If a valid JWT token is provided, it will also return the username associated with the token.
- Example:
curl -X GET http://localhost:8080/health
Healthy
- Method:
POST
- Description: Login endpoint to authenticate users and generate JWT tokens.
- Request Body: JSON object containing
username
andpassword
. - Response: Returns a JWT token if the credentials are valid. The token is signed with a secret key and contains user information.
- Example:
curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{
"username": "user",
"password": "password"
}'
<some_jwt_token>
- Method:
POST
- Description: Endpoint to process a payment.
- Request Body: JSON object containing payment details such as
amount
,currency
, andrecipient
. - Response: Returns a confirmation message if the payment is processed successfully.
- Example:
curl -X POST http://localhost:8080/pay \
-H "Content-Type: application/json"
-d '{
"amount": 100,
"currency": "USD",
"recipient": "Tom"
}'
Payment processed successfully: txn_<some_transaction_id>