PAYTR notification failed: bad hash hatası alıyorum yardımcı olabilir misiniz
nerede hata yapıyprum acaba
$merchant_ok_url = "https://www.site.com/paytr/odeme_basarili.php"; $merchant_fail_url = "https://www.site.com/paytr/odeme_hata.php"; $user_basket = htmlentities(json_encode(array( array("Ürün Hizmet Bedeli Ücreti ", "0.00", 1) ))); srand(time(null)); $merchant_oid = rand(); $test_mode="0"; //3d'siz işlem $non_3d="0"; //Ödeme süreci dil seçeneği tr veya en $client_lang = "tr"; //non3d işlemde, başarısız işlemi test etmek için 1 gönderilir (test_mode ve non_3d değerleri 1 ise dikkate alınır!) $non3d_test_failed="0"; if( isset( $_SERVER["HTTP_CLIENT_IP"] ) ) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif( isset( $_SERVER["HTTP_X_FORWARDED_FOR"] ) ) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } $user_ip = $ip; $email = "testnon3d@paytr.com"; $currency= $_POST['birim']; $username= $_POST['cc_owner']; $tel= $_POST['tel']; $adres= $_POST['adres']; $payment_amount = $_POST['tutar']; $atmail = $_POST['atmail']; // 100.99 TL ödeme // $payment_type = "card"; // $card_type = "bonus"; // Alabileceği değerler; advantage, axess, combo, bonus, cardfinans, maximum, paraf, world, saglamkart $installment_count = "0"; $post_url = "https://www.paytr.com/odeme"; $hash_str = $merchant_id . $user_ip . $merchant_oid . $atmail . $payment_amount . $payment_type . $installment_count. $currency. $test_mode. $non_3d; $token = base64_encode(hash_hmac('sha256',$hash_str.$merchant_salt,$merchant_key,true)); //hash = base64_encode( hash_hmac('sha256', $post['merchant_oid'].$merchant_salt.$post['status'].$post['total_amount'], $merchant_key, true) ); //echo $email; } ?> <div class="wrapper"> <h2>Ödeme / Payment </h2> <form action="<?php echo $post_url;?>" method="post"> <div class="input-group"> <div class="input-box"> <input type="text" name="cc_owner" placeholder="İsim Soyisim / Full Name" class="name" required> <i class="fa fa-user icon"></i> </div> </div> <div class="input-group"> <div class="input-box"> <input type="text" name="atmail" required class="name" placeholder="Email" > <i class="fa fa-envelope icon"></i> </div> </div> <div class="input-group"> <div class="input-box"> <input type="text" name="adres" placeholder="Adres / Adress" class="name" required> <i class="fa fa-map-marker icon"></i> </div> </div> <div class="input-group"> <div class="input-box"> <input type="text" name="tel" placeholder="Telefon / Phone" class="name" id="phoneInput" required> <i class="fa fa-phone icon"></i> </div> </div> <div class="input-group"> <div class="input-box"> <input type="Number" name="tutar" placeholder="Tutar / Amount" class="name" min="1"> <i class="fa fa-money icon"></i> </div> <div class="input-box"> <select name="birim" required> <option class="name" value="">Para Birimi / Currency</option> <option value="TL">TL</option> <option value="USD">USD</option> <option value="EUR">EUR</option> <option value="gbp">GBP</option> </select> </div> </div> <div class="input-group"> <div class="input-box"> <input type="text" placeholder="Kart No / Card Number" required class="name" id="cardNumberInput" maxlength="16" name="card_number"> <i class="fa fa-credit-card icon"></i> </div> </div> <div class="input-group"> <div class="input-box"> <input type="text" placeholder="CVC" required class="name" name="cvv" id="cvcInput" maxlength="3"> <i class="fa fa-user icon"></i> </div> <div class="input-box"> <input type="text" class="name" placeholder="Ay/ Month 01" name="expiry_month" id="expMonthInput" maxlength="2"> </div> <div class="input-box"> <input type="text" class="name" placeholder="Yıl /Year 25" name="expiry_year" id="expYearInput" maxlength="2"> </div> </div> <div class="input-group"> <div class="input-box"> <button type="submit">ŞİMDİ ÖDE / PAY NOW</button> </div> </div> <input type="hidden" name="merchant_id" value="<?php echo $merchant_id;?>"> <input type="hidden" name="user_ip" value="<?php echo $user_ip;?>"> <input type="hidden" name="merchant_oid" value="<?php echo $merchant_oid;?>"> <input type="hidden" name="email" value="<?php echo $atmail;?>" > <input type="hidden" name="payment_type" value="<?php echo $payment_type;?>"> <input type="hidden" name="payment_amount" value="<?php echo $payment_amount;?>"> <input type="hidden" name="currency" value="<?php echo $currency;?>"> <input type="hidden" name="test_mode" value="<?php echo $test_mode;?>"> <input type="hidden" name="non_3d" value="<?php echo $non_3d;?>"> <input type="hidden" name="merchant_ok_url" value="<?php echo $merchant_ok_url;?>"> <input type="hidden" name="merchant_fail_url" value="<?php echo $merchant_fail_url;?>"> <input type="hidden" name="user_name" value="<?php echo $username;?>"> <input type="hidden" name="user_address" value="<?php echo $adres;?>"> <input type="hidden" name="user_phone" value="<?php echo $tel;?>"> <input type="hidden" name="user_basket" value="<?php echo $user_basket; ?>"> <input type="hidden" name="debug_on" value="1"> <input type="hidden" name="client_lang" value="<?php echo $client_lang; ?>"> <input type="hidden" name="paytr_token" value="<?php echo $token; ?>"> <input type="hidden" name="non3d_test_failed" value="<?php echo $non3d_test_failed; ?>"> <input type="hidden" name="installment_count" value="<?php echo $installment_count; ?>"> <input type="hidden" name="card_type" value="<?php echo $card_type; ?>"> </form> </div>onay sayfam
# ## POST değerleri ile hash oluştur. //$hash = base64_encode( hash_hmac('sha256', $post['merchant_oid'].$merchant_salt.$post['status'].$post['total_amount'], $merchant_key, true) ); $hash = base64_encode(hash_hmac('sha256', $post['merchant_oid'] . $merchant_salt . $post['status'] . $post['total_amount'], $merchant_key, true)); echo $hash; # ## Oluşturulan hash'i, paytr'dan gelen post içindeki hash ile karşılaştır (isteğin paytr'dan geldiğine ve değişmediğine emin olmak için) ## Bu işlemi yapmazsanız maddi zarara uğramanız olasıdır. if( $hash != $post['hash'] ) die('PAYTR notification failed: bad hash'); ########################################################################### ## BURADA YAPILMASI GEREKENLER ## 1) Siparişin durumunu $post['merchant_oid'] değerini kullanarak veri tabanınızdan sorgulayın. ## 2) Eğer sipariş zaten daha önceden onaylandıysa veya iptal edildiyse echo "OK"; exit; yaparak sonlandırın. /* Sipariş durum sorgulama örnek $durum = SQL if($durum == "onay" || $durum == "iptal"){ echo "OK"; exit; } */ if( $post['status'] == 'success' ) { ## Ödeme Onaylandı ## BURADA YAPILMASI GEREKENLER ## 1) Siparişi onaylayın. ## 2) Eğer müşterinize mesaj / SMS / e-posta gibi bilgilendirme yapacaksanız bu aşamada yapmalısınız. ## 3) 1. ADIM'da gönderilen payment_amount sipariş tutarı taksitli alışveriş yapılması durumunda ## değişebilir. Güncel tutarı $post['total_amount'] değerinden alarak muhasebe işlemlerinizde kullanabilirsiniz. } else { ## Ödemeye Onay Verilmedi ## BURADA YAPILMASI GEREKENLER ## 1) Siparişi iptal edin. ## 2) Eğer ödemenin onaylanmama sebebini kayıt edecekseniz aşağıdaki değerleri kullanabilirsiniz. ## $post['failed_reason_code'] - başarısız hata kodu ## $post['failed_reason_msg'] - başarısız hata mesajı } ## Bildirimin alındığını PayTR sistemine bildir. echo "OK"; exit; ?>