A simple and modular Spring Framework-based payment processing application that demonstrates Dependency Injection (DI), loose coupling, and annotation-based configuration.
-
✅ Built using Spring Core (Annotations)
-
✅ Demonstrates Dependency Injection (DI)
-
✅ Supports multiple payment services:
- Google Pay
- Paytm
-
✅ Clean architecture using interfaces
-
✅ Easy to extend with new payment methods
com.nit
│
├── config
│ └── AppConfig.java
│
├── main
│ └── TestPaymentSystem.java
│
└── sbeans
├── PaymentService.java
├── PaymentProcessor.java
├── GooglePayService.java
└── PaytmPaymentService.java
- Java
- Spring Framework (Core)
- Annotation-based Configuration
- Spring scans components using
@ComponentScan - Payment services implement a common interface (
PaymentService) PaymentProcessorinjects a specific implementation using@Qualifier- The main class initializes Spring container and triggers payment processing
Defines a contract for all payment implementations.
public interface PaymentService {
public void pay(double amount);
}Implements payment using Google Pay
Implements payment using Paytm (currently active)
Handles payment logic by delegating to the selected service.
@Autowired
@Qualifier("paytmPaymentService")
private PaymentService paymentService;Spring configuration class enabling component scanning.
Main class used to run the application.
paymentProcessor.processPayment(154025);-
Clone the repository:
git clone https://github.com/your-username/payment-system.git
-
Open the project in your IDE (Eclipse / IntelliJ)
-
Run:
TestPaymentSystem.java
To change the payment service, update the qualifier in PaymentProcessor:
@Qualifier("googlePayService")- Add more payment methods (PhonePe, Credit Card, etc.)
- Convert to Spring Boot
- Add REST APIs
- Implement logging and validation
- Add database integration
Contributions are welcome! Feel free to fork the repo and submit pull requests.
This project is open-source and free to use.
Developed using Java & Spring Framework 🚀