Merhaba;
Android bir uygulama var ve buna bağlı php admin panel var uygulama içerisinden yapılan abonelik yada kredi satın alım olduğunda etkinlik sayfasında kullanıcının hangi paketi aldığı ve ücreti yazıyor fakat paket ücretleri değiştirdim ama şuan satın alım olduğunda güncel fiyat bilgisi çekmiyor örneğin 74,99 tl satın alım yapmış php tarafından baktığımda 49,99 tl almış görünüyor örneğin uygulama tarafı php tarafı db tarafı her yere baktım fakat çözüm bulamadım bu sorunu nasıl halledebilirim
Android Kod Tarafı : https://hizliresim.com/af5scp1
Php Kod Tarafı: https://ibb.co/CHTDZfT
Admin panelde görünen kısım: https://ibb.co/5nFw28d
PHP Güncel Veri Çekmiyor
1
●134
- 18-10-2024, 22:35:10
- 18-10-2024, 22:45:55PHP Güncel veriyi çeker, sizde farklı bir muhabbet var.
Uygulamada gösterilen fiyat ile PHP tarafında kaydedilen fiyatın aynı kaynaktan gelmesi gerekiyor. Fiyat bilgisini tek bir yerden (örnek veritabanı / db ) alıp hem uygulamada göstermeli hem de satın alım işleminde kullanmalısınız.
Android:
// Satın alma işlemi tamamlandığında çağrılacak fonksiyon fun onPurchaseComplete(purchase: Purchase) { val priceText = purchase.originalJson.getPriceText() // Kullanıcının gördüğü fiyat val actualPrice = purchase.originalJson.getActualPrice() // Gerçek fiyat (örn: "4999000" mikro birim cinsinden) val currency = purchase.originalJson.getCurrency() // Para birimi (örn: "TRY") // Sunucuya gönderilecek isteği güncelleyin @FormUrlEncoded @POST("action/InAppBilling.php") fun inAppBilling( @Field("type") type: String, @Field("orderId") orderId: String, @Field("productId") productId: String, @Field("priceText") priceText: String, @Field("actualPrice") actualPrice: String, @Field("currency") currency: String ): Call<Status_Model> // İsteği gönderin apiService.inAppBilling( type = "purchase", orderId = purchase.orderId, productId = purchase.sku, priceText = priceText, actualPrice = actualPrice, currency = currency ).enqueue(/* ... */) }PHP:
private function addKredi(){ // Gelen fiyat bilgilerini al $priceText = $_POST["priceText"]; $actualPrice = $_POST["actualPrice"]; $currency = $_POST["currency"]; // Ürün ID'sine göre beklenen fiyatı al $expectedPrice = $this->getExpectedPrice($this->product["id"], $currency); // Fiyat doğrulaması yap if ($this->validatePrice($actualPrice, $expectedPrice)) { // Fiyat doğruysa işleme devam et $updateStatus = $this->db->updatePrePare("kullanicilar", "kredi=kredi+".$this->product["kredi"], "id=:id", ["id" => $this->userId]); $this->statusModel->setKredi($this->product["kredi"]); $this->statusModel->setStatus($updateStatus); $this->db->addLog( $this->userId, $this->userEmail, $this->product["id"], "buy-kredi", $this->product["kredi"], $this->product["kredi"]." Kredi Satın Aldı (".$this->product["productId"].")", $priceText." Ödeme yapıldı", $updateStatus, $actualPrice, $currency ); } else { // Fiyat doğru değilse hata loglama veya işlemi reddetme $this->logPriceError($this->product["id"], $expectedPrice, $actualPrice, $currency); } } private function getExpectedPrice($productId, $currency) { // Veritabanından veya başka bir kaynaktan beklenen fiyatı al // Örnek: return $this->db->query("SELECT price FROM products WHERE id = ? AND currency = ?", [$productId, $currency])->fetchColumn(); } private function validatePrice($actualPrice, $expectedPrice) { // Fiyat doğrulama mantığı (örneğin, %1 tolerans ile) $tolerance = 0.01; // %1 tolerans $minAcceptable = $expectedPrice * (1 - $tolerance); $maxAcceptable = $expectedPrice * (1 + $tolerance); return ($actualPrice >= $minAcceptable && $actualPrice <= $maxAcceptable); } private function logPriceError($productId, $expectedPrice, $actualPrice, $currency) { // Fiyat uyuşmazlığını logla error_log("Price mismatch for product $productId: Expected $expectedPrice $currency, got $actualPrice $currency"); }Bu kodları deneyin bakalım sonuç ne olacak.