0% found this document useful (0 votes)
33 views43 pages

Credit Card Fraud Detection

Uploaded by

ramsrini533
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views43 pages

Credit Card Fraud Detection

Uploaded by

ramsrini533
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

CREDIT CARD FRAUD DETECTION

21CSC206P-ADVANCED OBJECT ORIENTED PROGRAMMING


A MINI-PROJECT REPORT
Submitted By
R.Kishore [RA2311027020066]
Praneeth.V.P [RA2311027020125]
Prashant [RA2311027050012]
in partial fulfilment for the award of the degree
of
BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE AND ENGINEERING
With
Big Data Analytics
Of
FACULTY OF ENGINEERING AND TECHNOLOGY

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY RAMAPURAM


CAMPUS, CHENNAI-600089
OCTOBER 2024
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

(Deemed to be University U/S 3 of UGC Act, 1956)

BONAFIDE CERTIFICATE

Certified that this mini project report titled “CREDIT CARD FRAUD DETECTION
USING JAVA” is the bonafide work of “R.Kishore(RA2311027020066),
V.P.Praneeth(RA2311027020125), Prashant(RA2311027050012)”,who carried
out the project work under my supervision.Certified further,that to the best of
my knowledge,the work reported here in does not form any other project
report or disseratation on the basis of which a degree or award was conferred
on an occasion on this or any other candidate.

SIGNATURE SIGNATURE

Dr.Visnu Dharsini Dr.K.Raja , M.E.,Ph.D.,


Assitant Professor Professor and Head
Computer Science and Engineering, Computer Science and Engineering,

SRM Institute of Science and Technology, SRM Institute of Science and Technology,

Ramapuram,Chennai. Ramapuram,Chennai.
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
RAMAPURAM, CHENNAI -600089
DECLARATION

We hereby declare that the entire work contained in this mini project report
titled “THREAD MANAGEMENT” has been carried out by
“R.Kishore(RA2311027020066),V.P.Praneeth(RA2311027020125),
Prashant(RA2311027050012)” at SRM Institute of Science and Technology,
Ramapuram Campus, Chennai - 600089,

Place: Chennai

Date:
TABLE OF CONTENT

1. Abstract
2. Introduction
3. Problem Statement
4. Objective
5. Scope of Project
6.Problems in the Existing Solution
7. Proposed Solution
8. System Modules
9. Architect Diagram
10. Coding and Output
ABSTRACT

This report focuses on the development and


implementation of a secure credit card transaction
management system using Java and Java Persistence
API (JPA) for database interactions. The system
facilitates credit card transaction processing by defining
and managing critical transaction attributes such as the
credit card number, user ID, transaction amount, and
transaction date. The system ensures secure user
authentication, validates credit card details, checks
available balances, and incorporates a fraud detection
mechanism. Additionally, it features a user-friendly
graphical user interface (GUI) that enables users to
input transaction details, which are then validated
before being processed. The validation layer also plays
a crucial role in detecting potentially fraudulent
transactions.
INTRODUCTION

The rapid growth of digital transactions has


significantly increased the reliance on credit card
payments. As financial institutions and e-
commerce platforms expand their online services,
the need for robust systems that can manage and
secure credit card transactions becomes essential.
Handling user information, securing transactions,
and ensuring real-time fraud detection are critical
components of such systems.

Java Enterprise technologies, particularly JPA,


provide a reliable foundation for building secure,
scalable, and efficient transaction systems. These
technologies allow seamless database interactions
while managing complex logic for user
authentication, transaction validation, and security.
PROBLEM STATEMENT

In traditional credit card transaction systems,


challenges like insecure transactions, inefficient
fraud detection, and complicated user interfaces
persist. Such systems often lack the automation
required to streamline transaction processing and
require significant manual oversight, leading to
errors and inefficiencies.

The absence of advanced fraud detection


mechanisms exposes users and financial
institutions to security breaches and fraudulent
activities. Furthermore, users often face difficulty
navigating complex interfaces, impacting the
overall experience and transaction accuracy.
OBJECTIVE

The primary goal of this project is to develop a


