Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set('Asia/Jakarta');
- require_once('../mainconfig.php');
- $email = $_POST['email'];
- $password = $_POST['password'];
- $service = $_POST['service'];
- $data = $_POST['data'];
- $jumlah = $_POST['quantity'];
- $tanggal = date('d-m-Y h:i:s');
- $checkuser = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password'"));
- $apikey = "H_4c1b85790d9f2b27c461c6e259417d73";
- $checkservice = mysql_fetch_array(mysql_query("SELECT * FROM services WHERE name='$service'"));
- $id_service = $checkservice['id'];
- $min = $checkservice['min'];
- $max = $checkservice['max'];
- $harga = $jumlah*($checkservice['price']/1000);
- if(!$apikey){
- echo json_encode(array('result' => 'Orderan Failed' , 'message' => 'Anda siapaa yaa ? '));
- } else if(!$checkservice){
- echo json_encode(array('result' => 'Orderan Failed' , 'message' => 'Service tidak tersedia....'));
- } else if($jumlah < $min){
- echo json_encode(array('result' => 'Orderan Failed' , 'message' => 'Minimal pembelian adalah '.$min.' '));
- } else if($jumlah > $max){
- echo json_encode(array('result' => 'Orderan Failed' , 'message' => 'Maximal pembelian adalah '.$max.' '));
- } else {
- //Mulai order
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"http://kedaisosmed.com/api.php");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- "key=$apikey&action=add&service=$id_service&link=$data&quantity=$jumlah");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $a = curl_exec($ch);
- $hasil = json_decode($a,true);
- $message = $hasil['error'];
- $idorder = $hasil['order'];
- if($message){
- echo json_encode(array('result' => 'Orderan Failed' , 'message' => $message));
- } else {
- echo json_encode(array('result' => 'Orderan Success' , 'message' => 'Pesanan #'.$idorder.' '.$jumlah.' '.$service.' Harga : '.$harga.' Akan segera di proses'));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement