-
Notifications
You must be signed in to change notification settings - Fork 0
/
fund_transfer_otp.php
350 lines (238 loc) · 11.6 KB
/
fund_transfer_otp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<html>
<head><title>OTP Verification</title>
<link rel="stylesheet" type="text/css" href="css/fund_transfer_otp.css">
</head>
<body>
<?php include 'header.php' ;
include 'customer_profile_header.php';
$sender_mob = $_SESSION['sender_mob'];
$hidden_mob_no = substr($sender_mob, 0, 3)."XXXX".substr($sender_mob, 7, 10);
$ref_no = $_SESSION['ref_no'];
?>
<label class="OTP_msg">OTP with Ref no.<?php echo $ref_no." sent to <b>".$hidden_mob_no."</b> please verify to complete your transaction <br><br> *OTP :".$_SESSION['fund_trnsfer_otp']."" ; ?></label>
<div class="fund_transfer_otp_container">
<form method="post">
<input type="text" name="otpcode" placeholder="OTP Code">
<input type="submit" name="verify-btn" value="Verify">
</form>
</div>
<?php include 'footer.php' ; ?>
</body>
</html>
<?php /*
if(isset($_POST['verify-btn'])){
if(!is_numeric($_POST['trnsf_amount'])){
echo '<script>alert("Invalid amount")</script>';
}
else{
$sender_ac_no = $_SESSION['Account_No']; //Sender's Account_No
$trnsf_amount=$_POST['trnsf_amount'];
include 'db_connect.php';
$cust_id = $_SESSION['customer_Id'];
//Receivers details require_onced for transaction
$beneficiary_ac_no = $_POST['beneficiary'];
$sql = "SELECT * FROM bank_customers WHERE Account_no = $beneficiary_ac_no ";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$receiver_ac_no = $row['Account_no'];
$receiver_custmr_id = $row['Customer_ID'];
$receiver_name = $row['Username'];
$receiver_ifsc= $row['IFSC_Code'];
$receiver_mob = $row['Mobile_no'];
$receiver_netbal = $row['Current_Balance'] + $trnsf_amount;
$receiver_passbk = "passbook_".$receiver_custmr_id;
//Senders Details require_onced for transaction
$sql = "SELECT * FROM bank_customers WHERE Account_no = '$sender_ac_no' " ;
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$sender_custmr_id = $row['Customer_ID'];
$sender_name = $row['Username'];
$sender_ifsc = $row['IFSC_Code'];
$sender_mob = $row['Mobile_no'];
$sender_ac_no = $row['Account_no'];
$sender_netbal = $row['Current_Balance'] - $trnsf_amount;
$sender_passbk = "passbook_".$sender_custmr_id;
if($row['Current_Balance'] < $trnsf_amount){
echo '<script>alert("Insufficient balance")
location="fund_transfer.php";
</script>';
}
else {
// Set autocommit to off
$conn->autocommit(FALSE);
//Add transferring amount to receiver's available balance
$sql1 = "Update bank_customers SET Current_Balance = '$receiver_netbal' WHERE bank_customers.Account_no = '$receiver_ac_no '";
//Subtract transferring amount from sender's available balance
$sql2 = "Update bank_customers SET Current_Balance ='$sender_netbal' WHERE bank_customers.Account_no = '$sender_ac_no' ";
//Generate Transaction ID
$transaction_id = mt_rand(100,999).mt_rand(1000,9999).mt_rand(10,99);
//Transaction Date
date_default_timezone_set('Asia/Kolkata');
$transaction_date = date("d/m/y h:i:s A");
//Narration
$remark = $_POST['trnsf_remark'];
//Sender's Transaction Description
$Transac_description = $receiver_name ."/".$receiver_ac_no."/".$receiver_ifsc;
// Insert Statement into Sender Passbook
$sql3 = "INSERT INTO $sender_passbk(Transaction_id,Transaction_date,Description,Cr_amount,Dr_amount,Net_Balance,Remark)
VALUES ('$transaction_id','$transaction_date','$Transac_description','0','$trnsf_amount','$sender_netbal','$remark')";
//Receiver's Transaction Description
$Transac_description = $sender_name."/".$sender_ac_no."/".$sender_ifsc;
// Insert Statement into Receiver Passbook
$sql4 = "INSERT INTO $receiver_passbk (Transaction_id,Transaction_date,Description,Cr_amount,Dr_amount,Net_Balance,Remark)
VALUES ('$transaction_id','$transaction_date','$Transac_description','$trnsf_amount','0','$receiver_netbal','$remark')";
if($conn->query($sql1) == TRUE && $conn->query($sql2) == TRUE && $conn->query($sql3) == TRUE && $conn->query($sql4) == TRUE ){
$conn->commit();
date_default_timezone_set('Asia/Kolkata');
$date_time = date("d/m/y h:i:s A");
//SMS Integration for Fund Transfer notification to both the Sender and the Receiver-------------------------------
///------------To the sender------------
require_once('textlocal.class.php');
$apikey = 'Mzie479SxfY-Z7slYf9AI3zVXCAu0G5skUBQVYOfRU';
$textlocal = new Textlocal(false,false,$apikey);
$numbers = array($sender_mob);
$sender = 'TXTLCL';
$hidden_ac_no = "XXXXXXXX".substr($sender_ac_no, 8, 13);
$message = 'Your a/c no.'.$hidden_ac_no.' is debited with Rs.'.$trnsf_amount.' on '.$date_time.' Transaction ID is '.$transaction_id.'' ;
try {
$result = $textlocal->sendSms($numbers, $message, $sender);
print_r($result);
} catch (Exception $e) {
die('Error: ' . $e->getMessage());
}
//-------------------------------------------------------------------------------------
//-------------------To the receiver----------------------------------------------------
require_once('textlocal.class.php');
$apikey = 'Mzie479SxfY-Z7slYf9AI3zVXCAu0G5skUBQVYOfRU';
$textlocal = new Textlocal(false,false,$apikey);
$numbers = array($receiver_mob);
$sender = 'TXTLCL';
$hidden_ac_no = "XXXXXXXX".substr($receiver_ac_no, 8, 13);
$message = 'Your a/c no.'.$hidden_ac_no.' is credited with Rs.'.$trnsf_amount.' on '.$date_time.' Transaction ID is '.$transaction_id.'' ;
try {
$result = $textlocal->sendSms($numbers, $message, $sender);
print_r($result);
} catch (Exception $e) {
die('Error: ' . $e->getMessage());
}
//-------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
echo '<script>alert("Transaction Successfull.")
location="fund_transfer.php"</script>';
}
else{
echo "Transaction failed!\nPlease contact bank<br>".$conn->error;
$conn->rollback();
}
}
}
} */
?>
<?php
echo $_SESSION['fund_trnsfer_otp'];
if(isset($_POST['verify-btn'])){
$otpcode = $_POST['otpcode'];
if($otpcode == $_SESSION['fund_trnsfer_otp']){ //Session1
$sender_ac_no = $_SESSION['Account_No']; //Sender's Account_No //SESSION2
$trnsf_amount = $_SESSION['trnsf_amount']; //Transfer Amount //SESSION3
//Receivers details require_onced for transaction
$beneficiary_ac_no = $_SESSION['beneficiary_ac_no']; //SESSION4
include 'db_connect.php';
// $cust_id = $_SESSION['customer_Id'];
$sql = "SELECT * FROM bank_customers WHERE Account_no = $beneficiary_ac_no ";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$receiver_ac_no = $row['Account_no'];
$receiver_custmr_id = $row['Customer_ID'];
$receiver_name = $row['Username'];
$receiver_ifsc= $row['IFSC_Code'];
$receiver_mob = $row['Mobile_no'];
$receiver_netbal = $row['Current_Balance'] + $trnsf_amount;
$receiver_passbk = "passbook_".$receiver_custmr_id;
//Senders Details require_onced for transaction
$sql = "SELECT * FROM bank_customers WHERE Account_no = '$sender_ac_no' " ;
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$sender_custmr_id = $row['Customer_ID'];
$sender_name = $row['Username'];
$sender_ifsc = $row['IFSC_Code'];
$sender_mob = $row['Mobile_no'];
$sender_ac_no = $row['Account_no'];
$sender_netbal = $row['Current_Balance'] - $trnsf_amount;
$sender_passbk = "passbook_".$sender_custmr_id;
// Set autocommit to off
$conn->autocommit(FALSE);
//Add transferring amount to receiver's available balance
$sql1 = "Update bank_customers SET Current_Balance = '$receiver_netbal' WHERE bank_customers.Account_no = '$receiver_ac_no '";
//Subtract transferring amount from sender's available balance
$sql2 = "Update bank_customers SET Current_Balance ='$sender_netbal' WHERE bank_customers.Account_no = '$sender_ac_no' ";
//Generate Transaction ID
$transaction_id = mt_rand(100,999).mt_rand(1000,9999).mt_rand(10,99);
//Transaction Date
date_default_timezone_set('Asia/Kolkata');
$transaction_date = date("d/m/y h:i:s A");
//Narration
$remark = $_SESSION['trnsf_remark']; //SESSION56
//Sender's Transaction Description
$Transac_description = $receiver_name ."/".$receiver_ac_no."/".$receiver_ifsc;
// Insert Statement into Sender Passbook
$sql3 = "INSERT INTO $sender_passbk(Transaction_id,Transaction_date,Description,Cr_amount,Dr_amount,Net_Balance,Remark)
VALUES ('$transaction_id','$transaction_date','$Transac_description','0','$trnsf_amount','$sender_netbal','$remark')";
//Receiver's Transaction Description
$Transac_description = $sender_name."/".$sender_ac_no."/".$sender_ifsc;
// Insert Statement into Receiver Passbook
$sql4 = "INSERT INTO $receiver_passbk (Transaction_id,Transaction_date,Description,Cr_amount,Dr_amount,Net_Balance,Remark)
VALUES ('$transaction_id','$transaction_date','$Transac_description','$trnsf_amount','0','$receiver_netbal','$remark')";
if($conn->query($sql1) == TRUE && $conn->query($sql2) == TRUE && $conn->query($sql3) == TRUE && $conn->query($sql4) == TRUE ){
$conn->commit();
date_default_timezone_set('Asia/Kolkata');
$date_time = date("d/m/y h:i:s A");
//SMS Integration for Fund Transfer notification to both the Sender and the Receiver-------------------------------
///------------To the sender------------
// require_once('textlocal.class.php');
// $apikey = 'Mzie479SxfY-Z7slYf9AI3zVXCAu0G5skUBQVYOfRU';
// $textlocal = new Textlocal(false,false,$apikey);
// $numbers = array($sender_mob);
// $sender = 'TXTLCL';
// $hidden_ac_no = "XXXXXXXX".substr($sender_ac_no, 8, 13);
// $message = 'Your a/c no.'.$hidden_ac_no.' is debited with Rs.'.$trnsf_amount.' on '.$date_time.' Transaction ID is '.$transaction_id.'' ;
// try {
// $result = $textlocal->sendSms($numbers, $message, $sender);
// print_r($result);
// } catch (Exception $e) {
// die('Error: ' . $e->getMessage());
// }
//-------------------------------------------------------------------------------------
//-------------------To the receiver----------------------------------------------------
// require_once('textlocal.class.php');
// $apikey = 'Mzie479SxfY-Z7slYf9AI3zVXCAu0G5skUBQVYOfRU';
// $textlocal = new Textlocal(false,false,$apikey);
// $numbers = array($receiver_mob);
// $sender = 'TXTLCL';
// $hidden_ac_no = "XXXXXXXX".substr($receiver_ac_no, 8, 13);
// $message = 'Your a/c no.'.$hidden_ac_no.' is credited with Rs.'.$trnsf_amount.' on '.$date_time.' Transaction ID is '.$transaction_id.'' ;
// try {
// $result = $textlocal->sendSms($numbers, $message, $sender);
// print_r($result);
// } catch (Exception $e) {
// die('Error: ' . $e->getMessage());
// }
//-------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------- */
unset($_SESSION['fund_trnsfer_otp']);
unset($_SESSION['trnsf_amount']);
unset($_SESSION['beneficiary_ac_no']);
unset($_SESSION['trnsf_remark']);
echo '<script>alert("Transaction Successful!")
location="fund_transfer.php"</script>';
}
else{
echo "Transaction failed!\nPlease contact bank<br>".$conn->error;
$conn->rollback();
}
}
else{
echo '<script>alert("Incorrect OTP\n\nPlease try again")</script>';
}
}
?>