secure, automated, and user-friendly system for
processing credit card transactions. The system
should allow users to submit transaction details,
validate credit card information, check balances,
and prevent fraudulent activities in real-time. It
should also ensure secure communication between
the application and the database, facilitating
seamless and protected interactions.
SCOPE OF THE PROJECT

The system is designed to address several critical


aspects of credit card transaction management:

1.User Input: Enable users to input transaction


details such as card number, transaction
amount, and user credentials.

2.Balance Check: Validate transaction amounts


against available credit balances to prevent
overdrafts.

3.Fraud Detection: Implement real-time fraud


detection through monitoring transaction
frequency, amount, and other relevant
parameters.
4.Security: Securely store and process sensitive
data like credit card numbers and personal
information using robust encryption
techniques.

5.User Interface: Provide an intuitive, easy-to-


navigate GUI that simplifies transaction input
and feedback.

6.Notification System: Integrate email or SMS


notifications for transaction updates, fraud
alerts, or suspicious activity.
Problems in the Existing System

1.Manual Transaction Processing: Existing


systems often require manual input and
validation, increasing the likelihood of human
error and delays in transaction processing.
2.Lack of Comprehensive Fraud Detection:
Many traditional systems fail to implement
real-time fraud detection algorithms, leaving
transactions vulnerable to malicious activities.
3.Security Vulnerabilities: Outdated security
protocols and weak validation processes lead
to insecure transactions, potentially exposing
sensitive user data.
4.Unintuitive Interfaces: Complex and poorly
designed user interfaces make it difficult for
users to perform transactions quickly and
accurately.
Proposed Work

To overcome the limitations of traditional credit


card transaction systems, this project proposes a
solution that automates transaction processing
while enhancing security and fraud detection. Key
features include:
1.Automated Transaction Handling: Using
Java and JPA, the system will manage credit
card transactions and interact securely with the
database to store transaction details.

2.Enhanced Fraud Detection: The system will


utilize algorithms to detect suspicious
transaction patterns, ensuring that fraud is
detected early.

3.User-Friendly GUI: The system will feature


an easy-to-use graphical interface that allows
users to input transactions, view their balance,
and receive immediate feedback on transaction
status.

4.Real-Time Validation: OTP (One-Time


Password) generation, transaction limit
checks, and formula-based validation
techniques will be implemented to secure
transactions.

5.Hadoop Integration for Large-Scale


Analysis: The system will leverage Hadoop
for real-time fraud detection based on large-
scale transaction data.
System Modules

1.User Management:
 Handles user registration and login.
 Stores and retrieves user information,
including user ID, credit card number, and
account balance.

2.Transaction Management:
 Allows users to input transaction details such
as amount and month.
 Records each transaction against the user in
the database
.
3.Validation System:
 Verifies if the transaction amount is within the
allowed balance.
 Uses Hadoop analytics to detect potential
fraud patterns in transactions.
 Generates an OTP for additional validation
during large transactions or suspicious
activities.

4.Credit Card Management:


 Tracks the available balance and credit limit
for each user’s credit card.
 Updates the balance after each transaction,
ensuring the user doesn’t exceed their credit
limit.

5.Hadoop Integration:
 Uses Hadoop analytics to analyze the
frequency and amount of past transactions.
 Helps identify irregular transaction patterns
and block potentially fraudulent transactions.

6.UI Module:
 Provides a graphical interface using Java
Swing for users to interact with the system.
ARCHITECT DIAGRAM

START Open application

Get details
from user

Transaction Fraud
Succe Detected

EXIT
CODING

package com.nura.entity; import


