https://github.com/andresweitzel/spring_batch_processing_payments
✅ This project implements a payment processor using Spring Batch that validates and processes payments from an input file, generating output files for processed and rejected payments, and an overall report.
https://github.com/andresweitzel/spring_batch_processing_payments
java payments report spring-batch spring-batch-jobs spring-boot
Last synced: 4 months ago
JSON representation
✅ This project implements a payment processor using Spring Batch that validates and processes payments from an input file, generating output files for processed and rejected payments, and an overall report.
- Host: GitHub
- URL: https://github.com/andresweitzel/spring_batch_processing_payments
- Owner: andresWeitzel
- License: gpl-3.0
- Created: 2025-05-21T03:24:03.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-08T03:21:23.000Z (12 months ago)
- Last Synced: 2026-01-17T04:49:43.532Z (5 months ago)
- Topics: java, payments, report, spring-batch, spring-batch-jobs, spring-boot
- Language: Java
- Homepage:
- Size: 13.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Batch Payments Processor 
This project implements a payment processor using Spring Batch that validates and processes payments from an input file, generating output files for processed payments, rejected payments, and a general report.
* [Functional tests video](https://www.youtube.com/watch?v=zPqArsLfH7o) 
## Index 📜
View details
`Latest update: 20/02/26`
### Section 1) Description, Configuration and Technologies
* [1.0) Project Description.](#10-project-description-)
* [1.1) Project Execution.](#11-project-execution-)
* [1.2) Project Structure.](#12-project-structure-)
* [1.3) Technologies.](#13-technologies-)
### Section 2) Processing Flow, File Formats and Validations
* [2.0) Processing Flow.](#20-processing-flow-)
* [2.1) File Formats.](#21-file-formats-)
* [2.2) Implemented Validations.](#22-implemented-validations-)
### Section 3) Payment Examples
* [3.0) Valid Payments.](#30-valid-payments-)
* [3.1) Rejected Payments.](#31-rejected-payments-)
### Section 4) Reports, Functionality Testing and References
* [4.0) Reports.](#40-reports-)
* [4.1) Functionality Test.](#41-functionality-test-)
* [4.2) Contributing.](#42-contributing-)
* [4.3) License.](#43-license-)
## Section 1) Description, Configuration and Technologies
### 1.0) Project Description [🔝](#index-)
View details
This project implements a payment processor using Spring Batch that validates and processes payments from an input file, generating output files for processed payments, rejected payments, and a general report.
**Features:**
- Batch payment processing
- Amount, currency, and customer data validation
- Commission calculation
- Report generation
- Error handling and rejected payments
- Support for multiple currencies (USD, EUR, GBP, JPY)
### 1.1) Project Execution [🔝](#index-)
View details
* We create a work environment through some IDE, we may or may not create a root folder for the project, we position ourselves on it
```git
cd 'projectRootName'
```
* Once a work environment has been created, we clone the project
```git
git clone https://github.com/andresWeitzel/Spring_Batch_Processing_Payments
```
* We position ourselves on the project
```git
cd 'Spring_Batch_Processing_Payments'
```
* We need [Java 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) or higher installed
* We need [Maven 3.6](https://maven.apache.org/download.cgi) or higher installed
* We install all the necessary dependencies
```git
mvn clean install
```
* The project uses different profiles for development and production. To run in development mode:
```git
mvn spring-boot:run -Dspring-boot.run.profiles=dev
```
* To run in production mode:
```git
mvn spring-boot:run -Dspring-boot.run.profiles=prod
```
* `Important`: It is possible that there are other previous steps that have not been included due to synchronization between docs in relation to development. Please open a conversation thread within the 'Issues' section of the project.
### 1.2) Project Structure [🔝](#index-)
View details
```
src/main/java/com/example/batch/
├── config/ # Spring Batch configuration
├── model/ # Data models
├── processor/ # Payment processors
└── enums/ # Enumerations
```
### 1.3) Technologies [🔝](#index-)
View details
| **Technologies** | **Version** | **Purpose** |
| ------------- | ------------- | ------------- |
| [Java](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) | 17+ | Programming Language |
| [Spring Boot](https://spring.io/projects/spring-boot) | 2.7.0 | Application Framework |
| [Spring Batch](https://spring.io/projects/spring-batch) | 4.3.6 | Batch Processing Framework |
| [Maven](https://maven.apache.org/) | 3.6+ | Dependency Management and Build |
| [JUnit](https://junit.org/junit5/) | 5 | Unit Testing Framework |
| [Postman](https://www.postman.com/downloads/) | 10+ | Http Client for Testing |
| [Swagger](https://swagger.io/) | 2.0 | API Documentation |
| [Git](https://git-scm.com/downloads) | 2.29+ | Version Control |
| Others | - | Others |
## Section 2) Processing Flow, File Formats and Validations
### 2.0) Processing Flow [🔝](#index-)
View details
1. **Payment Reading**: Reads payments from `input/payments.txt`
2. **Validation and Processing**:
- Validates amounts (minimum: 10.00, maximum: 10000.00)
- Validates supported currencies
- Validates email format
- Calculates commissions
3. **Result Writing**:
- Valid payments → `output/processed_payments.txt`
- Rejected payments → `output/rejected_payments.txt`
- General report → `output/payment_report.txt`
### 2.1) File Formats [🔝](#index-)
View details
### 2.1.0) Input File (payments.txt)
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
1,100.00,USD,PENDING,2024-03-20T10:00:00,CREDIT_CARD,John Doe,john@example.com
2,500.00,EUR,PENDING,2024-03-20T10:05:00,DEBIT_CARD,Jane Smith,jane@example.com
3,1000.00,GBP,PENDING,2024-03-20T10:10:00,CREDIT_CARD,Bob Johnson,bob@example.com
4,5000.00,JPY,PENDING,2024-03-20T10:15:00,DEBIT_CARD,Alice Brown,alice@example.com
```
### 2.1.1) Processed Payments File (processed_payments.txt)
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail,amountInUSD,commission,validationStatus
1,100.00,USD,PROCESSED,2024-03-20T10:00:00,CREDIT_CARD,John Doe,john@example.com,100.00,2.00,VALID
2,500.00,EUR,PROCESSED,2024-03-20T10:05:00,DEBIT_CARD,Jane Smith,jane@example.com,545.00,10.90,VALID
3,1000.00,GBP,PROCESSED,2024-03-20T10:10:00,CREDIT_CARD,Bob Johnson,bob@example.com,1270.00,25.40,VALID
4,5000.00,JPY,PROCESSED,2024-03-20T10:15:00,DEBIT_CARD,Alice Brown,alice@example.com,33.50,0.67,VALID
```
### 2.1.2) Rejected Payments File (rejected_payments.txt)
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail,errorMessage
5,5.00,USD,INVALID,2024-03-20T10:20:00,CREDIT_CARD,Charlie Wilson,charlie@example.com,Amount is below minimum allowed: 10.0
6,15000.00,EUR,INVALID,2024-03-20T10:25:00,DEBIT_CARD,Diana Miller,diana@example.com,Amount exceeds maximum allowed: 10000.0
7,200.00,MXN,INVALID,2024-03-20T10:30:00,CREDIT_CARD,Edward Davis,edward@example.com,Unsupported currency: MXN
8,300.00,GBP,INVALID,2024-03-20T10:35:00,INVALID_TYPE,Frank Lee,frank@example.com,Invalid payment type: INVALID_TYPE
9,400.00,USD,INVALID,2024-03-20T10:40:00,CREDIT_CARD,Grace Kim,invalid-email,Invalid email format
10,500.00,EUR,INVALID,2024-03-20T10:45:00,DEBIT_CARD,Henry Park,,Email cannot be empty
11,600.00,GBP,INVALID,2024-03-20T10:50:00,CREDIT_CARD,Ivy Chen,ivy@example.com,Invalid or empty payment date
```
### 2.1.3) General Report File (payment_report.txt)
```
=== Payment Processing Report ===
Processing Date: 2024-03-20T11:00:00
Total Processed Payments: 4
Total Rejected Payments: 7
Total Payments: 11
=== Currency Statistics ===
USD: 2 payments (1 processed, 1 rejected)
EUR: 3 payments (1 processed, 2 rejected)
GBP: 3 payments (1 processed, 2 rejected)
JPY: 1 payment (1 processed, 0 rejected)
MXN: 1 payment (0 processed, 1 rejected)
=== Payment Type Statistics ===
CREDIT_CARD: 6 payments
DEBIT_CARD: 4 payments
INVALID_TYPE: 1 payment
=== Rejection Reasons ===
Amount too low: 1
Amount too high: 1
Unsupported currency: 1
Invalid payment type: 1
Invalid email: 2
Invalid date: 1
=== Total Amounts ===
Total Processed (USD): 1948.40
Total Commissions (USD): 38.97
```
### 2.2) Implemented Validations [🔝](#index-)
View details
1. **Amount**:
- Minimum: 10.00
- Maximum: 10000.00
2. **Supported Currencies**:
- USD (US Dollar)
- EUR (Euro)
- GBP (British Pound)
- JPY (Japanese Yen)
3. **Email**:
- Valid format
- Cannot be empty
4. **Payment Date**:
- Cannot be empty
- ISO 8601 format
## Section 3) Payment Examples
### 3.0) Valid Payments [🔝](#index-)
View details
### 3.0.0) USD payments within allowed range
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
1,100.00,USD,PENDING,2024-03-20T10:00:00,CREDIT_CARD,John Doe,john@example.com
2,500.00,USD,PENDING,2024-03-20T10:05:00,DEBIT_CARD,Jane Smith,jane@example.com
3,1000.00,USD,PENDING,2024-03-20T10:10:00,CREDIT_CARD,Bob Johnson,bob@example.com
```
### 3.0.1) EUR payments with valid email
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
4,500.00,EUR,PENDING,2024-03-20T11:00:00,DEBIT_CARD,Jane Smith,jane.smith@example.com
5,750.00,EUR,PENDING,2024-03-20T11:05:00,CREDIT_CARD,Alice Brown,alice.brown@example.com
6,2500.00,EUR,PENDING,2024-03-20T11:10:00,DEBIT_CARD,Charlie Wilson,charlie.wilson@example.com
```
### 3.0.2) GBP payments with varied amounts
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
7,50.00,GBP,PENDING,2024-03-20T12:00:00,CREDIT_CARD,David Miller,david.miller@example.com
8,200.00,GBP,PENDING,2024-03-20T12:05:00,DEBIT_CARD,Eva Garcia,eva.garcia@example.com
9,5000.00,GBP,PENDING,2024-03-20T12:10:00,CREDIT_CARD,Frank Lee,frank.lee@example.com
```
### 3.0.3) JPY payments with different payment types
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
10,10000.00,JPY,PENDING,2024-03-20T13:00:00,CREDIT_CARD,Grace Kim,grace.kim@example.com
11,50000.00,JPY,PENDING,2024-03-20T13:05:00,DEBIT_CARD,Henry Park,henry.park@example.com
12,100000.00,JPY,PENDING,2024-03-20T13:10:00,CREDIT_CARD,Ivy Chen,ivy.chen@example.com
```
### 3.1) Rejected Payments [🔝](#index-)
View details
### 3.1.0) Very low amounts
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
13,5.00,USD,PENDING,2024-03-20T14:00:00,CREDIT_CARD,Jack Wilson,jack@example.com
14,1.00,EUR,PENDING,2024-03-20T14:05:00,DEBIT_CARD,Kate Brown,kate@example.com
15,0.50,GBP,PENDING,2024-03-20T14:10:00,CREDIT_CARD,Liam Davis,liam@example.com
```
### 3.1.1) Unsupported currencies
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
16,1000.00,MXN,PENDING,2024-03-20T15:00:00,DEBIT_CARD,Maria Garcia,maria@example.com
17,500.00,CAD,PENDING,2024-03-20T15:05:00,CREDIT_CARD,Noah Smith,noah@example.com
18,2000.00,AUD,PENDING,2024-03-20T15:10:00,DEBIT_CARD,Olivia Lee,olivia@example.com
```
### 3.1.2) Invalid emails
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
19,200.00,USD,PENDING,2024-03-20T16:00:00,CREDIT_CARD,Peter Davis,invalid-email
20,300.00,EUR,PENDING,2024-03-20T16:05:00,DEBIT_CARD,Quinn Wilson,not-an-email
21,400.00,GBP,PENDING,2024-03-20T16:10:00,CREDIT_CARD,Rachel Brown,missing@domain
```
### 3.1.3) Very high amounts
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
22,15000.00,USD,PENDING,2024-03-20T17:00:00,DEBIT_CARD,Sam Miller,sam@example.com
23,20000.00,EUR,PENDING,2024-03-20T17:05:00,CREDIT_CARD,Tina Garcia,tina@example.com
24,25000.00,GBP,PENDING,2024-03-20T17:10:00,DEBIT_CARD,Victor Lee,victor@example.com
```
### 3.1.4) Invalid or empty dates
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
25,100.00,USD,PENDING,,CREDIT_CARD,Will Smith,will@example.com
26,200.00,EUR,PENDING,invalid-date,DEBIT_CARD,Xena Brown,xena@example.com
27,300.00,GBP,PENDING,2024-13-45T25:61:99,CREDIT_CARD,Yara Davis,yara@example.com
```
### 3.1.5) Invalid payment types
```
id,amount,currency,status,paymentDate,paymentType,customerName,customerEmail
28,100.00,USD,PENDING,2024-03-20T18:00:00,INVALID_TYPE,Zack Wilson,zack@example.com
29,200.00,EUR,PENDING,2024-03-20T18:05:00,UNKNOWN,Anna Brown,anna@example.com
30,300.00,GBP,PENDING,2024-03-20T18:10:00,,Bob Davis,bob@example.com
```
## Section 4) Reports, Functionality Testing and References
### 4.0) Reports [🔝](#index-)
View details
The system generates three types of output files:
1. **processed_payments.txt**: Contains all valid processed payments with calculated commissions and USD conversion amounts.
2. **rejected_payments.txt**: Contains payments that failed validation along with the corresponding error message.
3. **payment_report.txt**: General report with processing statistics including currency statistics, payment type statistics, rejection reasons, and total amounts.
### 4.1) Functionality Test [🔝](#index-)
View details
#### [Watch video](https://www.youtube.com/watch?v=zPqArsLfH7o)
### 4.2) Contributing [🔝](#index-)
View details
1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
### 4.3) License [🔝](#index-)
View details
This project is under the MIT License - see the [LICENSE](LICENSE) file for details.