Advertisement
echaa26

Untitled

May 19th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2. require '../config.php';
  3.  
  4. $cekmutasi = $is->query("SELECT * FROM deposit WHERE provider = 'OVO' AND status = 'Pending'");
  5.  
  6.  
  7. while($mutasi = $cekmutasi->fetch_assoc()) {
  8.     $end_date = new DateTime(date('Y-m-d'));
  9.     $start_date = new DateTime($mutasi['daate']);
  10.     $masa_berlaku = $start_date->diff($end_date);
  11.     $data = array(
  12.        
  13.         "search" => array(
  14.            
  15.             "date" =>   array(
  16.                
  17.                 "from" =>  $start_date,
  18.                 "to" => $end_date
  19.                 ),
  20.             "account_number" => "083142182276",
  21.             "amount" => $mutasi['quantity']
  22.             )
  23.         );
  24.        
  25. $ch = curl_init();
  26. curl_setopt_array($ch, array(
  27.    
  28.     CURLOPT_URL => "https://api.cekmutasi.co.id/v1/ovo/search",
  29.     CURLOPT_POST => TRUE,
  30.     CURLOPT_POSTFIELDS => http_build_query($data),
  31.     CURLOPT_HTTPHEADER => ["API-KEY:d673c04d0e7edacb81663caf8bb77d9b"],
  32.     CURLOPT_SSL_VERIFYHOST => 0,
  33.     CURLOPT_SSL_VERIFYPEER => 0,
  34.     CURLOPT_RETURNTRANSFER => TRUE,
  35.     CURLOPT_HEADER => FALSE,
  36.     )
  37.   );
  38.   $chresult = curl_exec($ch);
  39.   curl_close($ch);
  40.  
  41.  
  42.   if($chresult['success'] == TRUE)
  43.   {
  44.       $cekdepo = $is->query("SELECT * FROM deposit WHERE quantity = '".$mutasi['quantity']."' AND status = 'Pending'");
  45.       if($cekdepo->num_rows() == 0)
  46.       {
  47.           echo "Data Not Found";
  48.       } else {
  49.           $cekdepo = $cekdepo->fetch_array();
  50.           $isuser = $is->query("SELECT * FROM user WHERE username = '".$mutasi['username']."' ");
  51.           if($isuser->num_rows() > 0) {
  52.               $isuser = $isuser->fetch_array();
  53.               $zha = "UPDATE user SET saldo = '".$isuser['saldo'] + $cekdepo['quantity']."' WHERE username = '".$isuser['username']."'";
  54.               $is->query($zha);
  55.               $cha = "UPDATE deposit SET status = 'Success' WHERE id = '".$cekdepo['id']."' ";
  56.               $is->query($chaa);
  57.          
  58.               echo "Deposit dengan Jumlah ".$cekdepo['quantity']." telah berhasil dan saldo sudah di terima";
  59.           }
  60.          
  61.       }
  62.   } else {
  63.       $respon = $chresult['error_message'];
  64.      
  65.       echo $respon;
  66.   }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement