<?php session_start();
ob_start();
 if(!isset($_SESSION["id"])){
  header("Location: login");
  exit;
}
if(@$_POST["islem"]=="Stripe"){
  $paytrad=htmlentities($_POST['paytrad'], ENT_QUOTES, "UTF-8");
  $stripe_publishable=htmlentities($_POST['stripe_publishable'], ENT_QUOTES, "UTF-8");
  $stripe_api=htmlentities($_POST['stripe_api'], ENT_QUOTES, "UTF-8");
  $paytrkomisyon=htmlentities($_POST['paytrkomisyon'], ENT_QUOTES, "UTF-8");


 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='stripe_publishable'");
$settings->execute(array($stripe_publishable));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='stripe_api'");
$settings->execute(array($stripe_api));
   
		
 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='7'");
$settings->execute(array($paytrad,$paytrkomisyon));
	
          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='7'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay7" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Ödeme methodu düzenle (Method: Stripe)</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="Stripe">
          </div>

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

   <hr>
            <p class="card-description">
              </p><ul>
                <li>
                  Stripe Dönüş Adresi: <code><?php echo $site; ?>?callback=Stripe</code>
                </li>
              </ul>
            <p></p>
          <hr>
          <div class="form-group">
            <label class="form-group__service-name">API Key</label>
            <input type="text" class="form-control" name="stripe_api" value="<?php echo $payment["stripe_api"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Pushible Key</label>
            <input type="text" class="form-control" name="stripe_publishable" value="<?php echo $payment["stripe_publishable"]; ?>">
          </div>


          <div class="form-group">
            <label class="form-group__service-name">Stripe Komisyon</label>
            <input type="text" class="form-control" pattern="[0-9.]*" required name="paytrkomisyon" 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>