''OK'' verdikten sonra kullanıcı id'si üzerinden bakiye gönderimi nasıl yapacağım?
Yardımcı olabilecek varmı
<?php
$post = $_POST;
$merchant_key = 'xxxxxx';
$merchant_salt = 'xxxxx';
$hash = base64_encode( hash_hmac('sha256', $post['merchant_oid'].$merchant_salt.$post['status'].$post['total_amount'], $merchant_key, true) );
if( $hash != $post['hash'] )
die('PAYTR notification failed: bad hash');
$merchant_oid = $post['merchant_oid'];
// Veritabanınıza bağlantı sağlayın (bağlantı bilgileri buraya eklenmelidir)
$servername = "localhost";
$username = "xxxxx";
$password = "xxxxx";
$database = "xxxxx";
$conn = mysqli_connect($servername, $username, $password, $database);
$conn->set_charset("utf8");
// Veritabanı bağlantısı kontrolü
if (!$conn) {
die("Veritabanı bağlantısı başarısız: " . mysqli_connect_error());
}
// merchant_oid değerini kullanarak ilgili satırı bulun
$sql = "SELECT id, durum, tutar, odeme_turu, adsoyad, telefon FROM paytr WHERE paytr_id = '$merchant_oid'";
$result = mysqli_query($conn, $sql);
if (!$result) {
die("Sorgu hatası: " . mysqli_error($conn));
}
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$id = $row['id'];
$bagis = $row['tutar'];
$bagis_turu = $row['odeme_turu'];
$adsoyad = $row['adsoyad'];
$telefon = $row['telefon'];
$durum = $row['durum'];
if ($durum == "BAŞARILI")
{
echo "OK";
exit;
}
if ($post['status'] == 'success') {
$sqlUpdate = "UPDATE paytr SET durum = 'BAŞARILI' WHERE id = $id";
$resultUpdate = mysqli_query($conn, $sqlUpdate);
}
else {
$sqlUpdate = "UPDATE paytr SET durum = 'BAŞARISIZ' WHERE id = $id";
$resultUpdate = mysqli_query($conn, $sqlUpdate);
if (!$resultUpdate) {
}
}
}
echo "OK";
exit;
mysqli_close($conn);
?>