-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfirm_payment_Copy.php
executable file
·410 lines (355 loc) · 16.3 KB
/
confirm_payment_Copy.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><!-- InstanceBegin template="/Templates/Inner Template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Etisalat Nigeria | Preorder</title>
<link href="common/blaq.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.back
{
border: none;
background: url('images/preorder/back.png') no-repeat top left;
padding: 2px 8px;
height:43px;
width:141px;
}
.back:hover {
border-style: none;
border-color: inherit;
border-width: medium;
background: url('images/preorder/back_over.png') no-repeat left top;
padding: 2px 8px;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5547935-1']);
_gaq.push(['_setDomainName', 'etisalat.com.ng']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
include('header.html');
include('flashbanner.html');
require_once('connectionvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$cbotitle= mysqli_real_escape_string($dbc, $_POST['cbotitle']);
$txtfirstname= mysqli_real_escape_string($dbc, $_POST['txtfirstname']);
$txtlastname= mysqli_real_escape_string($dbc, $_POST['txtlastname']);
$txtemail= mysqli_real_escape_string($dbc, $_POST['txtemail']);
$txtalternateemail= mysqli_real_escape_string($dbc, $_POST['txtalternateemail']);
$txtnumber= mysqli_real_escape_string($dbc, $_POST['txtnumber']);
$txtalternatenumber= mysqli_real_escape_string($dbc, $_POST['txtalternatenumber']);
$cboquantity= mysqli_real_escape_string($dbc, $_POST['cboquantity']);
$cboshop= mysqli_real_escape_string($dbc, $_POST['cboshop']);
$txtshops= mysqli_real_escape_string($dbc, $_POST['txtshops']);
$squestion = mysqli_real_escape_string($dbc, $_POST['squestion']);
$sanswer = mysqli_real_escape_string($dbc, $_POST['sanswer']);
$devicetype= mysqli_real_escape_string($dbc, $_POST['devicetype']);
$devicesize= mysqli_real_escape_string($dbc, $_POST['devicesize']);
$itemcode = "";
$paymentcode = "";
$amount = "";
$tomorrow = mktime(0,0,0,date("m"),date("d"),date("Y")+17);
$expdate = date("Y-m-d", $tomorrow);
$query=""; $newdbref = ""; $nowdate = date("Y-m-d");
$iswresult = ""; $client = ""; $array = "";
if(empty($devicetype) || empty($txtshops))
{
header('Location: index.php');
exit;
}
//Generate Customer ID and get device details (amount, itemcode & paymentcode)
$custid = ""; $stmt = "";
try
{
$query = "SELECT REFERENCE_NO FROM reference";
$data = mysqli_query($dbc,$query);
if(mysqli_num_rows($data) == 1)
{
$row = mysqli_fetch_array($data);
$newdbref = $row['REFERENCE_NO'] + 1;
$custid = ISW_ID . str_pad($newdbref,9,"0",STR_PAD_LEFT);
}
$stmt = $dbc->prepare("SELECT * FROM DEVICES WHERE NAME = ? AND SIZE = ?");
$stmt->bind_param("ss", $devicetype, $devicesize);
$stmt->execute();
$data = $stmt->get_result();
while($row = mysqli_fetch_array($data))
{
$amount = $row['AMOUNT'];
$paymentcode = $row['PAYMENTCODE'];
$itemcode = $row['ITEMCODE'];
}
//$amount = 100;
$amount = $amount * $cboquantity;
$iswamount = $amount * 100;
}
catch (Exception $e)
{
header('Location: index.php?msg=101 - Oops, server is temporarily unavailable, please try again later!');
exit;
}
//Connect to Interswitch to log Id
try
{
$Booking = array(
'ReferenceNumber' => $custid,
'Description' => $devicetype,
'Amount' => $iswamount ,
'DateBooked' => $nowdate,
'DateExpired' => $expdate,
'FirstName' => $txtfirstname,
'LastName' => $txtlastname,
'Email' => $txtemail,
'ItemCode' => $itemcode
);
$params = array(
'MerchantId' => ISW_ID,
'Bookings' => array($Booking)
);
if(!@file_get_contents(WSDL_URL))
{
throw new SoapFault('Server', 'No WSDL found at ' . WSDL_URL);
}
$client = new SoapClient(WSDL_URL);
$array = $client->CreateBooking(array('ReservationRequest' => $params));
$iswresult = $array->CreateBookingResult->Booking->ResponseCode;
}
catch (Exception $e)
{
header('Location: index.php?msg=102 - Oops, server is temporarily unavailable, please try again later!');
}
catch(SoapFault $se)
{
header('Location: index.php?msg=103 - Oops, server is temporarily unavailable, please try again later!');
}
//var_dump($Booking);
//var_dump($params);
//echo $iswresult;
//exit;
//Connect and Log transaction on local db
if( $iswresult == '100' )
{
try
{
$stmt = ""; $empty = ""; $zero = "0"; $nowdate = date("Y-m-d H:i:s");
$stmt = $dbc->prepare("INSERT INTO transactions VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssssssssdssssss", $custid, $nowdate, $txtfirstname, $txtlastname, $txtemail, $txtalternateemail, $txtnumber, $txtalternatenumber, $cboquantity, $devicetype, $devicesize, $amount, $cboshop, $squestion, $sanswer, $zero, $empty, $empty);
$stmt->execute();
$stmt = "";
$stmt = $dbc->prepare("UPDATE reference SET REFERENCE_NO = ?");
$stmt->bind_param("s", $newdbref);
$stmt->execute();
}
catch(Exception $e)
{
header('Location: index.php?msg=104 - Oops, server is temporarily unavailable, please try again later!');
}
}
else
{
header('Location: index.php?msg=105 - Oops, server is temporarily unavailable, please try again later! errorcode - '.$iswresult);
}
//$txtredirect = 'http://preorder.etisalat.com.ng/do_payment.php?params=' . $amount . ',' . $custid . ',' . $device . ',' . $ipadtype . ',' . $txtfirstname . ',' . $txtlastname;
$txtredirect = 'http://preorder.etisalat.com.ng/do_payment.php?params=' . $custid;
?>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" style="width: 815px; height: 293px" bgcolor="#ffffff" align="center">
<!-- MSTableType="layout" -->
<tr>
<td style="width: 15px"> </td>
<td style="width: 627px" valign="top">
<table border="0" cellspacing="0" cellpadding="0" style="width: 620px; margin-left:auto; margin-right:auto;">
<tr>
<td style="height: 18px"></td>
</tr>
<tr>
<td valign="top">
<div class="serviceHeader"><strong><span class="header">Etisalat Preordering System<br/><br/></span></strong></div>
<div class="outerTable">
<div class="innerTable" id="results" >
<table style="width: 100%">
<tr>
<td><span class="charge"><strong>Customer Preorder Request Information </strong> </span></td>
</tr>
<tr>
<td>
<form action="do_booking.php" method="post" >
<input name="amount" id="amount" value="<?php echo $amount; ?>" type="hidden" />
<input name="custid" id="custid" value="<?php echo $custid; ?>" type="hidden" />
<input name="txtfirstname" id="txtfirstname" value="<?php echo $txtfirstname; ?>" type="hidden" />
<input name="txtlastname" id="txtlastname" value="<?php echo $txtlastname; ?>" type="hidden" />
<input name="devicetype" id="devicetype" value="<?php echo $devicetype; ?>" type="hidden" />
<table class="serviceTable" border="0" bordercolor="#cccccc" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td colspan="3" align="right" valign="top">
<div align="justify">
Kindly confirm the form below and click on the submit button
to place your <strong><?php echo $devicetype?></strong> preorder. <br/>
<br />
These are your entries for confirmation. <span style="color:red">*</span>
Customer ID : <strong><?php echo $custid; ?></strong>
</div>
</td>
</tr>
<tr>
<td align="right" valign="top" width="35%">Title:</td>
<td colspan="2"><strong><?php echo $cbotitle; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">First Name:</td>
<td colspan="2"><strong><?php echo $txtfirstname; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">Last Name: </td>
<td colspan="2"><strong><?php echo $txtlastname; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">E-mail Address: </td>
<td colspan="2"><strong><?php echo $txtemail; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">Alternative E-mail Address: </td>
<td colspan="2"><strong><?php echo $txtalternateemail; ?></strong></td>
</tr>
<tr>
<td align="right" height="29" valign="top">Mobile number</td>
<td colspan="2" align="left" valign="top"><strong><?php echo $txtnumber; ?></strong></td>
</tr>
<tr>
<td align="right" height="29" valign="top">Alternative Mobile number</td>
<td colspan="2" align="left" valign="top"><strong><?php echo $txtalternatenumber; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">Quantity you want to preorder </td>
<td colspan="2" align="left" valign="top"><strong><?php echo $cboquantity; ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">Amount</td>
<td colspan="2" align="left" valign="top"><strong><strike>N</strike> <?php echo number_format($amount,2); ?></strong></td>
</tr>
<?php
$stmt = ""; $discountval = "0.0"; $discountamt = "";
$stmt = $dbc->prepare("SELECT DISCOUNTVALUE FROM discount WHERE MOBILE = ?");
$stmt->bind_param("s", $txtnumber);
$stmt->execute();
$data = $stmt->get_result();
while($row = mysqli_fetch_array($data))
{
$discountval = $row['DISCOUNTVALUE'];
}
//$amount = 100;
$discountamt = $amount * $discountval;
$amount = $amount - $discountamt;
$iswamount = $amount * 100;
$stmt->close();
mysqli_close($dbc);
?>
<tr>
<td align="right" valign="top">Discount</td>
<td colspan="2" align="left" valign="top"><strong><strike>N</strike> <?php echo number_format($discountamt,2); ?></strong></td>
</tr>
<tr>
<td align="right" valign="top">Total</td>
<td colspan="2" align="left" valign="top"><strong><strike>N</strike> <?php echo number_format($amount,2); ?></strong></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"> </td>
</tr>
<tr>
<td align="right" valign="top">Device pickup location </td>
<td colspan="2" align="left" valign="top"><strong><?php echo $txtshops; ?></strong></td>
</tr>
<tr>
<th>
<br/>
<input name="back" value="" type="button" class="back" onClick="window.history.back()" />
</th>
<th colspan="2" align="left">
<br/>
<input type="hidden" id="amountField" runat="server" value="<?php echo $iswamount; ?>" />
<input type="hidden" id="customerIdField" runat="server" value="<?php echo $custid; ?>" />
<input type="hidden" id="emailField" runat="server" value="<?php echo $txtemail; ?>" />
<input type="hidden" id="mobileNumberField" runat="server" value="<?php echo $txtnumber; ?>" />
<input type="hidden" id="txtredirect" value="<?php echo $txtredirect; ?>" />
<a class="quickteller-checkout-anchor" id="<?php echo $paymentcode; ?>" ></a>
<script type="text/javascript">
var QTCheckout = QTCheckout || {};
QTCheckout.paymentItems = QTCheckout.paymentItems || [];
QTCheckout.paymentItems.push({
paymentCode: '<?php echo $paymentcode; ?>',
extraData: {
amount: 'default',
amountFieldId:'amountField',
customerId: 'default',
customerIdFieldId:'customerIdField',
mobileNumber:'default',
mobileNumberFieldId:'mobileNumberField',
emailAddress:'default',
emailAddressFieldId: 'emailField',
buttonSize:'large',
redirectUrl:'<?php echo $txtredirect; ?>'
}
});
if (!QTCheckout.qtScript) {
var qtScript = document.createElement('script'); qtScript.type = 'text/javascript'; qtScript.async = true; qtScript.src = "https://paywith.quickteller.com/scripts/quickteller-checkout-min.js?v=" + new Date().getDay(); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(qtScript, s); QTCheckout.qtScript = qtScript;
} else if (QTCheckout.buildPaymentItemsUI) { QTCheckout.buildPaymentItemsUI(); }
</script>
<!--a class="quickteller-checkout-anchor" id="95002"></a>
<script type="text/javascript">
var QTCheckout = QTCheckout || {};
QTCheckout.paymentItems = QTCheckout.paymentItems || [];
QTCheckout.paymentItems.push({
paymentCode: "95002",
extraData: {
amount: 'default',
amountFieldId:'amountField',
customerId: 'default',
customerIdFieldId:'customerIdField',
mobileNumber:'default',
mobileNumberFieldId:'mobileNumberField',
emailAddress:'default',
emailAddressFieldId: 'emailField',
buttonSize:'long',
redirectUrl:'default'
}
});
if (!QTCheckout.qtScript) {
var qtScript = document.createElement('script'); qtScript.type = 'text/javascript'; qtScript.async = true; qtScript.src = "http://testwebpay.interswitchng.com/quicktellercheckout/scripts/quickteller-checkout.js?v=" + new Date().getDay(); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(qtScript, s); QTCheckout.qtScript = qtScript;
} else if (QTCheckout.buildPaymentItemsUI) { QTCheckout.buildPaymentItemsUI(); }
</script-->
</th>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="815" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="tdivider"> </td>
</tr>
<tr>
<td><?php include('common/footer.html'); ?></td>
</tr>
</table>
</td>
</tr>