This repository has been archived by the owner on Jul 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathorder.php
413 lines (405 loc) · 14.1 KB
/
order.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
411
412
413
<?php
/**
* @package Script Pulsa Online
* @version 1
* @author Engky Datz
* @link http://okepulsa.id
* @link http://facebook.com/Engky09
* @link http://okepulsa.id
* @link https://www.bukalapak.com/engky09
* @copyright 2015 -2016
*/
include ('includes/base.php');
$operators = $pdo->query("SELECT * FROM operator ORDER BY op_produk ASC, op_nama ASC")->
fetchAll();
$page_title = 'Order | ' . $set['site_name'];
$active_page = 'order';
$metode_pembayaran = json_decode($set['metode_pembayaran']);
$confirm = false;
$errors = array();
if (isset($_POST['submit']))
{
$oper = isset($_REQUEST['operator']) ? $_REQUEST['operator'] : '';
$voucher = isset($_REQUEST['voucher']) ? $_REQUEST['voucher'] : '';
$nomor_hp = isset($_REQUEST['nomor_hp']) ? $_REQUEST['nomor_hp'] : '';
$id_pln = isset($_REQUEST['id_pln']) ? $_REQUEST['id_pln'] : '';
$pembayaran = isset($_REQUEST['pembayaran']) ? $_REQUEST['pembayaran'] : '';
$query = $pdo->prepare('SELECT voucher.*, operator.* FROM voucher ' .
'LEFT JOIN operator ON voucher.op_id = operator.op_id WHERE voucher.op_id = ? AND voucher.vo_kode = ? AND voucher.vo_status = ?');
$query->execute(array($oper, $voucher, '1'));
if ($query->rowCount() == 0)
{
$errors[] = 'Nominal tidak benar';
}
$op = $query->fetch();
if ($produk->{$op->op_produk}->status != 'on') {
$errors[] = 'Produk tidak benar';
}
elseif ($op->vo_harga > $set['saldo']) {
$errors[] = 'Sisa saldo kami tidak cukup untuk melakukan transaksi ini';
}
elseif (strlen($nomor_hp) < 8 || strlen($nomor_hp) > 14 || !ctype_digit($nomor_hp))
{
$errors[] = 'Nomor HP tidak benar';
}
elseif (!array_key_exists($pembayaran, $metode_pembayaran))
{
$errors[] = 'Pembayaran tidak benar';
}
elseif ($pembayaran == 'bank_bca' && $op->vo_harga < 10000)
{
$errors[] = 'Pembayaran melalui Bank BCA minimal Rp. 10.000';
}
elseif ($metode_pembayaran->{$pembayaran}->status != 'on')
{
$errors[] = 'Pembayaran tidak tersedia';
}
if ($op->op_produk == 'token_pln' && (strlen($id_pln) < 8 || strlen($id_pln) >
16 || !ctype_digit($id_pln)))
{
$errors[] = 'ID PLN tidak benar';
}
if (!$errors) {
$confirm = true;
}
if ($_POST['submit'] == 'konfirmasi')
{
$kode = @$_POST['kode'];
if (!$kode || !isset($_SESSION['code']) || mb_strlen($kode) < 4 || strtolower($kode) !=
strtolower($_SESSION['code']))
{
$errors = 'Kode keamanan tidak benar.';
}
else
{
$fields = array(
'op_id' => '?',
'op_produk' => '?',
'op_nama' => '?',
'vo_id' => '?',
'vo_kode' => '?',
'vo_nominal' => '?',
'tr_id_pln' => '?',
'tr_no_hp' => '?',
'tr_harga' => '?',
'tr_harga2' => '?',
'tr_rate' => '?',
'tr_pembayaran' => '?',
'tr_status_pembayaran' => '?',
'tr_id_pembayaran' => '?',
'tr_status' => '?',
'tr_tanggal' => '?',
);
$inv_id = 'inv' . substr(time(), -6);
$harga_unik = $op->vo_harga;
if ($pembayaran != 'paypal')
{
$waktu = time() - (3600 * 48); // Harga unik kembali ke 1 dalam 2 hari
$q = $pdo->prepare("SELECT MAX(tr_harga) AS max_harga FROM transaksi WHERE tr_harga2 = ? AND tr_tanggal > ?");
$q->execute(array(
$op->vo_harga,
$waktu,
));
$res = $q->fetch();
if (!is_null($res->max_harga))
{
$harga_unik = $res->max_harga + 1;
}
else
{
$harga_unik = $op->vo_harga + 1;
}
}
$q = $pdo->prepare("INSERT INTO transaksi (" . implode(', ', array_keys($fields)) .
") VALUES (" . implode(', ', array_values($fields)) . ");");
$q->execute(array(
$op->op_id,
$op->op_produk,
$op->op_nama,
$op->vo_id,
$op->vo_kode,
$op->vo_nominal,
$id_pln,
$nomor_hp,
$harga_unik,
$op->vo_harga,
($pembayaran == 'paypal' ? $metode_pembayaran->paypal->rate : 0),
$pembayaran,
'pending',
$inv_id,
'pending',
time(),
));
header("Location: " . SITE_URL . "status.php?id=" . $pdo->lastInsertId());
exit();
}
unset($_SESSION['code']);
}
}
$head = '<link href="'.$set['site_url'].'assets/css/timeline.css" rel="stylesheet"/>';
include ('includes/header.php');
?>
<h3>Order</h3>
<?php if ($confirm):?>
<div class="row">
<div class="col-sm-8">
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td style="width: 50%;">
Jenis Produk
</td>
<td style="vertical-align: middle;">
<?php echo $produk->{$op->op_produk}->nama;?>
</td>
</tr>
<tr>
<td style="width: 50%;">
Provider
</td>
<td style="vertical-align: middle;">
<?php echo $op->op_nama?>
</td>
</tr>
<?php if ($op->op_produk == 'token_pln'):?>
<tr>
<td>
ID PLN
</td>
<td style="vertical-align: middle;">
<?php echo $id_pln?>
</td>
</tr>
<?php endif;?>
<tr>
<td>
Nomor HP
</td>
<td style="vertical-align: middle;">
<?php echo $nomor_hp?>
</td>
</tr>
<tr>
<td>
Voucher
</td>
<td style="vertical-align: middle;">
<?php echo __e($op->vo_nominal);?>
</td>
</tr>
<tr>
<td>
Harga
</td>
<td style="vertical-align: middle;">
<?php echo ($pembayaran == 'paypal' ? '$'.round($op->vo_harga / $metode_pembayaran->paypal->rate, 2).' USD' : 'Rp. '.format_uang($op->vo_harga));?>
</td>
</tr>
<tr>
<td>
Pembayaran
</td>
<td style="vertical-align: middle;">
<?php echo $metode_pembayaran->{$pembayaran}->nama; ?>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-4">
<?php if ($errors):?>
<div class="alert alert-danger">
Kode keamanan tidak benar.
</div>
<?php else:?>
<div class="alert alert-warning">
Sebelum Anda melakukan pembelian pastikan data - data sudah benar.
<br />
Kesalahan data tersebut bukan tanggung jawab Kami.
</div>
<?php endif;?>
<form method="post" action="<?php echo SITE_URL;?>order.php">
<input type="hidden" name="operator" value="<?php echo $oper;?>"/>
<input type="hidden" name="voucher" value="<?php echo $voucher;?>"/>
<input type="hidden" name="id_pln" value="<?php echo __e($id_pln);?>"/>
<input type="hidden" name="nomor_hp" value="<?php echo $nomor_hp;?>"/>
<input type="hidden" name="pembayaran" value="<?php echo $pembayaran;?>"/>
<div class="form-group">
<label for="kode" class=" control-label">
Kode Keamanan
</label>
<div class="input-group">
<span class="input-group-addon" style="padding: 0;">
<img src="<?php echo SITE_URL;?>captcha.php" style="" alt="Loading...."/>
</span>
<input type="text" class="form-control input-lg" name="kode" id="kode" maxlength="5" size="5" required="required"/>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary btn-lg btn-block" type="submit" name="submit" value="konfirmasi">
Beli Sekarang
</button>
</div>
</form>
</div>
</div>
<?php else:?>
<div class="row">
<div class="col-sm-8">
<?php if ($errors):?>
<div class="alert alert-danger"><ol><li><?php echo implode('</li><li>',$errors);?></li></ol></div>
<?php endif;?>
<div class="well well-sm order-form">
<form method="post" action="<?php echo SITE_URL?>order.php">
<div class="form-group">
<label for="operator">
Provider
</label>
<select class="form-control" name="operator" id="operator" required>
<option value="">
</option>
<?php
$my_produk = array();
foreach ($operators as $operator) {
if ($produk->{$operator->op_produk}->status == 'off')
continue;
if (!array_key_exists($operator->op_produk, $my_produk)) {
echo (count($my_produk) == 0 ? '': '</optgroup>') . PHP_EOL;
echo '<optgroup label="'.$produk->{$operator->op_produk}->nama.'" id="produk-'.$operator->op_produk.'">' . PHP_EOL;
}
$my_produk[$operator->op_produk][$operator->op_id] = $operator->op_nama;
echo '<option value="'.$operator->op_id.'">'.$operator->op_nama.'</option>' . PHP_EOL;
}
?>
</optgroup>
</select>
</div>
<div class="form-group">
<label for="voucher">
Voucher
</label>
<select class="form-control" name="voucher" id="voucher" required>
</select>
</div>
<div id="data_value1">
</div>
<div id="data_value2">
<div class="form-group">
<label for="nomor_hp">
Nomor HP
</label>
<input type="text" class="form-control" name="nomor_hp" id="nomor_hp" placeholder="08xxxxxxxxxx" maxlength="13" minlength="8" required/>
</div>
</div>
<div id="data_value3">
</div>
<div class="form-group">
<label for="pembayaran">
Pembayaran
</label>
<select class="form-control" name="pembayaran" id="pembayaran" required>
<option value="">
</option>
<?php foreach ($metode_pembayaran as $b_k=>
$b_v): if ($b_v->status == 'off') continue;?>
<option value="<?php echo $b_k?>">
<?php echo $b_v->nama;?>
</option>
<?php endforeach?>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" name="submit" value="next">
Selanjutnya »
</button>
</div>
</form>
</div>
</div>
<div class="col-sm-4">
<?php if ($set['smsg_aktif'] > (time() - 300)):?>
<div class="alert alert-success" data-toggle="tooltip" data-title="Transaksi pulsa akan diproses dengan cepat."><strong><i class="glyphicon glyphicon-signal"></i> SMS Gateway ON!</strong></div>
<?php else:?>
<div class="alert alert-warning" data-toggle="tooltip" data-title="Transaksi pulsa akan diproses dengan cepat."><strong><i class="glyphicon glyphicon-signal"></i> SMS Gateway OFF!</strong></div>
<?php endif?>
<ul class="timeline" style="margin-left: 25px;">
<li class="timeline-inverted">
<div class="timeline-badge info">
<i class="glyphicon glyphicon-shopping-cart">
</i>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">
Beli Voucher
</h4>
</div>
<div class="timeline-body">
<p>
Pilih produk / voucher.
</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge danger">
<i class="glyphicon glyphicon-credit-card">
</i>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">
Lakukan Pembayaran
</h4>
</div>
<div class="timeline-body">
<p>
Pembayaran maksimal <?php echo $set['jam_pembayaran'];?> jam.
</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge success">
<i class="glyphicon glyphicon-thumbs-up">
</i>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">
Transaksi Selesai
</h4>
</div>
<div class="timeline-body">
<p>
Pulsa Anda akan terisi.
</p>
</div>
</div>
</li>
</ul>
</div>
</div>
<?php
$foot = '<script>$("#operator").change(function() {
var selectedValue = $("#operator option:selected").val();
var dataProduk = jQuery.parseJSON(\''.str_replace("'","\'",json_encode($my_produk)).'\');
if (dataProduk.token_pln != undefined && dataProduk.token_pln[selectedValue] != undefined) {
$("#data_value1").html(\'<div class="form-group"><label for="id_pln">ID PLN</label><input type="text" class="form-control" name="id_pln" id="id_pln" maxlength="18" minlength="8" required/></div>\');
}
else {
$("#data_value1").html("");
}
$.ajax({
type: "POST",
url: "'.SITE_URL.'ajax.php?c=get_vouchers",
data: {
operator: selectedValue
}
}).done(function(data) {
$("#voucher").html(data);
});
});</script>';
?>
<?php endif;?>
<?php include ('includes/footer.php') ?>