├── .DS_Store ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── test │ └── java │ │ └── com │ │ └── syc │ │ └── finance │ │ └── v1 │ │ └── bharat │ │ ├── ServiceTest.java │ │ ├── ControllerTest.java │ │ └── BankApplicationTests.java └── main │ ├── java │ └── com │ │ └── syc │ │ └── finance │ │ └── v1 │ │ └── bharat │ │ ├── mapper │ │ ├── MapperToDebitResponse.java │ │ ├── TransactionToTransactionResponse.java │ │ ├── MapperToUpdateResponse.java │ │ └── MapperToResponse.java │ │ ├── utils │ │ ├── AccountDeletedSuccessResponse.java │ │ ├── AccountDetailsForExceptionalHandler.java │ │ ├── InternetBankingIdGenerator.java │ │ ├── UPIDGenerater.java │ │ ├── AccountDetailsGenarators.java │ │ └── AccountlLimitReached.java │ │ ├── exceptions │ │ ├── DailyLimitExceed.java │ │ ├── NotHavingNetbanking.java │ │ ├── AccountNotFoundStep.java │ │ ├── InSufficientBalance.java │ │ ├── EmailAlreadyExistStep.java │ │ ├── UpiAlreadyExist.java │ │ ├── RechangeDetailsNotValid.java │ │ ├── NetBankingIdAlreadyExist.java │ │ ├── DetailsNotFountException.java │ │ ├── PhoneNumberAlreadyExistStep.java │ │ ├── AccountBalanceMinimumSteps.java │ │ ├── ServiceProviderIsNullException.java │ │ ├── ServiceProviderValidationException.java │ │ ├── UpiNotFoundException.java │ │ └── handler │ │ │ ├── ErrorResponses.java │ │ │ └── GlobalExceptionHandling.java │ │ ├── dto │ │ ├── Accounts │ │ │ ├── AccountDetailsRequest.java │ │ │ ├── AlreadyExistAccounts.java │ │ │ ├── AccountRequest.java │ │ │ ├── AccountDeleteAccountDetailsResponse.java │ │ │ ├── AccountDeleteAccountDetailsRequest.java │ │ │ ├── Transaction │ │ │ │ └── TransactionResponse.java │ │ │ ├── AccountUpdateDetailsResponse.java │ │ │ ├── AccountUpdatingDetailsRequest.java │ │ │ └── AccountDetailsResponse.java │ │ ├── Update │ │ │ ├── UpdateAmountResponse.java │ │ │ └── UpdateAmountManually.java │ │ ├── TransferMoney │ │ │ ├── TransferMoneyResponse.java │ │ │ └── TransferMoneyRequest.java │ │ ├── UPIPay │ │ │ ├── AddMoneyToUPIFromAccountResponse.java │ │ │ ├── AddMoneyFromAccountToUPIResponse.java │ │ │ ├── AddMoneyFromAccountToUPIRequest.java │ │ │ └── AddMoneyToUPIFromAccountRequest.java │ │ ├── UPI │ │ │ ├── GetUPIRequest.java │ │ │ ├── UPIRequest.java │ │ │ └── UPIResponse.java │ │ ├── InternetBanking │ │ │ ├── GetNetBankingRequest.java │ │ │ ├── NetBankingRequest.java │ │ │ └── NetBankingResponse.java │ │ ├── Credit │ │ │ ├── CreditCredential.java │ │ │ └── CreditResponse.java │ │ ├── BalanceEnquiry │ │ │ ├── BalanceEnquireyRequest.java │ │ │ └── BalanceEnquiryResponse.java │ │ ├── Debit │ │ │ ├── DebitCredential.java │ │ │ └── DebitedResponse.java │ │ ├── Transaction │ │ │ └── TransactionRequest.java │ │ ├── UserRequest.java │ │ └── UserResponse.java │ │ ├── notification │ │ ├── NotificationErrorResponse.java │ │ ├── NotificationConfig.java │ │ └── NotificationsUtility.java │ │ ├── BankApplication.java │ │ ├── entity │ │ ├── TransactionDetailsHistory.java │ │ ├── UpiInformation.java │ │ ├── NetBankingInformation.java │ │ └── AccountInformation.java │ │ ├── service │ │ ├── TransactionService │ │ │ ├── TransactionService.java │ │ │ └── TransactionServiceImpl.java │ │ ├── UpiAndNetBanking │ │ │ ├── UPIAndNetBankingService.java │ │ │ └── UPIAndNetNetBankingServiceImpl.java │ │ ├── AccountService.java │ │ └── AccountServiceImpl.java │ │ ├── repository │ │ ├── NetBankingRepositories.java │ │ ├── UPIDetailsRepositories.java │ │ ├── TransactionHistoryRepository.java │ │ └── AccountDetailsRepositories.java │ │ ├── controller │ │ ├── TransferAccount.java │ │ ├── TransactionController.java │ │ ├── UpiController.java │ │ ├── NetBankingController.java │ │ └── AccountController.java │ │ └── constants │ │ └── AccountDetailsConstants.java │ └── resources │ └── application.yaml ├── All APIs Link ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HimanshuSingour/Bank-Of-Bharat-BOB/HEAD/.DS_Store -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HimanshuSingour/Bank-Of-Bharat-BOB/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/test/java/com/syc/finance/v1/bharat/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat; 2 | 3 | public class ServiceTest { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/java/com/syc/finance/v1/bharat/ControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat; 2 | 3 | public class ControllerTest { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/mapper/MapperToDebitResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.mapper; 2 | 3 | public class MapperToDebitResponse { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/AccountDeletedSuccessResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | public class AccountDeletedSuccessResponse { 4 | public AccountDeletedSuccessResponse(String ex){ 5 | super(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/DailyLimitExceed.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class DailyLimitExceed extends RuntimeException{ 4 | 5 | public DailyLimitExceed(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/NotHavingNetbanking.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class NotHavingNetbanking extends RuntimeException{ 4 | public NotHavingNetbanking(String message){ 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/AccountNotFoundStep.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class AccountNotFoundStep extends RuntimeException{ 4 | 5 | public AccountNotFoundStep(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/InSufficientBalance.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class InSufficientBalance extends RuntimeException{ 4 | 5 | public InSufficientBalance(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/EmailAlreadyExistStep.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class EmailAlreadyExistStep extends RuntimeException{ 4 | 5 | public EmailAlreadyExistStep(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/UpiAlreadyExist.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class UpiAlreadyExist extends RuntimeException{ 4 | 5 | public UpiAlreadyExist(String message){ 6 | 7 | super(message); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/RechangeDetailsNotValid.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class RechangeDetailsNotValid extends RuntimeException{ 4 | 5 | public RechangeDetailsNotValid(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/NetBankingIdAlreadyExist.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class NetBankingIdAlreadyExist extends RuntimeException{ 4 | 5 | public NetBankingIdAlreadyExist(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/DetailsNotFountException.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class DetailsNotFountException extends RuntimeException{ 4 | 5 | public DetailsNotFountException(String msg){ 6 | super(msg); 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/PhoneNumberAlreadyExistStep.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class PhoneNumberAlreadyExistStep extends RuntimeException{ 4 | 5 | public PhoneNumberAlreadyExistStep(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/AccountBalanceMinimumSteps.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class AccountBalanceMinimumSteps extends RuntimeException{ 4 | 5 | public AccountBalanceMinimumSteps(String mesg){ 6 | super(mesg); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/ServiceProviderIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class ServiceProviderIsNullException extends RuntimeException{ 4 | 5 | public ServiceProviderIsNullException(String message){ 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/ServiceProviderValidationException.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | public class ServiceProviderValidationException extends RuntimeException{ 4 | 5 | public ServiceProviderValidationException(String messages){ 6 | super(messages); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/syc/finance/v1/bharat/BankApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BankApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountDetailsRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.*; 4 | 5 | 6 | @Data 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | @Builder 10 | public class 11 | AccountDetailsRequest { 12 | 13 | private String accountNumber; 14 | private String IfscCode; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AlreadyExistAccounts.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AlreadyExistAccounts { 11 | 12 | private String message; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Update/UpdateAmountResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Update; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UpdateAmountResponse { 11 | 12 | private String message; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/UpiNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | 7 | public class UpiNotFoundException extends RuntimeException{ 8 | 9 | 10 | public UpiNotFoundException(String message){ 11 | 12 | super(message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/notification/NotificationErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.notification; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class NotificationErrorResponse { 11 | 12 | private String message; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/TransferMoney/TransferMoneyResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.TransferMoney; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class TransferMoneyResponse { 11 | 12 | private String responseMessage; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPIPay/AddMoneyToUPIFromAccountResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPIPay; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AddMoneyToUPIFromAccountResponse { 11 | 12 | private String status; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AccountRequest { 11 | 12 | private String accountNumber; 13 | private String ifsccode; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPI/GetUPIRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPI; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class GetUPIRequest { 11 | 12 | private String accountNumber; 13 | private String bankPassword; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Update/UpdateAmountManually.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Update; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UpdateAmountManually { 11 | 12 | private String accountNumber; 13 | private double accountBalance; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/BankApplication.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class BankApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(BankApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/InternetBanking/GetNetBankingRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.InternetBanking; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class GetNetBankingRequest { 11 | 12 | private String accountNumber; 13 | private String ifscCode; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Credit/CreditCredential.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Credit; 2 | 3 | import lombok.Data; 4 | 5 | 6 | @Data 7 | public class CreditCredential { 8 | 9 | private String accountNumber; 10 | private String password; 11 | private String bankPinCode; 12 | private String ifscCode; 13 | private String bankName; 14 | private double creditYourMoney; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPIPay/AddMoneyFromAccountToUPIResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPIPay; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AddMoneyFromAccountToUPIResponse { 11 | 12 | private String responseMessage; 13 | private String status; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPI/UPIRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPI; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UPIRequest { 11 | 12 | private String accountNumber; 13 | private String ifscCode; 14 | private String contactNumber; 15 | private String password; 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPIPay/AddMoneyFromAccountToUPIRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPIPay; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class AddMoneyFromAccountToUPIRequest { 12 | 13 | private String upiId; 14 | private String accountNumber; 15 | private double payMoney; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/BalanceEnquiry/BalanceEnquireyRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.BalanceEnquiry; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class BalanceEnquireyRequest { 11 | 12 | private String accountNumber; 13 | private String password; 14 | private String ifscCode; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Debit/DebitCredential.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Debit; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class DebitCredential { 12 | 13 | private String accountNumber; 14 | private String password; 15 | private String ifscCode; 16 | private double debitYourMoney; 17 | } 18 | -------------------------------------------------------------------------------- /All APIs Link: -------------------------------------------------------------------------------- 1 | http://localhost:9090/finance/v1/bank/v4/bharat/create-account 2 | http://localhost:9090/finance/v1/bank/v4/bharat/update-account-details 3 | http://localhost:9090/finance/v1/bank/v4/bharat/get-account-details/302668029483/BOB9793 4 | http://localhost:9090/finance/v1/bank/v4/bharat/delete-account 5 | http://localhost:9090/finance/v1/bank/v4/bharat/credit-money 6 | http://localhost:9090/finance/v1/bank/v4/bharat/credit-money 7 | http://localhost:9090/finance/v1/bank/v4/bharat/debit-money 8 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountDeleteAccountDetailsResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | @Builder 13 | public class AccountDeleteAccountDetailsResponse { 14 | 15 | private String userDeleteId; 16 | private String Message; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/InternetBanking/NetBankingRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.InternetBanking; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class NetBankingRequest { 11 | 12 | private String accountNumber; 13 | private String accountHolderName; 14 | private String ifscCode; 15 | private String password; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPIPay/AddMoneyToUPIFromAccountRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPIPay; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class AddMoneyToUPIFromAccountRequest { 12 | 13 | private double addedFromUpi; 14 | private String accountNumber; 15 | private String password; 16 | private String upiId; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/handler/ErrorResponses.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions.handler; 2 | 3 | import com.syc.finance.v1.bharat.utils.AccountDetailsForExceptionalHandler; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class ErrorResponses { 12 | 13 | private String errorMessage; 14 | private AccountDetailsForExceptionalHandler status; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/AccountDetailsForExceptionalHandler.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | import lombok.*; 4 | 5 | @Getter 6 | @AllArgsConstructor 7 | public enum AccountDetailsForExceptionalHandler { 8 | 9 | PENDING("Pending"), 10 | APPROVED("Approved"), 11 | REJECTED("Rejected"), 12 | COMPLETED("Completed"); 13 | 14 | private final String label; 15 | 16 | public String getLabel() { 17 | return label; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/BalanceEnquiry/BalanceEnquiryResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.BalanceEnquiry; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class BalanceEnquiryResponse { 14 | 15 | private String balanceId; 16 | private String accountNumber; 17 | private String statusMessage; 18 | private double yourBalance; 19 | private LocalDateTime localDateTime; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountDeleteAccountDetailsRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class AccountDeleteAccountDetailsRequest { 13 | 14 | private String accountHolderName; 15 | private String password; 16 | private String accountNumber; 17 | private String contactEmail; 18 | private String contactPhone; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/InternetBanking/NetBankingResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.InternetBanking; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class NetBankingResponse { 13 | 14 | private String netId; 15 | private String accountHolderName; 16 | private String net_BANKING_ID; 17 | private LocalDateTime localDateTime; 18 | private String accountNumber; 19 | private String ifscCode; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Transaction/TransactionRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Transaction; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class TransactionRequest { 13 | 14 | private String transactionId; 15 | private String accountNumber; 16 | private String ifscCode; 17 | private String debitedOrCredited; 18 | private LocalDateTime localDateTime; 19 | private double debitOrCreditMoney; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/TransferMoney/TransferMoneyRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.TransferMoney; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class TransferMoneyRequest { 13 | 14 | private String fullNameOfRecipient; 15 | private String accountNumberOfRecipient; 16 | private String accountNumberOfSender; 17 | private double transferAmount; 18 | private LocalDate localDate; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/Transaction/TransactionResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts.Transaction; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class TransactionResponse { 13 | 14 | private String accountId; 15 | private String accountNumber; 16 | private String ifscCode; 17 | private String debitedOrCredited; 18 | private LocalDateTime localDateTime; 19 | private double debitOrCreditMoney; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | 2 | # Database Configuration 3 | server: 4 | port: 7777 5 | 6 | spring: 7 | datasource: 8 | url: jdbc:mysql://root:CgDHgA5AC-fD1Ah4aBhagbe142b4-GEa@roundhouse.proxy.rlwy.net:15150/railway 9 | username: root 10 | password: CgDHgA5AC-fD1Ah4aBhagbe142b4-GEa 11 | driver-class-name : com.mysql.cj.jdbc.Driver 12 | 13 | main: 14 | web-application-type=none: 15 | allow-circular-references: true 16 | 17 | jpa: 18 | properties: 19 | hibernate: 20 | dialect: org.hibernate.dialect.MySQL8Dialect 21 | hibernate: 22 | ddl-auto: update 23 | show-sql: true 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/entity/TransactionDetailsHistory.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.entity; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.*; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | @Entity 13 | @Table(name = "TRANSACTION_HISTORY") 14 | @Builder 15 | public class TransactionDetailsHistory { 16 | 17 | @Id 18 | private String transactionId; 19 | private String accountNumber; 20 | private String ifscCode; 21 | private String debitedOrCredited; 22 | private LocalDateTime localDateTime; 23 | private double debitOrCreditMoney; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Debit/DebitedResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Debit; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class DebitedResponse { 14 | 15 | private String debitedId; 16 | private String accountNumber; 17 | private String ifscCode; 18 | private double currentBalance; 19 | private double debitYourMoney; 20 | private String accountHolderName; 21 | private String statusDebit; 22 | private LocalDateTime localDateTime; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Credit/CreditResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Credit; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class CreditResponse { 14 | 15 | private String creditId; 16 | private double currentBalance; 17 | private String accountHolderName; 18 | private String accountNumber; 19 | private String ifscCode; 20 | private String bankName; 21 | private String statusMoney; 22 | private LocalDateTime localDateTime; 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/TransactionService/TransactionService.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service.TransactionService; 2 | 3 | import com.syc.finance.v1.bharat.dto.Accounts.Transaction.TransactionResponse; 4 | import com.syc.finance.v1.bharat.dto.Transaction.TransactionRequest; 5 | 6 | import java.time.LocalDateTime; 7 | import java.util.List; 8 | 9 | public interface TransactionService { 10 | 11 | void saveTransaction(TransactionRequest transactionRequest); 12 | List getAllTransaction(String accountNumber); 13 | long countTransactionsByAccountNumberAndTimestamp(String accountNumber, LocalDateTime twentyFourHoursAgo, LocalDateTime currentDateTime); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/entity/UpiInformation.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.entity; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | import lombok.*; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Entity 12 | @Builder 13 | @Table(name = "UPI_INFO") 14 | public class UpiInformation { 15 | 16 | @Id 17 | private String globalId; 18 | private String accountNumber; 19 | private String upiId; 20 | private String ifscCode; 21 | private String bankPassword; 22 | private String contactNumber; 23 | private String contactEmail; 24 | private String UPI_CODE; 25 | private double UPI_BALANCE; 26 | private String responseMessage; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/repository/NetBankingRepositories.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.repository; 2 | 3 | import com.syc.finance.v1.bharat.entity.AccountInformation; 4 | import com.syc.finance.v1.bharat.entity.NetBankingInformation; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public interface NetBankingRepositories extends JpaRepository { 11 | 12 | @Query("SELECT u FROM NetBankingInformation u WHERE u.accountNumber = :accountNumber AND u.ifscCode = :ifscCode") 13 | NetBankingInformation findByAccountIdAndIfscCode(String accountNumber, String ifscCode); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UPI/UPIResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.UPI; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UPIResponse { 11 | 12 | private String accountNumber; // The bank account number linked to the UPI ID 13 | private String contactNumber; // The phone number associated with the UPI account 14 | private String contactEmail; 15 | private String upiId; // The UPI ID of the user 16 | private String UPI_CODE;// The email address associated with the UPI account 17 | private double UPI_BALANCE; // The current balance in the UPI account 18 | private String responseMessage; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/InternetBankingIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | import java.util.Random; 4 | 5 | public class InternetBankingIdGenerator { 6 | private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 7 | private static final int ID_LENGTH = 15; // Adjust the length as needed 8 | 9 | public String generateInternetBankingId() { 10 | StringBuilder idBuilder = new StringBuilder(); 11 | Random random = new Random(); 12 | 13 | for (int i = 0; i < ID_LENGTH; i++) { 14 | char randomChar = CHARACTERS.charAt(random.nextInt(CHARACTERS.length())); 15 | idBuilder.append(randomChar); 16 | } 17 | 18 | return idBuilder.toString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UserRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UserRequest { 11 | 12 | private String accountHolderName; 13 | private String contactEmail; 14 | private String contactPhone; 15 | private String gender; 16 | private String contactAddress; 17 | private String stateOfOrigin; 18 | private String pinCodeNumber; 19 | private String password; 20 | private String currentLocation; 21 | private String designation; 22 | private String country; 23 | private String accountType; 24 | 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/entity/NetBankingInformation.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.entity; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | import java.time.LocalDateTime; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Builder 17 | @Entity 18 | @Table(name = "NET_BANKING") 19 | public class NetBankingInformation { 20 | 21 | @Id 22 | private String netId; 23 | private String accountNumber; 24 | private String ifscCode; 25 | private String accountHolderName; 26 | private String password; 27 | private String net_BANKING_ID; 28 | private LocalDateTime localDateTime; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountUpdateDetailsResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class AccountUpdateDetailsResponse { 14 | 15 | private String accountHolderName; 16 | private String contactEmail; 17 | private String contactPhone; 18 | private String contactAddress; 19 | private String stateOfOrigin; 20 | private String pinCodeNumber; 21 | private String currentLocation; 22 | private String designation; 23 | private String country; 24 | private String accountType; 25 | private LocalDateTime localDateTime; 26 | private LocalDate accountUpdateDate; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/UserResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class UserResponse { 14 | 15 | private String accountId; 16 | private String message; 17 | private String accountHolderName; 18 | private String accountNumber; 19 | private String bankName; 20 | private String bankBranch; 21 | private String IfscCode; 22 | private LocalDate accountOpenDate; 23 | private String isHaveUpiId; 24 | private double accountBalance; 25 | private String routingNumber; 26 | private String password; 27 | private String accountType; 28 | private String contactEmail; 29 | private String contactPhone; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/repository/UPIDetailsRepositories.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.repository; 2 | 3 | import com.syc.finance.v1.bharat.entity.UpiInformation; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public interface UPIDetailsRepositories extends JpaRepository { 11 | 12 | @Query("SELECT u FROM UpiInformation u WHERE u.accountNumber = :accountNumber AND u.bankPassword = :bankPassword") 13 | UpiInformation findByAccountNumberAndPassword(@Param("accountNumber") String accountNumber, @Param("bankPassword") String bankPassword); 14 | 15 | @Query("SELECT u FROM UpiInformation u WHERE u.upiId = :upiId") 16 | UpiInformation findByUpiId(@Param("upiId") String upiId); 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/repository/TransactionHistoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.repository; 2 | 3 | import com.syc.finance.v1.bharat.entity.TransactionDetailsHistory; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.time.LocalDateTime; 9 | import java.util.List; 10 | 11 | @Repository 12 | public interface TransactionHistoryRepository extends JpaRepository { 13 | 14 | @Query("SELECT u FROM TransactionDetailsHistory u WHERE u.accountNumber = :accountNumber") 15 | List findAllByAccountNumberAndIfscCode(String accountNumber); 16 | 17 | long countByAccountNumberAndLocalDateTimeBetween( 18 | String accountNumber, 19 | LocalDateTime startTimestamp, 20 | LocalDateTime endTimestamp 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountUpdatingDetailsRequest.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class AccountUpdatingDetailsRequest { 14 | 15 | 16 | private String accountHolderName; 17 | 18 | private String accountNumber; 19 | private String IfscCode; 20 | private String contactEmail; 21 | 22 | private String contactPhone; 23 | private String contactAddress; 24 | private String stateOfOrigin; 25 | private String pinCodeNumber; 26 | private String currentLocation; 27 | private String designation; 28 | private String country; 29 | private String accountType; 30 | private LocalDateTime localDateTime; 31 | private LocalDate accountOpenDate; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/mapper/TransactionToTransactionResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.mapper; 2 | 3 | import com.syc.finance.v1.bharat.dto.Accounts.Transaction.TransactionResponse; 4 | import com.syc.finance.v1.bharat.entity.TransactionDetailsHistory; 5 | 6 | public class TransactionToTransactionResponse { 7 | 8 | public static TransactionResponse transactionToResponse(TransactionDetailsHistory transactionDetailsHistory) { 9 | 10 | TransactionResponse updateMapper = new TransactionResponse(); 11 | updateMapper.setAccountId(transactionDetailsHistory.getTransactionId()); 12 | updateMapper.setDebitedOrCredited(transactionDetailsHistory.getDebitedOrCredited()); 13 | updateMapper.setAccountNumber(transactionDetailsHistory.getAccountNumber()); 14 | updateMapper.setLocalDateTime(transactionDetailsHistory.getLocalDateTime()); 15 | updateMapper.setDebitOrCreditMoney(transactionDetailsHistory.getDebitOrCreditMoney()); 16 | return updateMapper; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/UPIDGenerater.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | import java.util.Random; 4 | 5 | public class UPIDGenerater { 6 | 7 | public String generateUpiId(String fullName) { 8 | 9 | if(fullName == null) return null; 10 | 11 | String[] names = fullName.split(" "); 12 | 13 | if (names.length == 2) { 14 | 15 | String firstName = names[0]; 16 | String lastName = names[1]; 17 | 18 | if (firstName.isEmpty() || lastName.isEmpty()) { 19 | return null; 20 | } 21 | 22 | String upiId = lastName + firstName + "@" + "okbob"; 23 | return upiId; 24 | } 25 | 26 | return null; 27 | } 28 | 29 | public String generatePin() { 30 | Random random = new Random(); 31 | int min = 100000; 32 | int max = 999999; 33 | int upiCode = random.nextInt(max - min + 1) + min; 34 | return String.format("%06d", upiCode); // Corrected the formatting 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/controller/TransferAccount.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.controller; 2 | 3 | 4 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyRequest; 5 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyResponse; 6 | import com.syc.finance.v1.bharat.service.UpiAndNetBanking.UPIAndNetBankingService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | @RestController 13 | @RequestMapping("transfer/v1/banking/v6") 14 | public class TransferAccount { 15 | 16 | @Autowired 17 | private UPIAndNetBankingService upiAndNetBankingService; 18 | 19 | @PostMapping("/process") 20 | ResponseEntity transactionGive(@RequestBody TransferMoneyRequest transferMoneyRequest){ 21 | TransferMoneyResponse response = upiAndNetBankingService.moneyTransferAccountToAccount(transferMoneyRequest); 22 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/UpiAndNetBanking/UPIAndNetBankingService.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service.UpiAndNetBanking; 2 | 3 | import com.syc.finance.v1.bharat.dto.InternetBanking.GetNetBankingRequest; 4 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingRequest; 5 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingResponse; 6 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyRequest; 7 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyResponse; 8 | import com.syc.finance.v1.bharat.dto.UPI.GetUPIRequest; 9 | import com.syc.finance.v1.bharat.dto.UPI.UPIRequest; 10 | import com.syc.finance.v1.bharat.dto.UPI.UPIResponse; 11 | 12 | public interface UPIAndNetBankingService { 13 | 14 | UPIResponse upiCreate(UPIRequest upiRequest); 15 | NetBankingResponse createNetBanking(NetBankingRequest netBankingRequest); 16 | UPIResponse getYourUpiInInfo(GetUPIRequest upiRequest); 17 | NetBankingResponse getYourNetBankingInfo(GetNetBankingRequest netBankingRequest); 18 | 19 | TransferMoneyResponse moneyTransferAccountToAccount(TransferMoneyRequest transferMoneyRequest); 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/notification/NotificationConfig.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.notification; 2 | 3 | import com.twilio.rest.api.v2010.account.Message; 4 | import com.twilio.type.PhoneNumber; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Component; 7 | 8 | import static com.syc.finance.v1.bharat.constants.AccountDetailsConstants.TWILIO_PHONE_NUMBER; 9 | 10 | 11 | @Component 12 | @Slf4j 13 | public class NotificationConfig { 14 | 15 | public void sendSMS(String messageBody) { 16 | PhoneNumber recipientNumber = new com.twilio.type.PhoneNumber("+916266769479"); 17 | PhoneNumber twilioNumber = new com.twilio.type.PhoneNumber(TWILIO_PHONE_NUMBER); 18 | 19 | try { 20 | Message message = Message.creator(recipientNumber, twilioNumber, messageBody).create(); 21 | 22 | if (message.getStatus() == Message.Status.SENT) { 23 | log.info("SMS sent successfully!"); 24 | } else { 25 | log.error("Failed to send SMS: " + message.getErrorMessage()); 26 | } 27 | } catch (Exception e) { 28 | log.error("An error occurred while sending SMS: " + e.getMessage(), e); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/controller/TransactionController.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.controller; 2 | 3 | import com.syc.finance.v1.bharat.dto.Accounts.Transaction.TransactionResponse; 4 | import com.syc.finance.v1.bharat.service.TransactionService.TransactionService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.List; 14 | 15 | @RestController 16 | @RequestMapping("/transaction/v1/fetch") 17 | public class TransactionController { 18 | 19 | @Autowired 20 | private TransactionService transactionService; 21 | 22 | @GetMapping("/transaction-enquiry/{accountNumber}") 23 | ResponseEntity> transactionGive(@PathVariable String accountNumber){ 24 | List response = transactionService.getAllTransaction(accountNumber); 25 | return new ResponseEntity>(response , HttpStatus.ACCEPTED); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/entity/AccountInformation.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.entity; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.*; 5 | 6 | import java.time.LocalDate; 7 | import java.time.LocalDateTime; 8 | import java.util.List; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | @ToString 16 | @Entity 17 | @Table(name = "USER_INFO") 18 | public class AccountInformation { 19 | 20 | @Id 21 | private String accountId; 22 | private String accountHolderName; 23 | private String contactEmail; 24 | private String contactPhone; 25 | private String gender; 26 | private String contactAddress; 27 | private String stateOfOrigin; 28 | private String pinCodeNumber; 29 | private String currentLocation; 30 | private String designation; 31 | private String country; 32 | private String accountNumber; 33 | private String password; 34 | private String ifscCode; 35 | private String bankName; 36 | private String bankBranch; 37 | private String routingNumber; 38 | private String bankPinCode; 39 | private String accountType; 40 | private String isHaveUpiId; 41 | private double accountBalance; 42 | private String status; 43 | private LocalDateTime localDateTime; 44 | private LocalDate accountOpenDate; 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/AccountDetailsGenarators.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | import java.util.Random; 4 | public class AccountDetailsGenarators { 5 | 6 | public String generateAccountNumber(){ 7 | Random random = new Random(); 8 | long accountNumberLong = random.nextLong() % 1000000000000L + 1000000000000L; 9 | return String.valueOf(accountNumberLong); 10 | } 11 | 12 | public String gereratedIFSC() { 13 | Random random = new Random(); 14 | int branchCodeInt = random.nextInt(9000) + 1000; 15 | return String.valueOf(branchCodeInt); 16 | } 17 | 18 | public String generatePin() { 19 | Random random = new Random(); 20 | int pin = random.nextInt(9000) + 1000; 21 | String pinString = String.valueOf(pin); 22 | return pinString; 23 | } 24 | 25 | public String generateBankCode() { 26 | Random random = new Random(); 27 | int bankCodeInt = random.nextInt(9000) + 1000; 28 | return String.valueOf(bankCodeInt); 29 | } 30 | 31 | // Generate a fictional branch code (4 digits) 32 | public String generateBranchCode() { 33 | Random random = new Random(); 34 | int branchCodeInt = random.nextInt(9000) + 1000; 35 | return String.valueOf(branchCodeInt); 36 | } 37 | 38 | 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/controller/UpiController.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.controller; 2 | 3 | 4 | import com.syc.finance.v1.bharat.dto.UPI.GetUPIRequest; 5 | import com.syc.finance.v1.bharat.dto.UPI.UPIRequest; 6 | import com.syc.finance.v1.bharat.dto.UPI.UPIResponse; 7 | import com.syc.finance.v1.bharat.service.UpiAndNetBanking.UPIAndNetBankingService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | @RestController 14 | @RequestMapping("finance/upi/v1/") 15 | public class UpiController { 16 | 17 | @Autowired 18 | private UPIAndNetBankingService upiAndNetBankingService; 19 | 20 | @PostMapping("/upi-create") 21 | ResponseEntity upiCreateUp(@RequestBody UPIRequest upiRequest){ 22 | UPIResponse response = upiAndNetBankingService.upiCreate(upiRequest); 23 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 24 | } 25 | 26 | @GetMapping("/get-upi-details") 27 | ResponseEntity getUpiDetails(@RequestBody GetUPIRequest upiRequest) { 28 | UPIResponse response = upiAndNetBankingService.getYourUpiInInfo(upiRequest); 29 | return new ResponseEntity(response, HttpStatus.ACCEPTED); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/dto/Accounts/AccountDetailsResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.dto.Accounts; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | import java.time.LocalDateTime; 9 | 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class AccountDetailsResponse { 15 | 16 | private String accountId; 17 | private String accountHolderName; 18 | private String contactEmail; 19 | private String contactPhone; 20 | private String gender; 21 | private String contactAddress; 22 | private String stateOfOrigin; 23 | private String pinCodeNumber; 24 | private String currentLocation; 25 | private String designation; 26 | private String country; 27 | private String accountNumber; 28 | private String ifscCode; 29 | private String bankName; 30 | private String bankBranch; 31 | private String routingNumber; 32 | private String accountType; 33 | private double accountBalance; 34 | private String status; 35 | private LocalDateTime localDateTime; 36 | private LocalDate accountOpenDate; 37 | 38 | // adding NetBanking Info 39 | private String password; 40 | private String net_BANKING_ID; 41 | 42 | //Upi Details 43 | private String UPI_ID; 44 | private double UPI_BALANCE; 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/mapper/MapperToUpdateResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.mapper; 2 | 3 | import com.syc.finance.v1.bharat.dto.Accounts.AccountUpdateDetailsResponse; 4 | import com.syc.finance.v1.bharat.entity.AccountInformation; 5 | 6 | public class MapperToUpdateResponse { 7 | 8 | public AccountUpdateDetailsResponse userInformationToUpdateAccountResponse(AccountInformation accountInformation) { 9 | 10 | AccountUpdateDetailsResponse updateMapper = new AccountUpdateDetailsResponse(); 11 | updateMapper.setAccountHolderName(accountInformation.getAccountHolderName()); 12 | updateMapper.setAccountType(accountInformation.getAccountType()); 13 | updateMapper.setContactEmail(accountInformation.getContactEmail()); 14 | updateMapper.setContactPhone(accountInformation.getContactPhone()); 15 | updateMapper.setContactAddress(accountInformation.getContactAddress()); 16 | updateMapper.setStateOfOrigin(accountInformation.getStateOfOrigin()); 17 | updateMapper.setPinCodeNumber(accountInformation.getPinCodeNumber()); 18 | updateMapper.setCurrentLocation(accountInformation.getCurrentLocation()); 19 | updateMapper.setDesignation(accountInformation.getDesignation()); 20 | updateMapper.setCountry(accountInformation.getCountry()); 21 | updateMapper.setAccountType(updateMapper.getAccountType()); 22 | 23 | return updateMapper; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/utils/AccountlLimitReached.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.utils; 2 | 3 | import com.syc.finance.v1.bharat.entity.AccountInformation; 4 | import com.syc.finance.v1.bharat.exceptions.DailyLimitExceed; 5 | import com.syc.finance.v1.bharat.service.TransactionService.TransactionService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | @Component 12 | public class AccountlLimitReached { 13 | 14 | @Autowired 15 | private TransactionService transactionService; 16 | 17 | public void validateDailyTransactionLimit(AccountInformation accountInformation) { 18 | 19 | if (accountInformation != null) { 20 | int maxTransactionCount = 5; 21 | LocalDateTime currentDateTime = LocalDateTime.now(); 22 | LocalDateTime twentyFourHoursAgo = currentDateTime.minusSeconds(10); 23 | 24 | long transactionCount = transactionService.countTransactionsByAccountNumberAndTimestamp( 25 | accountInformation.getAccountNumber(), 26 | twentyFourHoursAgo, 27 | currentDateTime); 28 | 29 | if (transactionCount >= maxTransactionCount) { 30 | throw new DailyLimitExceed("You have reached the maximum transaction limit for the last 24 hours."); 31 | } 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/controller/NetBankingController.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.controller; 2 | 3 | import com.syc.finance.v1.bharat.dto.InternetBanking.GetNetBankingRequest; 4 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingRequest; 5 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingResponse; 6 | import com.syc.finance.v1.bharat.service.UpiAndNetBanking.UPIAndNetBankingService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | @RestController 13 | @RequestMapping("finance/v1/banking") 14 | public class NetBankingController { 15 | 16 | @Autowired 17 | private UPIAndNetBankingService upiAndNetBankingService; 18 | 19 | @PostMapping("/net-bankingId-create") 20 | ResponseEntity upiCreateUp(@RequestBody NetBankingRequest netBankingRequest){ 21 | NetBankingResponse response = upiAndNetBankingService.createNetBanking(netBankingRequest); 22 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 23 | } 24 | 25 | @GetMapping("/get-internetBanking-details") 26 | ResponseEntity getUpiDetails(@RequestBody GetNetBankingRequest netBankingRequest){ 27 | NetBankingResponse response = upiAndNetBankingService.getYourNetBankingInfo(netBankingRequest); 28 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/mapper/MapperToResponse.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.mapper; 2 | 3 | import com.syc.finance.v1.bharat.dto.UserResponse; 4 | import com.syc.finance.v1.bharat.entity.AccountInformation; 5 | 6 | public class MapperToResponse { 7 | 8 | // Himashu 9 | 10 | public UserResponse userInformationToUserResponse(AccountInformation accountInformation) { 11 | 12 | UserResponse userResponse = new UserResponse(); 13 | userResponse.setIsHaveUpiId(accountInformation.getIsHaveUpiId()); 14 | userResponse.setAccountId(accountInformation.getAccountId()); 15 | userResponse.setAccountHolderName(accountInformation.getAccountHolderName()); 16 | userResponse.setAccountNumber(accountInformation.getAccountNumber()); 17 | userResponse.setBankName(accountInformation.getBankName()); 18 | userResponse.setBankBranch(accountInformation.getBankBranch()); 19 | userResponse.setIfscCode(accountInformation.getIfscCode()); 20 | userResponse.setAccountOpenDate(accountInformation.getAccountOpenDate()); 21 | userResponse.setAccountBalance(accountInformation.getAccountBalance()); 22 | userResponse.setRoutingNumber(accountInformation.getRoutingNumber()); 23 | userResponse.setPassword(accountInformation.getPassword()); 24 | userResponse.setAccountType(accountInformation.getAccountType()); 25 | userResponse.setContactEmail(accountInformation.getContactEmail()); 26 | userResponse.setContactPhone(accountInformation.getContactPhone()); 27 | 28 | return userResponse; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/repository/AccountDetailsRepositories.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.repository; 2 | 3 | import com.syc.finance.v1.bharat.entity.AccountInformation; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public interface AccountDetailsRepositories extends JpaRepository { 11 | 12 | @Query("SELECT u FROM AccountInformation u WHERE u.contactEmail = :contactEmail") 13 | AccountInformation findByContactEmail(@Param("contactEmail") String contactEmail); 14 | 15 | @Query("SELECT u FROM AccountInformation u WHERE u.contactPhone = :contactPhone") 16 | AccountInformation findByContactPhoneNumber(@Param("contactPhone") String phoneNumber); 17 | 18 | @Query("SELECT u FROM AccountInformation u WHERE u.accountNumber = :accountNumber") 19 | AccountInformation findByAccountNumber(String accountNumber); 20 | 21 | @Query("SELECT u FROM AccountInformation u WHERE u.accountNumber = :accountNumber AND u.ifscCode = :ifscCode AND u.password = :password") 22 | AccountInformation findByAccountIdAndIfscCode(String accountNumber, String ifscCode , String password); 23 | 24 | @Query("SELECT u FROM AccountInformation u WHERE u.accountNumber = :accountNumber AND u.password = :password") 25 | AccountInformation findByAccountNumberAndPassword(String accountNumber , String password); 26 | 27 | @Query("SELECT u FROM AccountInformation u WHERE u.accountNumber = :accountNumber AND u.accountHolderName = :accountHolderName") 28 | AccountInformation findByAccountNumberAndName(String accountNumber, String accountHolderName); 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/constants/AccountDetailsConstants.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.constants; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class AccountDetailsConstants { 6 | 7 | public static final String BANK_VI_NAME = "Bank of Bharat"; 8 | public static final String BANK_VI_BRANCH = "Bank of Bharat - Bhopal Indian Central Branch"; 9 | public static final String BANK_VI_ROUTING = "Bank of Bharat - Bhopal City Branch 456 Park Road MP Nagar Bhopal, 462011 India"; 10 | public static final String BANK_VI_STATUS = "002"; 11 | public static final String BANK_VI_ACCOUNT_CREATED = "YOUR ACCOUNT HAS BEEN CREATED SUCCESSFULLY !! "; 12 | public static final String BANK_VI_ACCOUNT_BALANCE_STATUS = "Your Current Balance"; 13 | public static final String BANK_VI_ACCOUNT_BALANCE_CREDIT = "Money Has Been Credited Successfully !!"; 14 | public static final String BANK_VI_ACCOUNT_BALANCE_DEBITED = "Money Has Been Debited Successfully !!"; 15 | public static final String TWILIO_ACCOUNT_SID = "ACd43b45b461dafda49453b040eab3a27f"; 16 | public static final String TWILIO_AUTH_TOKEN = "0e5f6c2b2bf9508cf17e96f8d2170316"; 17 | public static final String TWILIO_PHONE_NUMBER = "+12313594081"; 18 | public static final String BANK_V2_CREDIT = "CREDIT"; 19 | public static final String BANK_V2_DEBIT = "DEBIT"; 20 | public static final String BANK_V3_NOTA_UPI_ID = "This account does not have a UPI ID."; 21 | public static final String BANK_V3_UPI_CREATED = "Your UPI ID has been successfully created !!"; 22 | public static final String SUCCESS_PAY_MONEY_FROM_UPI = "Payment Successfully !!"; 23 | public static final String SUCCESS_STATUS = "SUCCESS !!"; 24 | public static final String SUCCESS_ADD_MONEY_TO_UPI_FROM_MAIN_ACCOUNT = "Your Money Hass been added to your upi account successfully !!"; 25 | public static final String MONEY_SEND_SUCCESSFULLY = "Money Has Been Send Successfully, Thank Your For Using Bank Of Bharat !!"; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/AccountService.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service; 2 | 3 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountManually; 4 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountResponse; 5 | import com.syc.finance.v1.bharat.utils.AccountDeletedSuccessResponse; 6 | import com.syc.finance.v1.bharat.dto.*; 7 | import com.syc.finance.v1.bharat.dto.Accounts.*; 8 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquireyRequest; 9 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquiryResponse; 10 | import com.syc.finance.v1.bharat.dto.Credit.CreditCredential; 11 | import com.syc.finance.v1.bharat.dto.Credit.CreditResponse; 12 | import com.syc.finance.v1.bharat.dto.Debit.DebitCredential; 13 | import com.syc.finance.v1.bharat.dto.Debit.DebitedResponse; 14 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountRequest; 15 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountResponse; 16 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIRequest; 17 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIResponse; 18 | 19 | import javax.security.auth.login.AccountNotFoundException; 20 | 21 | public interface AccountService { 22 | 23 | UserResponse createAccount(UserRequest userRequest); 24 | AccountUpdateDetailsResponse updateAccountDetails(AccountUpdatingDetailsRequest accountUpdatingDetailsRequest) throws AccountNotFoundException; 25 | AccountDeletedSuccessResponse deleteAccount(AccountDeleteAccountDetailsRequest accountDeleteAccountDetailsRequest); 26 | AccountDetailsResponse getYourAccountDetails(String accountNumber , String IFSCCode , String password); 27 | CreditResponse creditYourMoney(CreditCredential creditCredential); 28 | DebitedResponse debitYourMoney(DebitCredential debitCredential); 29 | BalanceEnquiryResponse balanceEnquiry(BalanceEnquireyRequest balanceEnquireyRequest); 30 | AddMoneyFromAccountToUPIResponse payUsingUpi(AddMoneyFromAccountToUPIRequest addMoneyFromAccountToUPIRequest); 31 | AddMoneyToUPIFromAccountResponse addingMoneyFromAccountNumberToUpi(AddMoneyToUPIFromAccountRequest addMoneyToUPIFromAccountRequest); 32 | UpdateAmountResponse updateAmountInPerson(UpdateAmountManually updateAmountManually); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/TransactionService/TransactionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service.TransactionService; 2 | 3 | import com.syc.finance.v1.bharat.mapper.TransactionToTransactionResponse; 4 | import com.syc.finance.v1.bharat.dto.Accounts.Transaction.TransactionResponse; 5 | import com.syc.finance.v1.bharat.dto.Transaction.TransactionRequest; 6 | import com.syc.finance.v1.bharat.entity.TransactionDetailsHistory; 7 | import com.syc.finance.v1.bharat.repository.TransactionHistoryRepository; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.time.LocalDateTime; 13 | import java.util.List; 14 | import java.util.stream.Collectors; 15 | 16 | @Service 17 | @Slf4j 18 | public class TransactionServiceImpl implements TransactionService{ 19 | 20 | @Autowired 21 | private TransactionHistoryRepository transactionHistoryRepository; 22 | 23 | @Override 24 | public void saveTransaction(TransactionRequest transactionRequest) { 25 | TransactionDetailsHistory transactionHistory = new TransactionDetailsHistory(); 26 | transactionHistory.setTransactionId(transactionRequest.getTransactionId()); 27 | transactionHistory.setAccountNumber(transactionRequest.getAccountNumber()); 28 | transactionHistory.setIfscCode(transactionRequest.getIfscCode()); 29 | transactionHistory.setLocalDateTime(transactionRequest.getLocalDateTime()); 30 | transactionHistory.setDebitedOrCredited(transactionRequest.getDebitedOrCredited()); 31 | transactionHistory.setDebitOrCreditMoney(transactionRequest.getDebitOrCreditMoney()); 32 | transactionHistoryRepository.save(transactionHistory); 33 | } 34 | 35 | @Override 36 | public List getAllTransaction(String accountNumber) { 37 | List transactionDetailsHistories = transactionHistoryRepository.findAllByAccountNumberAndIfscCode(accountNumber); 38 | 39 | return transactionDetailsHistories.stream() 40 | .map(TransactionToTransactionResponse::transactionToResponse) 41 | .collect(Collectors.toList()); 42 | } 43 | 44 | @Override 45 | public long countTransactionsByAccountNumberAndTimestamp(String accountNumber, LocalDateTime startTimestamp, LocalDateTime endTimestamp) { 46 | return transactionHistoryRepository.countByAccountNumberAndLocalDateTimeBetween(accountNumber, startTimestamp, endTimestamp); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.1.4 9 | 10 | 11 | com.syc.finance.v1.bharat 12 | Bank-Application 13 | 0.0.1-SNAPSHOT 14 | Bank-Application 15 | Bank Of Bharat 16 | 17 | 17 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | 26 | com.twilio.sdk 27 | twilio 28 | 9.0.0-rc.6 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-mail 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-web 38 | 39 | 40 | 41 | com.mysql 42 | mysql-connector-j 43 | runtime 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | true 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.jetbrains 57 | annotations 58 | 24.0.1 59 | compile 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | org.projectlombok 72 | lombok 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/notification/NotificationsUtility.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.notification; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | 9 | @Slf4j 10 | @Component 11 | public class NotificationsUtility { 12 | 13 | NotificationConfig notificationConfig = new NotificationConfig(); 14 | 15 | public void sendForUPIIdCreation(String upiId) { 16 | String messageBody = "Your UPI has been created successfully: " + upiId; 17 | notificationConfig.sendSMS(messageBody); 18 | } 19 | 20 | public void sendForNetBankingCreationAlert() { 21 | String messageBody = "You have requested the creation of a UPI ID. Note: To create a UPI ID, you need to first create a NetBanking ID, and then you can proceed."; 22 | notificationConfig.sendSMS(messageBody); 23 | } 24 | 25 | public void sendForUpdateAccountDetails(String accountNumber) { 26 | String messageBody = "Your account details have been successfully updated at Bank of Bharat. Account Holder's Name: " + accountNumber; 27 | notificationConfig.sendSMS(messageBody); 28 | } 29 | 30 | public void sendForTwilionLogin() { 31 | String se = "https://www.twilio.com/try-twilio"; 32 | String messageBody = "This Application is in the production phase. For now, if you want all updates and notifications about money " + 33 | "transactions and account creation, please log in to this link : " + se + "using your mobile number." + 34 | " Note that your mobile number should be the same as the one associated with your bank account." ; 35 | notificationConfig.sendSMS(messageBody); 36 | } 37 | 38 | public void sendForDeletedAccount() { 39 | String messageBody = "Your Account has been deleted successfully !!"; 40 | notificationConfig.sendSMS(messageBody); 41 | } 42 | 43 | 44 | public void sendForNetBankingCreation() { 45 | String messageBody = "Your NetBanking-ID has been created successfully, Proceeding for UPI-ID creation, Congratulation"; 46 | notificationConfig.sendSMS(messageBody); 47 | } 48 | 49 | public void sendForCredit(String accountNumber, double accountBalance, String phoneNumber) { 50 | String messageBody = "Dear Customer, Your money has been Debited from your account " + accountNumber + ", and this transaction" + 51 | " has been successfully completed. Current Balance : " + accountBalance; 52 | notificationConfig.sendSMS(messageBody); 53 | } 54 | 55 | public void sendForDebitedAccount(String accountNumber, double accountBalance, String phoneNumber) { 56 | String messageBody = "Dear Customer, Your money has been Credited from your account " + accountNumber + ", and this transaction" + 57 | " has been successfully completed. Current Balance : " + accountBalance; 58 | notificationConfig.sendSMS(messageBody); 59 | } 60 | 61 | public void ssendForCreateAccountNotification(String accountHolderName) { 62 | String messageBody = "Your account has been successfully created at Bank of Bharat, " + 63 | "and your bank account number is: " + accountHolderName; 64 | notificationConfig.sendSMS(messageBody); 65 | } 66 | 67 | public void sendForBalanceEnquiry(String accountNumber, double accountBalance, String phoneNumber){ 68 | String messageBody = "Dear Customer, Your account balance for account number " + 69 | accountNumber + " is " + accountBalance + "\n" + LocalDateTime.now(); 70 | notificationConfig.sendSMS(messageBody); 71 | } 72 | 73 | public void sendForHighAmountOfMoneyTransfer(){ 74 | String messageBody = "Dear customer, you have recently made a high-value transaction. " + 75 | "If you did not authorize this transaction, please contact us at 626-676-9479. "; 76 | notificationConfig.sendSMS(messageBody); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/exceptions/handler/GlobalExceptionHandling.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.exceptions.handler; 2 | 3 | import com.syc.finance.v1.bharat.exceptions.*; 4 | import com.twilio.exception.ApiException; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestControllerAdvice; 9 | 10 | import static com.syc.finance.v1.bharat.utils.AccountDetailsForExceptionalHandler.REJECTED; 11 | 12 | @RestControllerAdvice 13 | public class GlobalExceptionHandling { 14 | 15 | @ExceptionHandler(EmailAlreadyExistStep.class) 16 | ResponseEntity emailAlreadyExistException(EmailAlreadyExistStep ex) { 17 | ErrorResponses errorResponses = new ErrorResponses(); 18 | errorResponses.setErrorMessage(ex.getMessage()); 19 | errorResponses.setStatus(REJECTED); 20 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 21 | } 22 | 23 | @ExceptionHandler(PhoneNumberAlreadyExistStep.class) 24 | ResponseEntity phoneAlreadyExistException(PhoneNumberAlreadyExistStep ex) { 25 | ErrorResponses errorResponses = new ErrorResponses(); 26 | errorResponses.setErrorMessage(ex.getMessage()); 27 | errorResponses.setStatus(REJECTED); 28 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 29 | } 30 | 31 | @ExceptionHandler(DailyLimitExceed.class) 32 | ResponseEntity phoneAlreadyExistException(DailyLimitExceed ex) { 33 | ErrorResponses errorResponses = new ErrorResponses(); 34 | errorResponses.setErrorMessage(ex.getMessage()); 35 | errorResponses.setStatus(REJECTED); 36 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 37 | } 38 | 39 | @ExceptionHandler(DetailsNotFountException.class) 40 | ResponseEntity detailsNotFoundException(DetailsNotFountException ex) { 41 | ErrorResponses errorResponses = new ErrorResponses(); 42 | errorResponses.setErrorMessage(ex.getMessage()); 43 | errorResponses.setStatus(REJECTED); 44 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 45 | } 46 | 47 | @ExceptionHandler(UpiNotFoundException.class) 48 | ResponseEntity upInotFound(UpiNotFoundException ex) { 49 | ErrorResponses errorResponses = new ErrorResponses(); 50 | errorResponses.setErrorMessage(ex.getMessage()); 51 | errorResponses.setStatus(REJECTED); 52 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 53 | } 54 | 55 | 56 | @ExceptionHandler(NetBankingIdAlreadyExist.class) 57 | ResponseEntity netBankingIdAlreadyExistException(NetBankingIdAlreadyExist ex) { 58 | ErrorResponses errorResponses = new ErrorResponses(); 59 | errorResponses.setErrorMessage(ex.getMessage()); 60 | errorResponses.setStatus(REJECTED); 61 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 62 | } 63 | 64 | @ExceptionHandler(NotHavingNetbanking.class) 65 | ResponseEntity netBankingAccountNotPresent(NotHavingNetbanking ex) { 66 | ErrorResponses errorResponses = new ErrorResponses(); 67 | errorResponses.setErrorMessage(ex.getMessage()); 68 | errorResponses.setStatus(REJECTED); 69 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 70 | } 71 | 72 | @ExceptionHandler(InSufficientBalance.class) 73 | ResponseEntity inSufficientFunds(InSufficientBalance ex) { 74 | ErrorResponses errorResponses = new ErrorResponses(); 75 | errorResponses.setErrorMessage(ex.getMessage()); 76 | errorResponses.setStatus(REJECTED); 77 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 78 | } 79 | 80 | 81 | @ExceptionHandler(UpiAlreadyExist.class) 82 | ResponseEntity upiAlreadyExist(UpiAlreadyExist ex) { 83 | ErrorResponses errorResponses = new ErrorResponses(); 84 | errorResponses.setErrorMessage(ex.getMessage()); 85 | errorResponses.setStatus(REJECTED); 86 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 87 | } 88 | 89 | @ExceptionHandler(ApiException.class) 90 | ResponseEntity apiExceptionHandling(ApiException ex) { 91 | ErrorResponses errorResponses = new ErrorResponses(); 92 | errorResponses.setErrorMessage(ex.getMessage()); 93 | errorResponses.setStatus(REJECTED); 94 | return new ResponseEntity(HttpStatus.CREATED); 95 | } 96 | 97 | @ExceptionHandler(AccountBalanceMinimumSteps.class) 98 | ResponseEntity accountBalanceExist(AccountBalanceMinimumSteps ex) { 99 | ErrorResponses errorResponses = new ErrorResponses(); 100 | errorResponses.setErrorMessage(ex.getMessage()); 101 | errorResponses.setStatus(REJECTED); 102 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 103 | } 104 | 105 | @ExceptionHandler(AccountNotFoundStep.class) 106 | ResponseEntity accountNotFound(AccountNotFoundStep ex) { 107 | ErrorResponses errorResponses = new ErrorResponses(); 108 | errorResponses.setErrorMessage(ex.getMessage()); 109 | errorResponses.setStatus(REJECTED); 110 | return new ResponseEntity<>(errorResponses, HttpStatus.FORBIDDEN); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/controller/AccountController.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.controller; 2 | 3 | 4 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountManually; 5 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountResponse; 6 | import com.syc.finance.v1.bharat.utils.AccountDeletedSuccessResponse; 7 | import com.syc.finance.v1.bharat.dto.*; 8 | import com.syc.finance.v1.bharat.dto.Accounts.*; 9 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquireyRequest; 10 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquiryResponse; 11 | import com.syc.finance.v1.bharat.dto.Credit.CreditCredential; 12 | import com.syc.finance.v1.bharat.dto.Credit.CreditResponse; 13 | import com.syc.finance.v1.bharat.dto.Debit.DebitCredential; 14 | import com.syc.finance.v1.bharat.dto.Debit.DebitedResponse; 15 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountRequest; 16 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountResponse; 17 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIRequest; 18 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIResponse; 19 | import com.syc.finance.v1.bharat.service.AccountService; 20 | import com.syc.finance.v1.bharat.service.TransactionService.TransactionService; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.http.HttpStatus; 23 | import org.springframework.http.ResponseEntity; 24 | import org.springframework.web.bind.annotation.*; 25 | 26 | import javax.security.auth.login.AccountNotFoundException; 27 | 28 | @RestController 29 | @RequestMapping("finance/v1/bank/v4/bharat") 30 | 31 | @CrossOrigin(origins = "http://localhost:4200/") 32 | public class AccountController { 33 | 34 | @Autowired 35 | private AccountService userService; 36 | 37 | @Autowired 38 | private TransactionService transactionService; 39 | 40 | @PostMapping("/create-account") 41 | ResponseEntity createYourAccount(@RequestBody UserRequest userRequest){ 42 | UserResponse userResponse = userService.createAccount(userRequest); 43 | return new ResponseEntity(userResponse , HttpStatus.CREATED); 44 | } 45 | 46 | @PutMapping("/update-account-details") 47 | ResponseEntity updateAnAccountDetails(@RequestBody AccountUpdatingDetailsRequest accountDetailsRequest){ 48 | AccountUpdateDetailsResponse accountUpdateDetailsResponse = null; 49 | try { 50 | accountUpdateDetailsResponse = userService.updateAccountDetails(accountDetailsRequest); 51 | } catch (AccountNotFoundException e) { 52 | throw new RuntimeException(e); 53 | } 54 | return new ResponseEntity(accountUpdateDetailsResponse, HttpStatus.CREATED); 55 | } 56 | 57 | @DeleteMapping("/delete-account") 58 | ResponseEntity deleteAccount(@RequestBody AccountDeleteAccountDetailsRequest accountDetailsRequest){ 59 | AccountDeletedSuccessResponse accountDeletedSuccessResponse = userService.deleteAccount(accountDetailsRequest); 60 | return new ResponseEntity(accountDeletedSuccessResponse , HttpStatus.ACCEPTED); 61 | } 62 | @GetMapping("/get-account-details/{accountNumber}/{IFSCCode}/{password}") 63 | ResponseEntity getAccountDetails(@PathVariable String accountNumber, 64 | @PathVariable String IFSCCode, 65 | @PathVariable String password){ 66 | 67 | AccountDetailsResponse accountDetailsResponse = userService.getYourAccountDetails(accountNumber , IFSCCode , password); 68 | return new ResponseEntity(accountDetailsResponse , HttpStatus.ACCEPTED); 69 | } 70 | 71 | @GetMapping("/balance-enquiry") 72 | ResponseEntity balanceMoney(@RequestBody BalanceEnquireyRequest balanceEnquireyRequest){ 73 | BalanceEnquiryResponse response = userService.balanceEnquiry(balanceEnquireyRequest); 74 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 75 | } 76 | 77 | @GetMapping("/credit-money") 78 | ResponseEntity creditMoney(@RequestBody CreditCredential creditCredential){ 79 | CreditResponse response = userService.creditYourMoney(creditCredential); 80 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 81 | } 82 | 83 | @GetMapping("/debit-money") 84 | ResponseEntity debitMoney(@RequestBody DebitCredential balanceEnquireyRequest){ 85 | DebitedResponse response = userService.debitYourMoney(balanceEnquireyRequest); 86 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 87 | } 88 | 89 | // upi 90 | 91 | @PostMapping("/pay-money-from-upi") 92 | ResponseEntity payFromUpiId(@RequestBody AddMoneyFromAccountToUPIRequest addMoneyFromAccountToUPIRequest){ 93 | AddMoneyFromAccountToUPIResponse response = userService.payUsingUpi(addMoneyFromAccountToUPIRequest); 94 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 95 | } 96 | 97 | @PostMapping("/add-money-to-upi-from-bank") 98 | ResponseEntity payTo(@RequestBody AddMoneyToUPIFromAccountRequest addMoneyToUPIFromAccountRequest){ 99 | AddMoneyToUPIFromAccountResponse response = userService.addingMoneyFromAccountNumberToUpi(addMoneyToUPIFromAccountRequest); 100 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 101 | } 102 | 103 | @PutMapping("/update/money") 104 | ResponseEntity addMoneyInPerson(@RequestBody UpdateAmountManually updateAmountManually){ 105 | UpdateAmountResponse response = userService.updateAmountInPerson(updateAmountManually); 106 | return new ResponseEntity(response , HttpStatus.ACCEPTED); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.2.0 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 164 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 165 | " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 166 | " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 167 | " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 168 | " exit 1;"^ 169 | "}"^ 170 | "}" 171 | if ERRORLEVEL 1 goto error 172 | ) 173 | 174 | @REM Provide a "standardized" way to retrieve the CLI args that will 175 | @REM work with both Windows and non-Windows executions. 176 | set MAVEN_CMD_LINE_ARGS=%* 177 | 178 | %MAVEN_JAVA_EXE% ^ 179 | %JVM_CONFIG_MAVEN_PROPS% ^ 180 | %MAVEN_OPTS% ^ 181 | %MAVEN_DEBUG_OPTS% ^ 182 | -classpath %WRAPPER_JAR% ^ 183 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 184 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 185 | if ERRORLEVEL 1 goto error 186 | goto end 187 | 188 | :error 189 | set ERROR_CODE=1 190 | 191 | :end 192 | @endlocal & set ERROR_CODE=%ERROR_CODE% 193 | 194 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 195 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 196 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 197 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 198 | :skipRcPost 199 | 200 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 201 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 202 | 203 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 204 | 205 | cmd /C exit /B %ERROR_CODE% 206 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.2.0 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ] ; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ] ; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ] ; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ] ; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false; 54 | darwin=false; 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true;; 59 | Darwin*) darwin=true 60 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 61 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 62 | if [ -z "$JAVA_HOME" ]; then 63 | if [ -x "/usr/libexec/java_home" ]; then 64 | JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME 65 | else 66 | JAVA_HOME="/Library/Java/Home"; export JAVA_HOME 67 | fi 68 | fi 69 | ;; 70 | esac 71 | 72 | if [ -z "$JAVA_HOME" ] ; then 73 | if [ -r /etc/gentoo-release ] ; then 74 | JAVA_HOME=$(java-config --jre-home) 75 | fi 76 | fi 77 | 78 | # For Cygwin, ensure paths are in UNIX format before anything is touched 79 | if $cygwin ; then 80 | [ -n "$JAVA_HOME" ] && 81 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 82 | [ -n "$CLASSPATH" ] && 83 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 84 | fi 85 | 86 | # For Mingw, ensure paths are in UNIX format before anything is touched 87 | if $mingw ; then 88 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && 89 | JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" 90 | fi 91 | 92 | if [ -z "$JAVA_HOME" ]; then 93 | javaExecutable="$(which javac)" 94 | if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then 95 | # readlink(1) is not available as standard on Solaris 10. 96 | readLink=$(which readlink) 97 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 98 | if $darwin ; then 99 | javaHome="$(dirname "\"$javaExecutable\"")" 100 | javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" 101 | else 102 | javaExecutable="$(readlink -f "\"$javaExecutable\"")" 103 | fi 104 | javaHome="$(dirname "\"$javaExecutable\"")" 105 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 106 | JAVA_HOME="$javaHome" 107 | export JAVA_HOME 108 | fi 109 | fi 110 | fi 111 | 112 | if [ -z "$JAVACMD" ] ; then 113 | if [ -n "$JAVA_HOME" ] ; then 114 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 115 | # IBM's JDK on AIX uses strange locations for the executables 116 | JAVACMD="$JAVA_HOME/jre/sh/java" 117 | else 118 | JAVACMD="$JAVA_HOME/bin/java" 119 | fi 120 | else 121 | JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" 122 | fi 123 | fi 124 | 125 | if [ ! -x "$JAVACMD" ] ; then 126 | echo "Error: JAVA_HOME is not defined correctly." >&2 127 | echo " We cannot execute $JAVACMD" >&2 128 | exit 1 129 | fi 130 | 131 | if [ -z "$JAVA_HOME" ] ; then 132 | echo "Warning: JAVA_HOME environment variable is not set." 133 | fi 134 | 135 | # traverses directory structure from process work directory to filesystem root 136 | # first directory with .mvn subdirectory is considered project base directory 137 | find_maven_basedir() { 138 | if [ -z "$1" ] 139 | then 140 | echo "Path not specified to find_maven_basedir" 141 | return 1 142 | fi 143 | 144 | basedir="$1" 145 | wdir="$1" 146 | while [ "$wdir" != '/' ] ; do 147 | if [ -d "$wdir"/.mvn ] ; then 148 | basedir=$wdir 149 | break 150 | fi 151 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 152 | if [ -d "${wdir}" ]; then 153 | wdir=$(cd "$wdir/.." || exit 1; pwd) 154 | fi 155 | # end of workaround 156 | done 157 | printf '%s' "$(cd "$basedir" || exit 1; pwd)" 158 | } 159 | 160 | # concatenates all lines of a file 161 | concat_lines() { 162 | if [ -f "$1" ]; then 163 | # Remove \r in case we run on Windows within Git Bash 164 | # and check out the repository with auto CRLF management 165 | # enabled. Otherwise, we may read lines that are delimited with 166 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 167 | # splitting rules. 168 | tr -s '\r\n' ' ' < "$1" 169 | fi 170 | } 171 | 172 | log() { 173 | if [ "$MVNW_VERBOSE" = true ]; then 174 | printf '%s\n' "$1" 175 | fi 176 | } 177 | 178 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 179 | if [ -z "$BASE_DIR" ]; then 180 | exit 1; 181 | fi 182 | 183 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR 184 | log "$MAVEN_PROJECTBASEDIR" 185 | 186 | ########################################################################################## 187 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 188 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 189 | ########################################################################################## 190 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 191 | if [ -r "$wrapperJarPath" ]; then 192 | log "Found $wrapperJarPath" 193 | else 194 | log "Couldn't find $wrapperJarPath, downloading it ..." 195 | 196 | if [ -n "$MVNW_REPOURL" ]; then 197 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 198 | else 199 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 200 | fi 201 | while IFS="=" read -r key value; do 202 | # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) 203 | safeValue=$(echo "$value" | tr -d '\r') 204 | case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; 205 | esac 206 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 207 | log "Downloading from: $wrapperUrl" 208 | 209 | if $cygwin; then 210 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 211 | fi 212 | 213 | if command -v wget > /dev/null; then 214 | log "Found wget ... using wget" 215 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 216 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 217 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 218 | else 219 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 220 | fi 221 | elif command -v curl > /dev/null; then 222 | log "Found curl ... using curl" 223 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 224 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 225 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 226 | else 227 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 228 | fi 229 | else 230 | log "Falling back to using Java to download" 231 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 232 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 233 | # For Cygwin, switch paths to Windows format before running javac 234 | if $cygwin; then 235 | javaSource=$(cygpath --path --windows "$javaSource") 236 | javaClass=$(cygpath --path --windows "$javaClass") 237 | fi 238 | if [ -e "$javaSource" ]; then 239 | if [ ! -e "$javaClass" ]; then 240 | log " - Compiling MavenWrapperDownloader.java ..." 241 | ("$JAVA_HOME/bin/javac" "$javaSource") 242 | fi 243 | if [ -e "$javaClass" ]; then 244 | log " - Running MavenWrapperDownloader.java ..." 245 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 246 | fi 247 | fi 248 | fi 249 | fi 250 | ########################################################################################## 251 | # End of extension 252 | ########################################################################################## 253 | 254 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 255 | wrapperSha256Sum="" 256 | while IFS="=" read -r key value; do 257 | case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; 258 | esac 259 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 260 | if [ -n "$wrapperSha256Sum" ]; then 261 | wrapperSha256Result=false 262 | if command -v sha256sum > /dev/null; then 263 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then 264 | wrapperSha256Result=true 265 | fi 266 | elif command -v shasum > /dev/null; then 267 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then 268 | wrapperSha256Result=true 269 | fi 270 | else 271 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." 272 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." 273 | exit 1 274 | fi 275 | if [ $wrapperSha256Result = false ]; then 276 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 277 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 278 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 279 | exit 1 280 | fi 281 | fi 282 | 283 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 284 | 285 | # For Cygwin, switch paths to Windows format before running java 286 | if $cygwin; then 287 | [ -n "$JAVA_HOME" ] && 288 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 289 | [ -n "$CLASSPATH" ] && 290 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 291 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 292 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 293 | fi 294 | 295 | # Provide a "standardized" way to retrieve the CLI args that will 296 | # work with both Windows and non-Windows executions. 297 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 298 | export MAVEN_CMD_LINE_ARGS 299 | 300 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 301 | 302 | # shellcheck disable=SC2086 # safe args 303 | exec "$JAVACMD" \ 304 | $MAVEN_OPTS \ 305 | $MAVEN_DEBUG_OPTS \ 306 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 307 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 308 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 309 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/UpiAndNetBanking/UPIAndNetNetBankingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service.UpiAndNetBanking; 2 | 3 | import com.syc.finance.v1.bharat.notification.NotificationsUtility; 4 | import com.syc.finance.v1.bharat.utils.InternetBankingIdGenerator; 5 | import com.syc.finance.v1.bharat.utils.UPIDGenerater; 6 | import com.syc.finance.v1.bharat.dto.InternetBanking.GetNetBankingRequest; 7 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingRequest; 8 | import com.syc.finance.v1.bharat.dto.InternetBanking.NetBankingResponse; 9 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyRequest; 10 | import com.syc.finance.v1.bharat.dto.TransferMoney.TransferMoneyResponse; 11 | import com.syc.finance.v1.bharat.dto.UPI.GetUPIRequest; 12 | import com.syc.finance.v1.bharat.dto.UPI.UPIRequest; 13 | import com.syc.finance.v1.bharat.dto.UPI.UPIResponse; 14 | import com.syc.finance.v1.bharat.entity.AccountInformation; 15 | import com.syc.finance.v1.bharat.entity.NetBankingInformation; 16 | import com.syc.finance.v1.bharat.entity.UpiInformation; 17 | import com.syc.finance.v1.bharat.exceptions.*; 18 | import com.syc.finance.v1.bharat.repository.AccountDetailsRepositories; 19 | import com.syc.finance.v1.bharat.repository.NetBankingRepositories; 20 | import com.syc.finance.v1.bharat.repository.UPIDetailsRepositories; 21 | import lombok.extern.slf4j.Slf4j; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.stereotype.Service; 24 | 25 | import java.time.LocalDateTime; 26 | import java.util.UUID; 27 | 28 | import static com.syc.finance.v1.bharat.constants.AccountDetailsConstants.*; 29 | 30 | 31 | @Service 32 | @Slf4j 33 | public class UPIAndNetNetBankingServiceImpl implements UPIAndNetBankingService { 34 | 35 | @Autowired 36 | private UPIDetailsRepositories upiDetailsRepositories; 37 | 38 | @Autowired 39 | private AccountDetailsRepositories accountDetailsRepositories; 40 | 41 | @Autowired 42 | private NetBankingRepositories netBankingRepositories; 43 | 44 | @Autowired 45 | private NotificationsUtility notificationsUtility; 46 | 47 | @Override 48 | public UPIResponse upiCreate(UPIRequest upiRequest) { 49 | 50 | AccountInformation accountInfo = accountDetailsRepositories.findByAccountIdAndIfscCode(upiRequest.getAccountNumber(), 51 | upiRequest.getIfscCode(), upiRequest.getPassword()); 52 | 53 | NetBankingInformation existingNetBanking = netBankingRepositories.findByAccountIdAndIfscCode( 54 | upiRequest.getAccountNumber(), 55 | upiRequest.getIfscCode()); 56 | 57 | if (accountInfo != null) { 58 | 59 | if (existingNetBanking == null) { 60 | 61 | notificationsUtility.sendForNetBankingCreationAlert(); 62 | throw new NotHavingNetbanking("Account need to create a net banking ID first in order to be able to create a UPI ID."); 63 | 64 | } else { 65 | 66 | UPIDGenerater upidGenerater = new UPIDGenerater(); 67 | String isUpiPresentInAccount = accountInfo.getIsHaveUpiId(); 68 | 69 | String UPI_GENERATED_ID = UUID.randomUUID().toString(); 70 | String UPI_ID = upidGenerater.generateUpiId(accountInfo.getAccountHolderName()); 71 | String UPI_CODE = upidGenerater.generatePin(); 72 | 73 | if (BANK_V3_NOTA_UPI_ID.equals(isUpiPresentInAccount)) { 74 | 75 | UPIResponse response = new UPIResponse(); 76 | response.setAccountNumber(accountInfo.getAccountNumber()); 77 | response.setContactNumber(accountInfo.getContactPhone()); 78 | response.setContactEmail(accountInfo.getContactEmail()); 79 | response.setUpiId(UPI_ID); 80 | response.setUpiId(UPI_CODE); 81 | response.setUPI_BALANCE(0.0); 82 | response.setResponseMessage(BANK_V3_UPI_CREATED); 83 | 84 | UpiInformation upiInformation = new UpiInformation(); 85 | upiInformation.setGlobalId(UPI_GENERATED_ID); 86 | upiInformation.setAccountNumber(accountInfo.getAccountNumber()); 87 | upiInformation.setIfscCode(accountInfo.getIfscCode()); 88 | upiInformation.setBankPassword(accountInfo.getPassword()); 89 | upiInformation.setContactNumber(accountInfo.getContactPhone()); 90 | upiInformation.setContactEmail(accountInfo.getContactEmail()); 91 | upiInformation.setUpiId(UPI_ID); 92 | upiInformation.setUPI_CODE(UPI_CODE); 93 | upiInformation.setUPI_BALANCE(0.0); 94 | upiInformation.setResponseMessage(BANK_V3_UPI_CREATED); 95 | 96 | upiDetailsRepositories.save(upiInformation); 97 | 98 | accountInfo.setIsHaveUpiId("YES"); 99 | accountDetailsRepositories.save(accountInfo); 100 | 101 | notificationsUtility.sendForUPIIdCreation(response.getUpiId()); 102 | 103 | return response; 104 | 105 | } else { 106 | 107 | throw new UpiAlreadyExist("Your account number and IFSC code are already linked to a UPI ID"); 108 | } 109 | } 110 | } 111 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 112 | } 113 | 114 | @Override 115 | public NetBankingResponse createNetBanking(NetBankingRequest netBankingRequest) { 116 | 117 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode( 118 | netBankingRequest.getAccountNumber(), 119 | netBankingRequest.getIfscCode(), 120 | netBankingRequest.getPassword() 121 | ); 122 | 123 | if(accountInformation != null){ 124 | 125 | NetBankingResponse netBankingResponse = new NetBankingResponse(); 126 | 127 | NetBankingInformation existingNetBanking = netBankingRepositories.findByAccountIdAndIfscCode( 128 | netBankingRequest.getAccountNumber(), 129 | netBankingRequest.getIfscCode()); 130 | 131 | if (existingNetBanking == null) { 132 | 133 | InternetBankingIdGenerator internetBankingIdGenerator = new InternetBankingIdGenerator(); 134 | NetBankingInformation netBankingResponseEntity = new NetBankingInformation(); 135 | 136 | netBankingResponse.setNetId(UUID.randomUUID().toString()); 137 | netBankingResponse.setAccountHolderName(accountInformation.getAccountHolderName()); 138 | netBankingResponse.setAccountNumber(accountInformation.getAccountNumber()); 139 | netBankingResponse.setIfscCode(accountInformation.getIfscCode()); 140 | netBankingResponse.setLocalDateTime(LocalDateTime.now()); 141 | netBankingResponse.setNet_BANKING_ID(internetBankingIdGenerator.generateInternetBankingId()); 142 | 143 | netBankingResponseEntity.setNetId(netBankingResponse.getNetId()); 144 | netBankingResponseEntity.setAccountHolderName(netBankingResponse.getAccountHolderName()); 145 | netBankingResponseEntity.setAccountNumber(netBankingResponse.getAccountNumber()); 146 | netBankingResponseEntity.setIfscCode(netBankingResponse.getIfscCode()); 147 | netBankingResponseEntity.setLocalDateTime(netBankingResponse.getLocalDateTime()); 148 | netBankingResponseEntity.setNet_BANKING_ID(netBankingResponse.getNet_BANKING_ID()); 149 | netBankingResponseEntity.setPassword(netBankingRequest.getPassword()); 150 | 151 | notificationsUtility.sendForNetBankingCreation(); 152 | 153 | netBankingRepositories.save(netBankingResponseEntity); 154 | return netBankingResponse; 155 | 156 | } else { 157 | throw new NetBankingIdAlreadyExist("You already have a bank ID. If you've forgotten it, please contact our support team.."); 158 | } 159 | } 160 | 161 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 162 | } 163 | 164 | @Override 165 | public UPIResponse getYourUpiInInfo(GetUPIRequest upiRequest) { 166 | 167 | UpiInformation upiInformation = upiDetailsRepositories.findByAccountNumberAndPassword(upiRequest.getAccountNumber() 168 | , upiRequest.getBankPassword()); 169 | 170 | if(upiInformation != null){ 171 | 172 | UPIResponse response = new UPIResponse(); 173 | response.setAccountNumber(upiInformation.getAccountNumber()); 174 | response.setContactNumber(upiInformation.getContactNumber()); 175 | response.setContactEmail(upiInformation.getContactEmail()); 176 | response.setUpiId(upiInformation.getUpiId()); 177 | response.setUPI_CODE(upiInformation.getUPI_CODE()); 178 | response.setUPI_BALANCE(upiInformation.getUPI_BALANCE()); 179 | response.setResponseMessage(upiInformation.getResponseMessage()); 180 | return response; 181 | } 182 | throw new DetailsNotFountException("Details Not Found.."); 183 | } 184 | 185 | @Override 186 | public NetBankingResponse getYourNetBankingInfo(GetNetBankingRequest netBankingRequest) { 187 | 188 | NetBankingInformation netBankingInformation = netBankingRepositories.findByAccountIdAndIfscCode(netBankingRequest.getAccountNumber() 189 | , netBankingRequest.getIfscCode()); 190 | 191 | if(netBankingInformation != null){ 192 | 193 | NetBankingResponse response = new NetBankingResponse(); 194 | response.setNetId(netBankingInformation.getNetId()); 195 | response.setAccountHolderName(netBankingInformation.getAccountHolderName()); 196 | response.setAccountNumber(netBankingInformation.getAccountNumber()); 197 | response.setIfscCode(netBankingInformation.getIfscCode()); 198 | response.setLocalDateTime(netBankingInformation.getLocalDateTime()); 199 | response.setNet_BANKING_ID(netBankingInformation.getNet_BANKING_ID()); 200 | return response; 201 | } 202 | 203 | throw new DetailsNotFountException("Details Not Found.."); 204 | } 205 | 206 | @Override 207 | public TransferMoneyResponse moneyTransferAccountToAccount(TransferMoneyRequest transferMoneyRequest) { 208 | 209 | AccountInformation accountInformationForRecipient = accountDetailsRepositories.findByAccountNumberAndName( 210 | transferMoneyRequest.getFullNameOfRecipient(), 211 | transferMoneyRequest.getAccountNumberOfRecipient()); 212 | 213 | AccountInformation accountInformationForSender = accountDetailsRepositories.findByAccountNumber( 214 | transferMoneyRequest.getAccountNumberOfSender()); 215 | 216 | if(accountInformationForRecipient != null && accountInformationForSender != null){ 217 | 218 | //senders money 219 | double sendersMoney = transferMoneyRequest.getTransferAmount(); 220 | 221 | if(sendersMoney >= 10000){ 222 | 223 | // need to pass the phoneNumber in below methods 224 | notificationsUtility.sendForHighAmountOfMoneyTransfer(); 225 | 226 | double sendersBankAccount = accountInformationForSender.getAccountBalance() - sendersMoney; 227 | 228 | accountInformationForSender.setAccountBalance(sendersBankAccount); 229 | accountDetailsRepositories.save(accountInformationForSender); 230 | 231 | //recipients money 232 | double recipientMoney = accountInformationForRecipient.getAccountBalance(); 233 | double recdBankAccount = sendersMoney + recipientMoney; 234 | 235 | accountInformationForRecipient.setAccountBalance(recdBankAccount); 236 | accountDetailsRepositories.save(accountInformationForRecipient); 237 | 238 | //response 239 | TransferMoneyResponse transferMoneyResponse = new TransferMoneyResponse(); 240 | transferMoneyResponse.setResponseMessage(MONEY_SEND_SUCCESSFULLY); 241 | return transferMoneyResponse; 242 | 243 | } 244 | else{ 245 | 246 | double sendersBankAccount = accountInformationForSender.getAccountBalance() - sendersMoney; 247 | 248 | accountInformationForSender.setAccountBalance(sendersBankAccount); 249 | accountDetailsRepositories.save(accountInformationForSender); 250 | 251 | //recipients money 252 | double recipientMoney = accountInformationForRecipient.getAccountBalance(); 253 | double recdBankAccount = sendersMoney + recipientMoney; 254 | 255 | accountInformationForRecipient.setAccountBalance(recdBankAccount); 256 | accountDetailsRepositories.save(accountInformationForRecipient); 257 | 258 | //response 259 | TransferMoneyResponse transferMoneyResponse = new TransferMoneyResponse(); 260 | transferMoneyResponse.setResponseMessage(MONEY_SEND_SUCCESSFULLY); 261 | return transferMoneyResponse; 262 | } 263 | 264 | } 265 | 266 | else { 267 | 268 | throw new DetailsNotFountException("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 269 | } 270 | 271 | } 272 | } 273 | 274 | -------------------------------------------------------------------------------- /src/main/java/com/syc/finance/v1/bharat/service/AccountServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.syc.finance.v1.bharat.service; 2 | 3 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountManually; 4 | import com.syc.finance.v1.bharat.dto.Update.UpdateAmountResponse; 5 | import com.syc.finance.v1.bharat.mapper.MapperToResponse; 6 | import com.syc.finance.v1.bharat.mapper.MapperToUpdateResponse; 7 | import com.syc.finance.v1.bharat.notification.*; 8 | import com.syc.finance.v1.bharat.utils.AccountDeletedSuccessResponse; 9 | import com.syc.finance.v1.bharat.utils.AccountDetailsGenarators; 10 | import com.syc.finance.v1.bharat.utils.AccountlLimitReached; 11 | import com.syc.finance.v1.bharat.dto.*; 12 | import com.syc.finance.v1.bharat.dto.Accounts.*; 13 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquireyRequest; 14 | import com.syc.finance.v1.bharat.dto.BalanceEnquiry.BalanceEnquiryResponse; 15 | import com.syc.finance.v1.bharat.dto.Credit.CreditCredential; 16 | import com.syc.finance.v1.bharat.dto.Credit.CreditResponse; 17 | import com.syc.finance.v1.bharat.dto.Debit.DebitCredential; 18 | import com.syc.finance.v1.bharat.dto.Debit.DebitedResponse; 19 | import com.syc.finance.v1.bharat.dto.Transaction.TransactionRequest; 20 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountRequest; 21 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyToUPIFromAccountResponse; 22 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIRequest; 23 | import com.syc.finance.v1.bharat.dto.UPIPay.AddMoneyFromAccountToUPIResponse; 24 | import com.syc.finance.v1.bharat.entity.AccountInformation; 25 | import com.syc.finance.v1.bharat.entity.NetBankingInformation; 26 | 27 | import static com.syc.finance.v1.bharat.constants.AccountDetailsConstants.*; 28 | 29 | import com.syc.finance.v1.bharat.entity.UpiInformation; 30 | import com.syc.finance.v1.bharat.exceptions.*; 31 | import com.syc.finance.v1.bharat.repository.TransactionHistoryRepository; 32 | import com.syc.finance.v1.bharat.repository.AccountDetailsRepositories; 33 | import com.syc.finance.v1.bharat.repository.UPIDetailsRepositories; 34 | import com.syc.finance.v1.bharat.service.TransactionService.TransactionService; 35 | import com.twilio.Twilio; 36 | import lombok.extern.slf4j.Slf4j; 37 | import org.springframework.beans.factory.annotation.Autowired; 38 | import org.springframework.stereotype.Service; 39 | 40 | import java.time.LocalDate; 41 | import java.time.LocalDateTime; 42 | import java.util.Optional; 43 | import java.util.UUID; 44 | 45 | 46 | @Service 47 | @Slf4j 48 | public class AccountServiceImpl implements AccountService { 49 | 50 | @Autowired 51 | private AccountDetailsRepositories accountDetailsRepositories; 52 | @Autowired 53 | private TransactionHistoryRepository transactionHistoryRepository; 54 | @Autowired 55 | private UPIDetailsRepositories upiDetailsRepositories; 56 | @Autowired 57 | private TransactionService transactionService; 58 | @Autowired 59 | private AccountlLimitReached accountlLimitReached; 60 | @Autowired 61 | private NotificationsUtility notificationsUtility; 62 | 63 | 64 | static { 65 | Twilio.init(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN); 66 | } 67 | 68 | @Override 69 | public UserResponse createAccount(UserRequest userRequest) { 70 | 71 | log.info("Creating a new account."); 72 | 73 | String userIdGenerated = UUID.randomUUID().toString(); 74 | MapperToResponse mapperToResponse = new MapperToResponse(); 75 | 76 | Optional existingEmail = Optional.ofNullable(accountDetailsRepositories.findByContactEmail(userRequest.getContactEmail())); 77 | Optional existingPhone = Optional.ofNullable(accountDetailsRepositories.findByContactPhoneNumber(userRequest.getContactPhone())); 78 | 79 | if (existingEmail.isPresent()) { 80 | throw new EmailAlreadyExistStep("Email Already Exist. "); 81 | 82 | } else if (existingPhone.isPresent()) { 83 | 84 | throw new PhoneNumberAlreadyExistStep("Phone Number Already Exist. "); 85 | 86 | } else { 87 | 88 | AccountDetailsGenarators accountDetailsGenarators = new AccountDetailsGenarators(); 89 | 90 | String IFSC_CODE = accountDetailsGenarators.gereratedIFSC(); 91 | String BANK_PIN = accountDetailsGenarators.generateBankCode(); 92 | String PASSWORD = accountDetailsGenarators.generatePin(); 93 | 94 | AccountInformation accountInformation = AccountInformation.builder() 95 | .accountId(userIdGenerated) 96 | .accountHolderName(userRequest.getAccountHolderName()) 97 | .contactEmail(userRequest.getContactEmail()) 98 | .contactPhone(userRequest.getContactPhone()) 99 | .gender(userRequest.getGender()) 100 | .isHaveUpiId(BANK_V3_NOTA_UPI_ID) 101 | .contactAddress(userRequest.getContactAddress()) 102 | .stateOfOrigin(userRequest.getStateOfOrigin()) 103 | .pinCodeNumber(userRequest.getPinCodeNumber()) 104 | .currentLocation(userRequest.getCurrentLocation()) 105 | .designation(userRequest.getDesignation()) 106 | .country(userRequest.getCountry()) 107 | .password(PASSWORD) 108 | .bankName(BANK_VI_NAME) 109 | .bankBranch(BANK_VI_BRANCH) 110 | .routingNumber(BANK_VI_ROUTING) 111 | .accountType(userRequest.getAccountType()) 112 | .status(BANK_VI_STATUS) 113 | .localDateTime(LocalDateTime.now()) 114 | .accountOpenDate(LocalDate.now()) 115 | .accountNumber(accountDetailsGenarators.generateAccountNumber()) 116 | .ifscCode("BOBI" + IFSC_CODE) 117 | .bankPinCode(BANK_PIN) 118 | .build(); 119 | 120 | notificationsUtility.sendForTwilionLogin(); 121 | notificationsUtility.ssendForCreateAccountNotification(accountInformation.getAccountHolderName()); 122 | accountDetailsRepositories.save(accountInformation); 123 | 124 | UserResponse userRes = mapperToResponse.userInformationToUserResponse(accountInformation); 125 | userRes.setMessage(BANK_VI_ACCOUNT_CREATED); 126 | 127 | log.info("Account created successfully for user: {}", userRes.getAccountHolderName()); 128 | return userRes; 129 | 130 | } 131 | } 132 | 133 | 134 | @Override 135 | public AccountUpdateDetailsResponse updateAccountDetails(AccountUpdatingDetailsRequest accountUpdatingDetailsRequest) { 136 | 137 | log.info("Updating account details for account number: {}", accountUpdatingDetailsRequest.getAccountNumber()); 138 | 139 | Optional userInformation = Optional.ofNullable(accountDetailsRepositories.findByAccountNumber( 140 | accountUpdatingDetailsRequest.getAccountNumber())); 141 | 142 | if (userInformation.isPresent()) { 143 | log.info("User information found for account number: {}", accountUpdatingDetailsRequest.getAccountNumber()); 144 | 145 | log.info("Updating account details for account holder: {}", accountUpdatingDetailsRequest.getAccountHolderName()); 146 | AccountInformation updateAccountDetails = AccountInformation.builder() 147 | .accountHolderName(accountUpdatingDetailsRequest.getAccountHolderName()) 148 | .contactPhone(accountUpdatingDetailsRequest.getContactPhone()) 149 | .contactEmail(accountUpdatingDetailsRequest.getContactEmail()) 150 | .accountType(accountUpdatingDetailsRequest.getAccountType()) 151 | .contactAddress(accountUpdatingDetailsRequest.getContactAddress()) 152 | .stateOfOrigin(accountUpdatingDetailsRequest.getStateOfOrigin()) 153 | .pinCodeNumber(accountUpdatingDetailsRequest.getPinCodeNumber()) 154 | .currentLocation(accountUpdatingDetailsRequest.getCurrentLocation()) 155 | .designation(accountUpdatingDetailsRequest.getDesignation()) 156 | .country(accountUpdatingDetailsRequest.getCountry()) 157 | .accountType(accountUpdatingDetailsRequest.getAccountType()) 158 | .localDateTime(LocalDateTime.now()) 159 | .build(); 160 | 161 | 162 | log.info("Account details updated successfully for account holder: {}", accountUpdatingDetailsRequest.getAccountHolderName()); 163 | 164 | notificationsUtility.sendForUpdateAccountDetails(accountUpdatingDetailsRequest.getAccountHolderName()); 165 | accountDetailsRepositories.save(updateAccountDetails); 166 | MapperToUpdateResponse mapperToUpdateResponse = new MapperToUpdateResponse(); 167 | 168 | return mapperToUpdateResponse.userInformationToUpdateAccountResponse(updateAccountDetails); 169 | 170 | } else 171 | 172 | log.info("Account not found for account number: {}", accountUpdatingDetailsRequest.getAccountNumber()); 173 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 174 | } 175 | 176 | 177 | @Override 178 | public AccountDeletedSuccessResponse deleteAccount(AccountDeleteAccountDetailsRequest accountDetailsRequest) { 179 | log.info("Deleting account with account number: {}", accountDetailsRequest.getAccountNumber()); 180 | 181 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode( 182 | accountDetailsRequest.getAccountNumber(), 183 | accountDetailsRequest.getContactEmail(), 184 | accountDetailsRequest.getPassword() 185 | ); 186 | 187 | if (accountInformation != null) { 188 | log.info("Account found for deletion: {}", accountInformation); 189 | 190 | accountDetailsRepositories.delete(accountInformation); 191 | log.info("Account deleted for account number: {}", accountDetailsRequest.getAccountNumber()); 192 | 193 | notificationsUtility.sendForDeletedAccount(); 194 | log.info("Account deletion notification sent"); 195 | 196 | return new AccountDeletedSuccessResponse("Account deleted successfully."); 197 | } else { 198 | log.info("Account not found for deletion. Account details: AccountNumber={}, ContactEmail={}, Password={}", 199 | accountDetailsRequest.getAccountNumber(), accountDetailsRequest.getContactEmail(), accountDetailsRequest.getPassword()); 200 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 201 | } 202 | } 203 | 204 | 205 | @Override 206 | public AccountDetailsResponse getYourAccountDetails(String accountNumber, String IFSCCode, String password) { 207 | 208 | log.info("Getting account details for accountNumber: {}", accountNumber); 209 | 210 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode(accountNumber 211 | , IFSCCode, password); 212 | AccountDetailsResponse accountDetailsResponse = new AccountDetailsResponse(); 213 | 214 | if (accountInformation != null) { 215 | log.info("Account details found for accountNumber: {}", accountNumber); 216 | 217 | accountDetailsResponse.setAccountId(accountInformation.getAccountId()); 218 | accountDetailsResponse.setAccountHolderName(accountInformation.getAccountHolderName()); 219 | accountDetailsResponse.setContactEmail(accountInformation.getContactEmail()); 220 | accountDetailsResponse.setContactPhone(accountInformation.getContactPhone()); 221 | accountDetailsResponse.setGender(accountInformation.getGender()); 222 | accountDetailsResponse.setContactAddress(accountInformation.getContactAddress()); 223 | accountDetailsResponse.setStateOfOrigin(accountInformation.getStateOfOrigin()); 224 | accountDetailsResponse.setPinCodeNumber(accountInformation.getPinCodeNumber()); 225 | accountDetailsResponse.setCurrentLocation(accountInformation.getCurrentLocation()); 226 | accountDetailsResponse.setDesignation(accountInformation.getDesignation()); 227 | accountDetailsResponse.setCountry(accountInformation.getCountry()); 228 | accountDetailsResponse.setAccountNumber(accountInformation.getAccountNumber()); 229 | accountDetailsResponse.setIfscCode(accountInformation.getIfscCode()); 230 | accountDetailsResponse.setBankName(accountInformation.getBankName()); 231 | accountDetailsResponse.setBankBranch(accountInformation.getBankBranch()); 232 | accountDetailsResponse.setRoutingNumber(accountInformation.getRoutingNumber()); 233 | accountDetailsResponse.setAccountType(accountInformation.getAccountType()); 234 | accountDetailsResponse.setAccountBalance(accountInformation.getAccountBalance()); 235 | accountDetailsResponse.setStatus(accountInformation.getStatus()); 236 | accountDetailsResponse.setLocalDateTime(LocalDateTime.now()); 237 | accountDetailsResponse.setAccountOpenDate(LocalDate.now()); 238 | 239 | NetBankingInformation netBankingInformation = new NetBankingInformation(); 240 | 241 | accountDetailsResponse.setPassword(netBankingInformation.getPassword()); 242 | accountDetailsResponse.setNet_BANKING_ID(netBankingInformation.getNet_BANKING_ID()); 243 | 244 | // need to fix 245 | UpiInformation upiInformation = new UpiInformation(); 246 | 247 | accountDetailsResponse.setUPI_ID(upiInformation.getUpiId()); 248 | accountDetailsResponse.setUPI_BALANCE(upiInformation.getUPI_BALANCE()); 249 | 250 | return accountDetailsResponse; 251 | } else { 252 | 253 | log.info("Account not found for accountNumber: {}", accountNumber); 254 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 255 | } 256 | } 257 | 258 | @Override 259 | public CreditResponse creditYourMoney(CreditCredential creditCredential) { 260 | 261 | log.info("Crediting money for account number: {}", creditCredential.getAccountNumber()); 262 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode(creditCredential.getAccountNumber(), 263 | creditCredential.getIfscCode(), creditCredential.getPassword()); 264 | 265 | if (accountInformation != null) { 266 | log.info("Account found for crediting money. Account Number: {}", creditCredential.getAccountNumber()); 267 | 268 | // transaction limit reached 269 | accountlLimitReached.validateDailyTransactionLimit(accountInformation); 270 | 271 | double creditedAmount = creditCredential.getCreditYourMoney(); 272 | double currentBalance = accountInformation.getAccountBalance() + creditedAmount; 273 | 274 | accountInformation.setAccountBalance(currentBalance); 275 | accountInformation = accountDetailsRepositories.save(accountInformation); 276 | 277 | creditCredential.setCreditYourMoney(accountInformation.getAccountBalance()); 278 | String autoGeneratedId = UUID.randomUUID().toString(); 279 | 280 | notificationsUtility.sendForDebitedAccount(accountInformation.getAccountNumber(), 281 | accountInformation.getAccountBalance(), accountInformation.getContactPhone()); 282 | 283 | CreditResponse addingMoney = new CreditResponse(); 284 | 285 | TransactionRequest transactionRequest = new TransactionRequest(); 286 | transactionRequest.setTransactionId(autoGeneratedId); 287 | transactionRequest.setDebitedOrCredited(BANK_V2_CREDIT); 288 | transactionRequest.setAccountNumber(accountInformation.getAccountNumber()); 289 | transactionRequest.setDebitOrCreditMoney(creditedAmount); 290 | transactionRequest.setLocalDateTime(LocalDateTime.now()); 291 | 292 | transactionService.saveTransaction(transactionRequest); 293 | addingMoney.setCreditId(autoGeneratedId); 294 | addingMoney.setAccountHolderName(accountInformation.getAccountHolderName()); 295 | addingMoney.setAccountNumber(accountInformation.getAccountNumber()); 296 | addingMoney.setIfscCode(accountInformation.getIfscCode()); 297 | addingMoney.setBankName(accountInformation.getBankName()); 298 | addingMoney.setStatusMoney(BANK_VI_ACCOUNT_BALANCE_CREDIT); 299 | addingMoney.setLocalDateTime(LocalDateTime.now()); 300 | addingMoney.setCurrentBalance(currentBalance); 301 | 302 | log.info("Money credited successfully for account number: {}. Current balance: {}", creditCredential.getAccountNumber(), currentBalance); 303 | return addingMoney; 304 | 305 | } else 306 | 307 | log.info("Account not found for crediting money. Account details: AccountNumber={}, IFSCCode={}, Password={}", 308 | creditCredential.getAccountNumber(), creditCredential.getIfscCode(), creditCredential.getPassword()); 309 | 310 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 311 | 312 | } 313 | 314 | @Override 315 | public DebitedResponse debitYourMoney(DebitCredential debitCredential) { 316 | 317 | log.info("Account found for debiting money. Account Number: {}", debitCredential.getAccountNumber()); 318 | 319 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode( 320 | debitCredential.getAccountNumber(), debitCredential.getIfscCode(), debitCredential.getPassword()); 321 | 322 | if (accountInformation != null) { 323 | double debitedAmount = debitCredential.getDebitYourMoney(); 324 | 325 | accountlLimitReached.validateDailyTransactionLimit(accountInformation); 326 | 327 | if (debitedAmount >= 10000) { 328 | log.info("High amount of money transfer. Account Balance: {}, Debited Amount: {}", accountInformation.getAccountBalance(), debitedAmount); 329 | 330 | double currentBalance = accountInformation.getAccountBalance() - debitedAmount; 331 | 332 | if (currentBalance >= debitedAmount) { 333 | 334 | notificationsUtility.sendForHighAmountOfMoneyTransfer(); 335 | accountInformation.setAccountBalance(currentBalance); 336 | accountInformation = accountDetailsRepositories.save(accountInformation); 337 | debitCredential.setDebitYourMoney(accountInformation.getAccountBalance()); 338 | String autoGeneratedId = UUID.randomUUID().toString(); 339 | 340 | notificationsUtility.sendForCredit(accountInformation.getAccountNumber(), 341 | accountInformation.getAccountBalance(), accountInformation.getContactPhone()); 342 | 343 | DebitedResponse miniMoney = new DebitedResponse(); 344 | TransactionRequest transactionRequest = new TransactionRequest(); 345 | transactionRequest.setTransactionId(autoGeneratedId); 346 | transactionRequest.setDebitedOrCredited(BANK_V2_DEBIT); 347 | transactionRequest.setLocalDateTime(LocalDateTime.now()); 348 | transactionRequest.setAccountNumber(accountInformation.getAccountNumber()); 349 | transactionRequest.setDebitOrCreditMoney(debitedAmount); 350 | transactionService.saveTransaction(transactionRequest); 351 | 352 | miniMoney.setDebitedId(autoGeneratedId); 353 | miniMoney.setAccountHolderName(accountInformation.getAccountHolderName()); 354 | miniMoney.setAccountNumber(accountInformation.getAccountNumber()); 355 | miniMoney.setIfscCode(accountInformation.getIfscCode()); 356 | miniMoney.setStatusDebit(BANK_VI_ACCOUNT_BALANCE_DEBITED); 357 | miniMoney.setLocalDateTime(LocalDateTime.now()); 358 | miniMoney.setCurrentBalance(currentBalance); 359 | miniMoney.setDebitYourMoney(debitedAmount); 360 | 361 | log.info("Money debited successfully for account number: {}. Current balance: {}", debitCredential.getAccountNumber(), currentBalance); 362 | return miniMoney; 363 | 364 | } else { 365 | 366 | log.info("Insufficient balance to complete the transaction. Account Balance: {}, Debited Amount: {}", accountInformation.getAccountBalance(), debitedAmount); 367 | throw new InSufficientBalance("Insufficient balance to complete the transaction."); 368 | } 369 | } else { 370 | 371 | debitedAmount = debitCredential.getDebitYourMoney(); 372 | double currentBalance = accountInformation.getAccountBalance() - debitedAmount; 373 | 374 | if (currentBalance >= debitedAmount) { 375 | accountInformation.setAccountBalance(currentBalance); 376 | accountInformation = accountDetailsRepositories.save(accountInformation); 377 | debitCredential.setDebitYourMoney(accountInformation.getAccountBalance()); 378 | String autoGeneratedId = UUID.randomUUID().toString(); 379 | 380 | notificationsUtility.sendForCredit(accountInformation.getAccountNumber(), 381 | accountInformation.getAccountBalance(), accountInformation.getContactPhone()); 382 | 383 | DebitedResponse miniMoney = new DebitedResponse(); 384 | TransactionRequest transactionRequest = new TransactionRequest(); 385 | transactionRequest.setTransactionId(autoGeneratedId); 386 | transactionRequest.setDebitedOrCredited(BANK_V2_DEBIT); 387 | transactionRequest.setLocalDateTime(LocalDateTime.now()); 388 | transactionRequest.setAccountNumber(accountInformation.getAccountNumber()); 389 | transactionRequest.setDebitOrCreditMoney(debitedAmount); 390 | transactionService.saveTransaction(transactionRequest); 391 | 392 | miniMoney.setDebitedId(autoGeneratedId); 393 | miniMoney.setAccountHolderName(accountInformation.getAccountHolderName()); 394 | miniMoney.setAccountNumber(accountInformation.getAccountNumber()); 395 | miniMoney.setIfscCode(accountInformation.getIfscCode()); 396 | miniMoney.setStatusDebit(BANK_VI_ACCOUNT_BALANCE_DEBITED); 397 | miniMoney.setLocalDateTime(LocalDateTime.now()); 398 | miniMoney.setCurrentBalance(currentBalance); 399 | miniMoney.setDebitYourMoney(debitedAmount); 400 | 401 | log.info("Money debited successfully for account number: {}. Current balance: {}", debitCredential.getAccountNumber(), currentBalance); 402 | return miniMoney; 403 | } 404 | } 405 | } 406 | 407 | log.info("Account not found for debiting money. Account details: AccountNumber={}, IFSCCode={}, Password={}", 408 | debitCredential.getAccountNumber(), debitCredential.getIfscCode(), debitCredential.getPassword()); 409 | 410 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 411 | } 412 | 413 | 414 | @Override 415 | public BalanceEnquiryResponse balanceEnquiry(BalanceEnquireyRequest balanceEnquireyRequest) { 416 | log.info("Received request for balance enquiry: {}", balanceEnquireyRequest); 417 | 418 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountIdAndIfscCode( 419 | balanceEnquireyRequest.getAccountNumber(), 420 | balanceEnquireyRequest.getIfscCode(), 421 | balanceEnquireyRequest.getPassword() 422 | ); 423 | 424 | log.info("Account information found for the request."); 425 | 426 | NotificationsUtility notificationsUtility = new NotificationsUtility(); 427 | notificationsUtility.sendForBalanceEnquiry(accountInformation.getAccountNumber(), 428 | accountInformation.getAccountBalance(), accountInformation.getContactPhone()); 429 | 430 | log.info("Sent balance enquiry notification."); 431 | 432 | String balanceId = UUID.randomUUID().toString(); 433 | BalanceEnquiryResponse response = new BalanceEnquiryResponse(); 434 | response.setBalanceId(balanceId); 435 | response.setAccountNumber(accountInformation.getAccountNumber()); 436 | response.setStatusMessage(BANK_VI_ACCOUNT_BALANCE_STATUS); 437 | response.setYourBalance(accountInformation.getAccountBalance()); 438 | response.setLocalDateTime(LocalDateTime.now()); 439 | 440 | log.info("Balance enquiry successful."); 441 | 442 | return response; 443 | } 444 | 445 | 446 | // adding money from account balance to UPI, account -> UPI 447 | @Override 448 | public AddMoneyFromAccountToUPIResponse payUsingUpi(AddMoneyFromAccountToUPIRequest addMoneyFromAccountToUPIRequest) { 449 | log.info("Received request to pay using UPI: {}", addMoneyFromAccountToUPIRequest); 450 | 451 | AccountInformation accountInformation = accountDetailsRepositories.findByAccountNumber(addMoneyFromAccountToUPIRequest.getAccountNumber()); 452 | UpiInformation upiInformation = upiDetailsRepositories.findByUpiId(addMoneyFromAccountToUPIRequest.getUpiId()); 453 | 454 | if (upiInformation != null && accountInformation != null) { 455 | log.info("UPI and account information found for the request."); 456 | 457 | accountlLimitReached.validateDailyTransactionLimit(accountInformation); 458 | log.info("Validated daily transaction limit for the account."); 459 | 460 | if (accountInformation.getAccountBalance() > addMoneyFromAccountToUPIRequest.getPayMoney()) { 461 | double getFromUPI = addMoneyFromAccountToUPIRequest.getPayMoney(); 462 | double fromMainAccount = accountInformation.getAccountBalance(); 463 | double leftMoneyForMainAccount = fromMainAccount - getFromUPI; 464 | 465 | accountInformation.setAccountBalance(leftMoneyForMainAccount); 466 | accountDetailsRepositories.save(accountInformation); 467 | 468 | upiInformation.setUPI_BALANCE(getFromUPI); 469 | upiDetailsRepositories.save(upiInformation); 470 | 471 | AddMoneyFromAccountToUPIResponse payUsingUpiResponse = new AddMoneyFromAccountToUPIResponse(); 472 | payUsingUpiResponse.setResponseMessage(SUCCESS_PAY_MONEY_FROM_UPI); 473 | payUsingUpiResponse.setStatus(SUCCESS_STATUS); 474 | 475 | log.info("Payment using UPI successful."); 476 | 477 | return payUsingUpiResponse; 478 | } else { 479 | log.error("Insufficient balance for the payment."); 480 | throw new InSufficientBalance("Insufficient Balance.."); 481 | } 482 | } else { 483 | log.error("UPI or account information not found for the request."); 484 | throw new DetailsNotFountException("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 485 | } 486 | } 487 | 488 | 489 | public AddMoneyToUPIFromAccountResponse addingMoneyFromAccountNumberToUpi(AddMoneyToUPIFromAccountRequest addMoneyToUPIFromAccountRequest) { 490 | log.info("Adding money from account number {} to UPI {}.", addMoneyToUPIFromAccountRequest.getAccountNumber(), addMoneyToUPIFromAccountRequest.getUpiId()); 491 | 492 | AccountInformation accountInformation = accountDetailsRepositories 493 | .findByAccountNumberAndPassword( 494 | addMoneyToUPIFromAccountRequest.getAccountNumber(), 495 | addMoneyToUPIFromAccountRequest.getPassword()); 496 | 497 | UpiInformation upiInformation = upiDetailsRepositories.findByUpiId(addMoneyToUPIFromAccountRequest.getUpiId()); 498 | 499 | try { 500 | 501 | 502 | if (accountInformation != null && upiInformation != null) { 503 | log.info("Account and UPI found for the transaction."); 504 | 505 | accountlLimitReached.validateDailyTransactionLimit(accountInformation); 506 | 507 | double moneyGetFromMainAccount = accountInformation.getAccountBalance(); 508 | 509 | double gettingMoneyFromUpi = addMoneyToUPIFromAccountRequest.getAddedFromUpi(); 510 | double adding = moneyGetFromMainAccount + gettingMoneyFromUpi; 511 | 512 | accountInformation.setAccountBalance(adding); 513 | 514 | accountDetailsRepositories.save(accountInformation); 515 | 516 | AddMoneyToUPIFromAccountResponse addMoneyToUPIFromAccountResponse = new AddMoneyToUPIFromAccountResponse(); 517 | addMoneyToUPIFromAccountResponse.setStatus(SUCCESS_ADD_MONEY_TO_UPI_FROM_MAIN_ACCOUNT); 518 | 519 | log.info("Money added successfully from account number {} to UPI {}.", addMoneyToUPIFromAccountRequest.getAccountNumber(), addMoneyToUPIFromAccountRequest.getUpiId()); 520 | 521 | return addMoneyToUPIFromAccountResponse; 522 | } 523 | 524 | } catch (NullPointerException e) { 525 | 526 | log.warn("NullPointerException occurred: {}", e.getMessage()); 527 | log.warn("There is no records..."); 528 | 529 | System.out.println("There is no records..."); 530 | } 531 | 532 | log.info("Account or UPI not found for the transaction. AccountNumber={}, UPIId={}", addMoneyToUPIFromAccountRequest.getAccountNumber(), addMoneyToUPIFromAccountRequest.getUpiId()); 533 | 534 | throw new AccountNotFoundStep("The details you have entered are incorrect. There is no account with these details. Please double-check the information and try again."); 535 | } 536 | 537 | @Override 538 | public UpdateAmountResponse updateAmountInPerson(UpdateAmountManually updateAmountManually) { 539 | 540 | log.info("Updating amount in person for account number: {}", updateAmountManually.getAccountNumber()); 541 | 542 | AccountInformation accountInformation = accountDetailsRepositories 543 | .findByAccountNumber(updateAmountManually.getAccountNumber()); 544 | 545 | if (accountInformation != null) { 546 | 547 | log.info("Account found for updating amount in person. Account Number: {}", updateAmountManually.getAccountNumber()); 548 | accountInformation.setAccountBalance(updateAmountManually.getAccountBalance()); 549 | accountDetailsRepositories.save(accountInformation); 550 | 551 | log.info("Account balance updated in person. New balance: {}", updateAmountManually.getAccountBalance()); 552 | } else { 553 | 554 | log.info("Account not found for updating amount in person. Account Number: {}", updateAmountManually.getAccountNumber()); 555 | 556 | throw new AccountNotFoundStep("The details you have entered are incorrect. " + 557 | "There is no account with these details. Please double-check the information and try again."); 558 | } 559 | 560 | UpdateAmountResponse updateAmountResponse = new UpdateAmountResponse(); 561 | updateAmountResponse.setMessage("In person, an ATM has credited your account, adding a physical touch to your financial update."); 562 | return updateAmountResponse; 563 | } 564 | } 565 | 566 | 567 | 568 | --------------------------------------------------------------------------------