This project implements a payment processing service for merchants using Java and the Spring framework. The service exposes a REST API that accepts HTTP requests and responds with JSON payloads.
To build and run this application, you need to have the following installed:
Follow these instructions to get the project up and running on your local machine.
1.Clone the repository from GitHub:
git clone ...
2.Navigate to the project directory
3.Build the project using Maven:
mvn clean install
4.Run Docker:
docker-compose up -d
5.Run Spring boot application:
mvn spring-boot:run
6.Run Tests:
mvn test
- Request: JSON payload with amount, customer name, credit card number,merchant Id, and expiry date
- Response: paymentId, status
- Payments will fail if the credit card number starts with 5.
- Request: Empty
- Response: paymentId, status
- Refund is only possible for payments from the same merchant.
- Refund is only possible for Successful payments.
- Refund is only possible for payments that have not already been refunded.
- Request: Empty
- Response: payment details based on paymentId, including refund records if applicable.
- View is only allowed for payments from the same merchant.
- Parameters: sort by date, filter by customer name
- Response: List of payments.
- Request: Empty
- Response: JSON payload with total payments count, total payments amount, total fees amount for the merchant.
- payload with total payments with successful status and refunds.
All payment endpoints are secured via JWT token authentication/authorization.
Set PAYMENT_MERCHANT as the default role for accessing all APIs.
- Request: Empty
- Response: JWT token
- generate JWT token with merchantId and PAYMENT_MERCHANT GrantedAuthority
Included in the application is a Flyway migration file that initializes the Merchant table. Two merchants with IDs 1000 and 1001 are created for testing purposes.
Location: [ db/migration: V1__initial_schema.sql ] Purpose: Create initial merchant entries (ID: 1000, 1001), Please be aware if you are going to test via Postman, you need to change the merchantId in the request body to 1000 or 1001.
- I incorporate a dedicated table to store information about merchants, ensuring a systematic record of every payment.
- Additionally, I treat refunds as negative payments, allowing them to be distinct yet seamlessly integrated into the payment system.
- Moreover, each successful payment has the potential for a corresponding refund, with a one-time limit for refund transactions.
- Statistics is only available for all successful and Refund payments.