Merhaba arkadaşlar bildirim kısmında post'dan gelen verileri almıyor boş veri gönderiyor nasıl iframe formundan gelen verileri alabilirim.
public function showPayment(){
$paytr=Payment::find(1);
$config=Config::find(1);
$whatsapp=Whatsapp::find(1);
$headerfooters=HeaderFooters::find(1);
$data = request()->all();
$merchant_id = $paytr->paymentsid;
$merchant_key = $paytr->paymentskey;
$merchant_salt = $paytr->paymentssalt;
$urunid = session('urunid');
$adsoyad = session('adsoyad');
$mail = session('mail');
$telefon = session('telefon');
$urunfiyat = session('urunfiyat');
$random_id = "11".rand(1,999).rand(1,88)*rand(1,50);
$email = $mail;
$payment_amount =intval($urunfiyat * 100); //9.99 için 9.99 * 100 = 999 gönderilmelidir.
$merchant_oid = $random_id;
$user_name = $adsoyad;
$user_address = "xxxxxxx";
$user_phone = $telefon;
$merchant_ok_url = "https://siteadresi.net/payments/paytr/onay";
$merchant_fail_url = "https://siteadresi net/payments/paytr/hata";
$user_basket = '1';
$siparisler=new Siparisler;
$siparisler->urunid=session('urunid');
$siparisler->adsoyad=$adsoyad;
$siparisler->mailadres=$mail;
$siparisler->telno=$telefon;
$siparisler->siparisfiyat=$urunfiyat;
$siparisler->paytrid=$random_id;
$siparisler->durum=0;
$siparisler->save();
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;
$timeout_limit = "5";
$debug_on = 1;
$test_mode = 1;
$no_installment = 1;
$max_installment = 0;
$currency = "TL";
$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));
$data_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'=>$debug_on,
'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'=>$timeout_limit,
'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, $data_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 connection error. err:".curl_error($ch));
curl_close($ch);
$result=json_decode($result,1);
if($result['status']=='success')
$token=$result['token'];
else
die("PAYTR IFRAME failed. reason:".$result['reason']);
return view("payments/paytr/callback",compact("token", 'config','whatsapp','headerfooters'));
}
public function showBildirim(){
$data =request()->all();
$paytr=Payment::find(1);
$config=Config::find(1);
$whatsapp=Whatsapp::find(1);
$headerfooters=HeaderFooters::find(1);
$post =$_POST;
$merchant_key = $paytr->paymentskey;
$merchant_salt = $paytr->paymentssalt;
$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');
if( $post['status'] == 'success' ) {
$urunid = session('urunid');
$siparisler=Siparisler::findOrFail($urunid);
$siparisler->durum=1;
$siparisler->save();
return view("payments/paytr/onay",compact('config','whatsapp','headerfooters'));
} else { ## Ödemeye Onay Verilmedi
$urunid = session('urunid');
$siparisler=Siparisler::findOrFail($urunid);
$siparisler->durum=2;
$siparisler->save();
$hatamesaj = $post['failed_reason_msg'];
return view("payments/paytr/hata",compact('config','whatsapp','headerfooters','hatamesaj'));
## $post['failed_reason_code'] - başarısız hata kodu
## $post['failed_reason_msg'] - başarısız hata mesajı
}
}