merhaba arkadaşlar shopier ödeme entegrasyonu yaptım ama başaramadım en son carem burası oldu bana yardımcı olabilirmisiniz entegrasyonun kodunu vereceğim burada ne hata yaptım ben ve shopier geçince bu uyarı verıyor
kodu sizle paylaşıyorum bakarmısınız anlamadım bu hatayı YADA CALISAN BIR KOD VARSA PAYLAŞABILIRMISINIZ
<?php
session_start();
include 'includes/db.php';
include 'includes/shopier_config.php';
$order_id = (int)($_GET['order_id'] ?? 0);
if (!$order_id) {
echo '<div class="alert alert-danger">Sipariş bulunamadı.</div>';
exit;
}
// Sipariş ve kullanıcı bilgisi
$stmt = $pdo->prepare('SELECT o.*, u.username, u.email, u.first_name, u.last_name, u.tc_kimlik_no, u.phone_number, u.billing_address, u.billing_city, u.billing_district, u.billing_country, u.billing_postcode FROM orders o LEFT JOIN users u ON o.user_id = u.id WHERE o.id = ?');
$stmt->execute([$order_id]);
$order = $stmt->fetch();
if (!$order) {
echo '<div class="alert alert-danger">Sipariş bulunamadı.</div>';
exit;
}
// Shopier parametreleri
$buyer_name = $order['first_name'] ?? '';
$buyer_surname = $order['last_name'] ?? '';
$buyer_email = $order['email'] ?? '';
// Telefon, adres, şehir, posta kodu gibi bilgiler users tablosundan çekiliyor
$buyer_phone = $order['phone_number'] ?? '';
$billing_address = $order['billing_address'] ?? '';
$billing_city = $order['billing_city'] ?? '';
$billing_district = $order['billing_district'] ?? ''; // Shopier'da billing_state olarak geçer
$billing_country = $order['billing_country'] ?? 'TR'; // Varsayılan Türkiye
$billing_postcode = $order['billing_postcode'] ?? '';
// Eğer ülke bilgisi TR değilse veya boşsa, Shopier'ın beklediği formata çevir veya varsayılan atama
if (strtoupper($billing_country) === 'TÜRKİYE' || empty($billing_country)) {
$billing_country = 'TR';
}
$shipping_address = $billing_address; // Fatura adresi ile aynı, farklıysa veritabanından çekin
$shipping_city = $billing_city; // Fatura adresi ile aynı, farklıysa veritabanından çekin
$shipping_country = $billing_country; // Fatura adresi ile aynı, farklıysa veritabanından çekin
$shipping_postcode = $billing_postcode; // Fatura adresi ile aynı, farklıysa veritabanından çekin
$order_total_formatted = number_format($order['total'], 2, '.', ''); // Virgül yerine nokta kullanıldı
$order_currency = 'TL'; // 'TRY' yerine 'TL' olarak düzeltildi
$product_name = 'Yazılım Siparişi #' . $order_id;
$random_nr = uniqid(); // Her işlem için benzersiz rastgele sayı
$shopier_args = [
'API_key' => SHOPIER_API_KEY,
'website_index' => 1,
'platform_order_id' => $order_id,
'product_name' => $product_name,
'product_type' => 1, // 1: Dijital/Sanal Ürün (Shopier dökümanına göre)
'buyer_name' => $buyer_name,
'buyer_surname' => $buyer_surname,
'buyer_email' => $buyer_email,
'buyer_account_age' => 1, // Müşteri hesabı yaşı (gün cinsinden). Varsayılan 1.
'buyer_id_nr' => $order['tc_kimlik_no'] ?? '', // Müşterinin TC Kimlik Numarası
'buyer_phone' => $buyer_phone,
'billing_address' => $billing_address,
'billing_city' => $billing_city,
'billing_state' => $billing_district, // İlçe bilgisi Shopier'da billing_state olarak kullanılır
'billing_country' => $billing_country,
'billing_postcode' => $billing_postcode,
'shipping_address' => $shipping_address,
'shipping_city' => $shipping_city,
'shipping_country' => $shipping_country,
'shipping_postcode' => $shipping_postcode,
'total_order_value' => $order_total_formatted,
'currency' => $order_currency,
'platform' => 0, // 0: Web, 1: Mobil, 2: API (Önceki örnekteki 2 yerine 0 daha mantıklı olabilir)
'is_in_frame' => 0, // 0: Yönlendirme, 1: Iframe
'current_language' => 0, // 0: Türkçe, 1: İngilizce
'random_nr' => $random_nr,
'callback_url' => SHOPIER_CALLBACK_URL,
];
// Shopier hash (güvenlik imzası) - EN KAPSAMLI VE MUHTEMELEN DOĞRU HESAPLAMA SIRASI
// Bu sıralama ve parametreler, Shopier'ın çeşitli SDK'larında ve örneklerinde görülen yaygın bir desendir.
// API Anahtarlarınızın (SHOPIER_API_KEY, SHOPIER_API_SECRET) kesinlikle doğru olduğundan emin olun!
$hash_str =
$shopier_args['random_nr'] .
$shopier_args['platform_order_id'] .
$shopier_args['total_order_value'] .
$shopier_args['currency'] .
$shopier_args['website_index'] .
$shopier_args['buyer_name'] .
$shopier_args['buyer_surname'] .
$shopier_args['buyer_email'] .
$shopier_args['buyer_id_nr'] .
$shopier_args['buyer_phone'] .
$shopier_args['billing_address'] .
$shopier_args['billing_city'] .
$shopier_args['billing_country'] .
$shopier_args['billing_postcode'] .
$shopier_args['shipping_address'] .
$shopier_args['shipping_city'] .
$shopier_args['shipping_country'] .
$shopier_args['shipping_postcode'] .
SHOPIER_API_KEY .
SHOPIER_API_SECRET;
$signature = base64_encode(hash_hmac('SHA256', $hash_str, SHOPIER_API_SECRET, true));
$shopier_args['signature'] = $signature;
$shopier_url = 'https://www.shopier.com/ShowProduct/api_pay4.php';
// HTML çıktısı (heredoc syntax)
echo <<<HTML_START
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>Shopier ile Ödeme</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2>Shopier'a Yönlendiriliyorsunuz...</h2>
<p>Lütfen bekleyiniz, ödeme sayfasına yönlendiriliyorsunuz.</p>
<form action="{$shopier_url}" method="post" id="shopierForm">
HTML_START;
foreach ($shopier_args as $k => $v) {
echo '<input type="hidden" name="' . htmlspecialchars($k) . '" value="' . htmlspecialchars($v) . '">';
}
echo <<<HTML_END
</form>
<script>
document.getElementById('shopierForm').submit();
</script>
</div>
</body>
</html>
HTML_END;
exit; // Ödeme işlemi tamamlandığında script'i sonlandır.