<?php session_start();
ob_start();
 if(!isset($_SESSION["id"])){
  header("Location: login");
  exit;
}
if(@$_POST["islem"]=="Iyzico"){
  $iyzicoad=htmlentities($_POST['iyzicoad'], ENT_QUOTES, "UTF-8");
  $iyzico_api=htmlentities($_POST['iyzico_api'], ENT_QUOTES, "UTF-8");
  $iyzico_secret=htmlentities($_POST['iyzico_secret'], ENT_QUOTES, "UTF-8");
  $iyzicokomisyon=htmlentities($_POST['iyzicokomisyon'], ENT_QUOTES, "UTF-8");
     
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='iyzico_api'");
$settings->execute(array($iyzico_api));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='iyzico_secret'");
$settings->execute(array($iyzico_secret));

 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='1'");
$settings->execute(array($iyzicoad,$iyzicokomisyon));

          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='1'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay1" class="modal fade" role="dialog">
  <div class="modal-dialog modal-xl">

    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Ödeme methodu düzenle (Method: Iyzico)</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
  <form class="form" action="" method="post">

        <div class="modal-body">

          <div class="form-group">
            <label class="form-group__service-name">Method adı</label>
            <input type="text" class="form-control" readonly="" name="islem" value="Iyzico">
          </div>

          <div class="form-group">
            <label class="form-group__service-name">Görünür adı</label>
            <input type="text" class="form-control" name="iyzicoad" value="<?php echo $payys["gor_ad"]; ?>">
          </div>

   <hr>
            <p class="card-description">
              </p><ul>
                <li>
                  İyzico Callback: <code><?php echo $site; ?>?callback=Iyzico</code>
                </li>
              </ul>
            <p></p>
          <hr>
        
          <div class="form-group">
            <label class="form-group__service-name">İyzico Api Key</label>
            <input type="text" class="form-control" name="iyzico_api" value="<?php echo $payment["iyzico_api"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">İyzico Secret Key</label>
            <input type="text" class="form-control" name="iyzico_secret" value="<?php echo $payment["iyzico_secret"]; ?>">
          </div>

          <div class="form-group">
            <label class="form-group__service-name">İyzico Komisyon</label>
            <input type="text" class="form-control" pattern="[0-9.]*" required name="iyzicokomisyon" value="<?php echo $payys["komisyon"]; ?>">
          </div>

        </div>

          <div class="modal-footer" style="display: flex; justify-content: flex-start;">
            <button type="submit" class="btn guncelle mt-0">
            Ayarları güncelle                   
            </button>
            <a href="?pasif=<?php echo $payys["id"];?>"  class="btn guncelle" style="margin: 0 0 4px 0">Pasifleştir</a>

            <button type="submit" data-dismiss="modal" class="btn guncelle guncelle-dark mt-0">
            Vazgeç                 
            </button>
          </div>
          </form>
    </div>

  </div>
</div>