PropJoe adlı üyeden alıntı: mesajı görüntüle
Bu kodu denermisiniz?
<?php
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$title = "Ödeme Sayfası";
include('../include/header.php');
include('../include/db.php');

if (!isset($_SESSION['kullanici_id'])) {
    header("Location: /giris-yap");
    exit;
}

$cv_id = $_GET['cv_id'] ?? null;
$kullanici_id = $_SESSION['kullanici_id'];

if ($cv_id) {
    $sorgu = $conn->prepare("SELECT * FROM cv_liste WHERE id = ? AND kullanici_id = ?");
    $sorgu->execute([$cv_id, $kullanici_id]);
    $cv = $sorgu->fetch(PDO::FETCH_ASSOC);

    if ($cv) {
        $kullanici_sorgu = $conn->prepare("SELECT * FROM kullanicilar WHERE id = ?");
        $kullanici_sorgu->execute([$kullanici_id]);
        $kullanici = $kullanici_sorgu->fetch(PDO::FETCH_ASSOC);

        if ($kullanici) {
            $merchant_id = '480';
            $merchant_key = 'EySp4NBzPF3A';
            $merchant_salt = 'pcr6ffAdr2n';
            
            $email = $kullanici['email'] ?? null;
            if (empty($email)) {
                echo "<p class='text-danger'>Kullanıcı email bilgisi bulunamadı. Lütfen tekrar deneyin.</p>";
                exit;
            }

            $payment_amount = 5000; // 50.00 TL
            $merchant_oid = time() . rand(1000, 9999);
            $user_name = $kullanici['ad'] . ' ' . $kullanici['soyad'];
            $user_address = $kullanici['adres'] ?? 'Adres bilgisi girilmemiş';
            $user_phone = $kullanici['telefon'] ?? 'Telefon bilgisi girilmemiş';
            $merchant_ok_url = "https://site-ismi/basarili";
            $merchant_fail_url = "https://site-ismi/basarisiz";
            $user_basket = base64_encode(json_encode([
                ["CV " . ($cv['cv_adi'] ?? 'Bilinmeyen'), "50.00", 1]
            ]));

            if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $user_ip = $_SERVER["HTTP_CLIENT_IP"];
            } elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                $user_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else {
                $user_ip = $_SERVER["REMOTE_ADDR"];
            }

            $no_installment = 0;
            $max_installment = 1;
            $currency = "TL";
            $test_mode = "1";
            
            $hash_str = $merchant_id . $user_ip . $merchant_oid . $email . $payment_amount . $user_basket . $no_installment . $max_installment . $currency . $test_mode;
            $paytr_token = base64_encode(hash_hmac('sha256', $hash_str . $merchant_salt, $merchant_key, true));

            $post_vals = array(
                'merchant_id' => $merchant_id,
                'user_ip' => $user_ip,
                'merchant_oid' => $merchant_oid,
                'email' => $email,
                'payment_amount' => $payment_amount,
                'paytr_token' => $paytr_token,
                'user_basket' => $user_basket,
                'debug_on' => 1,
                'no_installment' => $no_installment,
                'max_installment' => $max_installment,
                'user_name' => $user_name,
                'user_address' => $user_address,
                'user_phone' => $user_phone,
                'merchant_ok_url' => $merchant_ok_url,
                'merchant_fail_url' => $merchant_fail_url,
                'timeout_limit' => 30,
                'currency' => $currency,
                'test_mode' => $test_mode
            );

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/get-token");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
            curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
            curl_setopt($ch, CURLOPT_TIMEOUT, 20);

            $result = @curl_exec($ch);

            if(curl_errno($ch))
                die("PAYTR IFRAME bağlantı hatası. err:".curl_error($ch));

            curl_close($ch);

            $result = json_decode($result, 1);

            if($result['status'] == 'success')
                $token = $result['token'];
            else
                die("PAYTR IFRAME hatası. reason:".$result['reason']);
            ?>
            
            <section class="container my-5">
                <h2>Ödeme Yap</h2>
                <p class="lead">Ödeme yapmanız gerekmektedir.</p>
                <script src="https://www.paytr.com/js/iframeResizer.min.js"></script>
                <iframe src="https://www.paytr.com/odeme/guvenli/<?php echo $token;?>" id="paytriframe" frameborder="0" scrolling="no" style="width: 100%;"></iframe>
                <script>iFrameResize({}, '#paytriframe');</script>
            </section>

            <?php
        } else {
            echo "<p class='text-danger'>Kullanıcı bilgileri bulunamadı. Lütfen tekrar deneyin.</p>";
        }
    } else {
        echo "<p class='text-danger'>CV bilgileri bulunamadı. Lütfen tekrar deneyin.</p>";
    }
} else {
    echo "<p class='text-danger'>CV ID bulunamadı. Lütfen tekrar deneyin.</p>";
}

include('../include/footer.php');
?>

Yaşa hocam Çok teşekkür ederim çalıştı.