java.io.Serializable; import
javax.persistence.Entity; import
javax.persistence.GeneratedValue; import
javax.persistence.GenerationType; import
javax.persistence.Id; import
javax.persistence.Table; @Entity @Table(name =
"cc_trans") public class CCTransactions
implements Serializable{ @Id
@GeneratedValue(strategy =
GenerationType.IDENTITY) private long seq;
private String ccno; private String userid; private
String transamt; private String month; public
CCTransactions(){ } /** * @return the seq */
public long getSeq() { return seq; } /** * @param
seq the seq to set */ public void setSeq(long seq)
{ this.seq = seq; } /** * @return the ccno */ public
String getCcno() { return ccno; } /** * @param
ccno the ccno to set */ public void setCcno(String
ccno) { this.ccno = ccno; } /** * @return the
userid */ public String getUserid() { return
userid; } /** * @param userid the userid to set */
public void setUserid(String userid) { this.userid =
userid; } /** * @return the transamt */ public
String getTransamt() { return transamt; } /** *
@param transamt the transamt to set */ public void
setTransamt(String transamt) { this.transamt =
transamt; } /** * @return the month */ public
String getMonth() { return month; } /** * @param
month the month to set */ public void
setMonth(String month) { } import
com.nura.dao.impl.CCDtlsDAOImpl; import
com.nura.dao.impl.CCTransDAOImpl; import
com.nura.dao.impl.UserDetailsDAOImpl; import
com.nura.entity.CCDtls; import
com.nura.entity.CCTransactions; import
com.nura.entity.UserDetails; import
com.nura.hadoop.HadoopAnalyzer; import
com.nura.mail.SendMail; import java.io.File;
import java.io.FileInputStream; import
java.io.FileNotFoundException; import
java.io.FileReader; import java.io.IOException;
import java.util.HashMap; import java.util.List;
import java.util.Map; import java.util.Random;
import java.util.Scanner; import
java.util.logging.Level; import
java.util.logging.Logger; import
javax.swing.JOptionPane; public class
TransactionFrame extends javax.swing.JFrame
{ this.month = month; } private CCTransDAOImpl
_ccTransDAOImpl = new CCTransDAOImpl();
private CCDtlsDAOImpl _ccDtlsDAOImpl = new
CCDtlsDAOImpl(); private UserDetails
_usrDtls; /** * Creates new form
TransactionFrame */ public TransactionFrame()
{ } public TransactionFrame(UserDetails _usrDtls)
{ FileInputStream fis = null; initComponents();
this._usrDtls = _usrDtls;
tf_userName.setText(_usrDtls.getUserName());
tf_userName.setEditable(false); // fis = new
FileInputStream(constants.Constants.RFID_READ
ER_FILE); // Scanner scan = new Scanner(fis);
tf_CCno.setText(_usrDtls.getCreditCardNo());
tf_CCno.setEditable(false);
tf_avlBal.setEditable(false); setBalance(); //
fis.close(); } /** * This method is called from
within the constructor to initialize the form. *
WARNING: Do NOT modify this code. The
content of this method is always * regenerated by
the Form Editor. */
@SuppressWarnings("unchecked") // private void
initComponents() { jPanel1 = new
javax.swing.JPanel(); jLabel1 = new
javax.swing.JLabel(); cb_Month = new
javax.swing.JComboBox(); jLabel2 = new
javax.swing.JLabel(); tf_userName = new
javax.swing.JTextField(); jLabel3 = new
javax.swing.JLabel(); tf_amt = new
javax.swing.JTextField(); tf_submit = new
javax.swing.JButton(); tf_cancel = new
javax.swing.JButton(); jLabel5 = new
javax.swing.JLabel(); jLabel6 = new
javax.swing.JLabel(); tf_CCno = new
javax.swing.JTextField(); tf_avlBal = new
javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowCo
nstants.EXIT_ON_CLOSE); jLabel1.setFont(new
java.awt.Font("Times New Roman", 1, 18)); //
NOI18N jLabel1.setText("Select Month:-");
cb_Month.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
cb_Month.setModel(new
javax.swing.DefaultComboBoxModel( constants.C
onstants.MONTHS));
cb_Month.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt)
{ cb_MonthActionPerformed(evt); } });
jLabel2.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N jLabel2.setText("User
Name:-"); tf_userName.setFont(new
java.awt.Font("Times New Roman", 1, 18)); //
NOI18N jLabel3.setFont(new
java.awt.Font("Times New Roman", 1, 18)); //
NOI18N jLabel3.setText("Enter Amount");
tf_amt.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
tf_submit.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
tf_submit.setText("Submit");
tf_submit.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt)
{ tf_submitActionPerformed(evt); } });
tf_cancel.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
tf_cancel.setText("Cancel");
tf_cancel.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt)
{ tf_cancelActionPerformed(evt); } });
jLabel5.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
jLabel5.setText("Credit Card Number:-");
jLabel6.setFont(new java.awt.Font("Times New
Roman", 1, 18)); // NOI18N
jLabel6.setText("Available Balance");
javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Al
ignment.LEADING) .addGroup(jPanel1Layout.cre
ateSequentialGroup() .addGroup(jPanel1Layout.cr
eateParallelGroup(javax.swing.GroupLayout.Alig
nment.
LEADING) .addGroup(jPanel1Layout.createSequ
entialGroup() .addGap(138, 138,
138) .addComponent(tf_submit,
javax.swing.GroupLayout.PREFERRED_SIZE,
147,
javax.swing.GroupLayout.PREFERRED_SIZE) .a
ddPreferredGap(javax.swing.LayoutStyle.Compon
entPlacement.UNRELATED) .addComponent(tf_c
ancel,
javax.swing.GroupLayout.PREFERRED_SIZE,
147,
javax.swing.GroupLayout.PREFERRED_SIZE)) .
addGroup(jPanel1Layout.createSequentialGroup()
.addGap(53, 53,
53) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(jLabel6,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(jLabel5,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(jLabel1,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)) .addGap(67, 67,
67) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(cb_Month, 0, 198,
Short.MAX_VALUE) .addComponent(tf_userNam
e) .addComponent(tf_amt) .addComponent(tf_CC
no) .addComponent(tf_avlBal)))) .addContainerGa
p(91, Short.MAX_VALUE)) );
jPanel1Layout.setVerticalGroup( jPanel1Layout.cr
eateParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING) .addGroup(jPanel1Layout.creat
eSequentialGroup() .addGap(35, 35,
35) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(tf_userNam
e, javax.swing.GroupLayout.DEFAULT_SIZE, 40,
Short.MAX_VALUE)) .addPreferredGap(javax.sw
ing.LayoutStyle.ComponentPlacement.UNRELAT
ED) .addGroup(jPanel1Layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.
LEADING, false) .addComponent(jLabel5,
javax.swing.GroupLayout.DEFAULT_SIZE, 33,
Short.MAX_VALUE) .addComponent(tf_CCno)) .
addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED) .addGroup(jPanel1Lay
out.createParallelGroup(javax.swing.GroupLayout
.Alignment. LEADING,
false) .addComponent(cb_Month) .addComponent
(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
37,
javax.swing.GroupLayout.PREFERRED_SIZE)) .
addGap(18, 18,
18) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) .addComponent(tf_amt,
javax.swing.GroupLayout.DEFAULT_SIZE, 37,
Short.MAX_VALUE)) .addGap(18, 18,
18) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(jLabel6,
javax.swing.GroupLayout.DEFAULT_SIZE, 31,
Short.MAX_VALUE) .addComponent(tf_avlBal))
.addGap(73, 73,
73) .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment. LEADING,
false) .addComponent(tf_submit,
javax.swing.GroupLayout.DEFAULT_SIZE, 39,
Short.MAX_VALUE) .addComponent(tf_cancel,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)) .addContainerGap(javax.s
wing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)) );
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelG
roup(javax.swing.GroupLayout.Alignment.LEADI
NG) .addComponent(jPanel1,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) );
layout.setVerticalGroup( layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.LEADING
) .addComponent(jPanel1,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE) ); pack(); }// private void
cb_MonthActionPerformed(java.awt.event.Action
Event evt) { // TODO add your handling code
here: } private void
tf_submitActionPerformed(java.awt.event.ActionE
vent evt) { // TODO add your handling code here:
if (true) { CCTransactions ccTrans = new
CCTransactions();
ccTrans.setCcno(this._usrDtls.getCreditCardNo());
ccTrans.setMonth(cb_Month.getSelectedItem().to
String()); ccTrans.setTransamt(tf_amt.getText());
ccTrans.setUserid("" + this._usrDtls.getId()); List
subUserList = null; Map getCCDtls = new
HashMap<>(); if (this._usrDtls.getParentAc() ==
0l) { subUserList = new
UserDetailsDAOImpl().getUserDetalsBsdOnParen
tId(this._usrDtls.getId()); } long maxAmt = 0l;
long cardId = 0l; for (UserDetails ud :
subUserList) { CCDtls _ccDtls = new
CCDtlsDAOImpl().getCCDtlsBsdOnUserId(ud.get
Id()); getCCDtls.put(ud.getId(), _ccDtls); if
(_ccDtls.getCcBal() > maxAmt) { maxAmt =
_ccDtls.getCcBal(); cardId =
_ccDtls.getUserId(); } } List ccTransList =
_ccTransDAOImpl.getCCTrans(this._usrDtls.getId
()); if (this._usrDtls.getParentAc() == 0l)
{ ccTransList =
_ccTransDAOImpl.getCCTrans(this._usrDtls.getId
()); } else { ccTransList =
_ccTransDAOImpl.getCCTransForJanMonth(this.
_usrDtls.getId(),
cb_Month.getSelectedItem().toString()); } Long
totTransAmtForAMonth = 0l; for (CCTransactions
cctrans : ccTransList) { totTransAmtForAMonth =
totTransAmtForAMonth +
Long.parseLong(cctrans.getTransamt()); } if
(ccTransList.size() < 3) { if
(Long.parseLong(tf_amt.getText()) <
Long.parseLong(tf_avlBal.getText()))
{ ccTrans.setCcno(this._usrDtls.getCreditCardNo(
));
ccTrans.setMonth(cb_Month.getSelectedItem().to
String()); ccTrans.setTransamt(tf_amt.getText());
ccTrans.setUserid("" + this._usrDtls.getId());
CCDtls _ccDtls =
_ccDtlsDAOImpl.getCCDtlsBsdOnUserId(this._us
rDtls.getId()); long bal = _ccDtls.getCcBal(); long
due = _ccDtls.getCcDue(); _ccDtls.setCcBal((bal -
Long.parseLong(tf_amt.getText())));
_ccDtls.setCcDue((due +
Long.parseLong(tf_amt.getText())));
_ccDtlsDAOImpl.updateCCDtls(_ccDtls); if
(_ccTransDAOImpl.saveCCTrans(ccTrans))
{ clearFields(); setBalance();
JOptionPane.showMessageDialog(this,
"Transaction successful"); } else
{ JOptionPane.showMessageDialog(this,
"Transaction failed!Contact Admin"); } } else
{ JOptionPane.showMessageDialog(this,
"Transaction declined! Available balance is
less"); } } else { try { //Validate from hadoop
System.out.println("Validating the transaction
from Hadoop"); new
HadoopAnalyzer().main(this._usrDtls.getId());
File hfile = new
File(constants.Constants.FILE_HADOOP_OUT_L
OCATION); int indicator = 0; FileReader
fileReader = new FileReader(hfile); Scanner
scanFile = new Scanner(fileReader); int freqCount
= 0; long finalAmtAllowd = 0l; while
(scanFile.hasNext()) { String data =
scanFile.nextLine(); String[] splitData =
data.split("\t"); if (freqCount <
Integer.parseInt(splitData[1].split("\\|")[1]))
{ freqCount =
Integer.parseInt(splitData[1].split("\\|")[1]);
finalAmtAllowd =
Long.parseLong(splitData[1].split("\\|")[0]); } } if
(Long.parseLong(tf_amt.getText()) <
Long.parseLong(tf_avlBal.getText()) ||
Long.parseLong(tf_amt.getText()) < maxAmt) { if
((this._usrDtls.getParentAc() == 0l &&
Long.parseLong(tf_amt.getText()) <=
this._usrDtls.getCcLimit()) ||
(Long.parseLong(tf_amt.getText()) +
totTransAmtForAMonth <=
this._usrDtls.getCcLimit())) { CCDtls _ccDtls =
_ccDtlsDAOImpl.getCCDtlsBsdOnUserId(this._us
rDtls.getId()); long bal = _ccDtls.getCcBal(); long
due = _ccDtls.getCcDue(); _ccDtls.setCcBal((bal -
Long.parseLong(tf_amt.getText())));
_ccDtls.setCcDue((due +
Long.parseLong(tf_amt.getText())));
_ccDtlsDAOImpl.updateCCDtls(_ccDtls); if
(_ccTransDAOImpl.saveCCTrans(ccTrans))
{ clearFields(); setBalance();
JOptionPane.showMessageDialog(this,
"Transaction successful"); } else
{ JOptionPane.showMessageDialog(this,
"Transaction failed!Contact Admin"); } } else if
(this._usrDtls.getParentAc() == 0l &&
Long.parseLong(tf_amt.getText()) <=
finalAmtAllowd) { CCDtls _ccDtls =
_ccDtlsDAOImpl.getCCDtlsBsdOnUserId(this._us
rDtls.getId()); long bal = _ccDtls.getCcBal(); long
due = _ccDtls.getCcDue(); _ccDtls.setCcBal((bal -
Long.parseLong(tf_amt.getText())));
_ccDtls.setCcDue((due +
Long.parseLong(tf_amt.getText())));
_ccDtlsDAOImpl.updateCCDtls(_ccDtls); if
(_ccTransDAOImpl.saveCCTrans(ccTrans))
{ clearFields(); setBalance();
JOptionPane.showMessageDialog(this,
"Transaction successful"); } else
{ JOptionPane.showMessageDialog(this,
"Transaction failed!Contact Admin"); } } else
{ //Allow transaction based on formula Random
rand = new Random(); String otp = ""; for (int k =
0; k < 5; k++) { otp = otp + rand.nextInt(9); }
String msgBox = ""; int counter = 0; java.util.Map
formulaVal = new java.util.HashMap(); for (String
alpha : constants.Constants.FORMULA_CHAR) {
if (counter == 0) { //msgBox = msgBox + alpha +
":=" + "" + rand.nextInt(9) + "\t"; } else { int val =
rand.nextInt(9); msgBox = msgBox + alpha + ":="
+ "" + val + "\t "; formulaVal.put(alpha, val); }
counter++; } String inputRec =
JOptionPane.showInputDialog(this, msgBox);
System.out.println("Input " + inputRec); String[]
splitUserForm =
this._usrDtls.getFormula().split("#"); int userVal =
0; //First operator validation if
(splitUserForm[1].equalsIgnoreCase("+"))
{ userVal = formulaVal.get(splitUserForm[0]) +
formulaVal.get(splitUserForm[2]); } else { userVal
= formulaVal.get(splitUserForm[0]) -
formulaVal.get(splitUserForm[2]); } //Second
operator validation if
(splitUserForm[3].equalsIgnoreCase("+"))
{ userVal = userVal +
formulaVal.get(splitUserForm[4]); } else { userVal
= userVal -
formulaVal.get(splitUserForm[4]); }
//System.out.println("User amt " + userVal + " and
rec amt " + if (userVal ==
Long.parseLong(inputRec)) { inputRec); //Sending
otp to mail id // // + otp, "OTP"); // // if
(this._usrDtls.getParentAc() == 0l)
{ SendMail.main(this._usrDtls.getEmailId(), "Your
OTP is =>" } else { UserDetails subUser = new
UserDetailsDAOImpl().getUserDetals(this._usrDtl
s.getParentAc()); // otp, "OTP"); //
SendMail.main(subUser.getEmailId(), "Your OTP
is =>" + } //String otpEntered =
JOptionPane.showInputDialog("Enter OTP"); //if
(otpEntered.equals(otp)) { CCDtls _ccDtls =
_ccDtlsDAOImpl.getCCDtlsBsdOnUserId(this._us
rDtls.getId()); long bal = _ccDtls.getCcBal(); long
due = _ccDtls.getCcDue(); _ccDtls.setCcBal((bal -
Long.parseLong(tf_amt.getText())));
_ccDtls.setCcDue((due +
Long.parseLong(tf_amt.getText())));
_ccDtlsDAOImpl.updateCCDtls(_ccDtls); if
(_ccTransDAOImpl.saveCCTrans(ccTrans))
{ clearFields(); setBalance();
JOptionPane.showMessageDialog(this,
"Transaction successful"); } else
{ JOptionPane.showMessageDialog(this,
"Transaction failed!Contact Admin"); } // } // // //
else { JOptionPane.showMessageDialog(this,
"Invalid OTP"); } } else
{ JOptionPane.showMessageDialog(this, "Credit
card fraud detected"); } } } else
{ JOptionPane.showMessageDialog(this,
"Transaction declined! Available balance is
less"); } } catch (Exception ex)
{ Logger.getLogger(TransactionFrame.class.getNa
me()).log(Level.SEVERE, null, ex); } } } else
{ JOptionPane.showMessageDialog(this, "Invalid
pin"); } } private void setBalance() { CCDtls
_ccDtls =
_ccDtlsDAOImpl.getCCDtlsBsdOnUserId(this._us
rDtls.getId()); tf_avlBal.setText("" +
_ccDtls.getCcBal()); } private void clearFields()
{ this.tf_amt.setText(""); } private void
tf_cancelActionPerformed(java.awt.event.ActionE
vent evt) { // TODO add your handling code here:
dispose(); new UserLogin().main(); } /** *
@param args the command line arguments */
public static void main(final UserDetails ud) { /*
Set the Nimbus look and feel */ // /* If Nimbus
(introduced in Java SE 6) is not available, stay
with the default look and feel. * For details see
http://download.oracle.com/javase/tutorial/uiswing
/lookandfeel/plaf.html */ try { for
(javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels
()) { if ("Nimbus".equals(info.getName()))
{ javax.swing.UIManager.setLookAndFeel(info.ge
tClassName()); break; } } } catch
(ClassNotFoundException ex)
{ java.util.logging.Logger.getLogger(TransactionF
rame.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex); } catch
(InstantiationException ex)
{ java.util.logging.Logger.getLogger(TransactionF
rame.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex); } catch
(IllegalAccessException ex)
{ java.util.logging.Logger.getLogger(TransactionF
rame.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex); } catch
(javax.swing.UnsupportedLookAndFeelException
ex)
{ java.util.logging.Logger.getLogger(TransactionF
rame.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex); } // /* Create
and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{ public void run() { File file = new
File(constants.Constants.RFID_READER_FILE);
FileReader fileReader = null; try { fileReader =
new FileReader(file); } catch
(FileNotFoundException ex)
{ Logger.getLogger(TransactionFrame.class.getNa
me()).log(Level.SEVERE, null, ex); } Scanner
scan = new Scanner(fileReader); long id = 0; while
(scan.hasNext()) { id =
(Long.parseLong(scan.nextLine())); }
//UserDetails _usrDB = new
UserDetailsDAOImpl().getUserDetals(id);
UserDetails _usrDB = new
UserDetailsDAOImpl().getUserDetals(ud.getId());
new TransactionFrame(_usrDB).setVisible(true); }
}); } // Variables declaration - do not modify
private javax.swing.JComboBox cb_Month;
private javax.swing.JLabel jLabel1; private
javax.swing.JLabel jLabel2; private
javax.swing.JLabel jLabel3; private
javax.swing.JLabel jLabel5; private
javax.swing.JLabel jLabel6; private
javax.swing.JPanel jPanel1; private
javax.swing.JTextField tf_CCno; private
javax.swing.JTextField tf_amt; private
javax.swing.JTextField tf_avlBal; private
javax.swing.JButton tf_cancel; private
javax.swing.JButton tf_submit; private
javax.swing.JTextField tf_userName; // End of
variables declaration}
}}javax.swing.JTextField tf_usdeclaration }
CONCLUSION

The credit card transaction management system


developed in this project serves as a robust
platform for handling financial transactions
securely and efficiently.

Future enhancements could focus on integrating


more advanced analytics, improving security
measures further, and expanding the system's
capabilities to include features like transaction
history, multi-factor authentication, and better
error handling. Overall, this project lays a solid
foundation for a scalable and secure transaction
management system that can evolve with user
needs and technological advancements.
THANK YOU

You might also like