v2.5.2
Giriş yap

Php PDO PayTR

zailby9
188 defa görüntülendi

Direk konuya gireceğim tayfun hocanın udemy deki dersini izliyerek bir proje yaptım bu projeye PayTR entegrasyonunu ekledim PayTR entegrasyonunu kulanan arkadaşalr biliyorlardır iki adım var ben 2 adımı yaptım ödeme de ekleniyor veritabanına falan ama birinci adım bir türlü yapamadım. PayTR panelinden Bildirim URL sini belirtmiş olduğum urlyi giriyorum https://site.com/app/callback.php callback kodunu paylaşacağım sizle.

callback.php

<?php

	require __DIR__. '/init.php';

	$post = $_POST;

	$merchant_key 	= 'test';
	$merchant_salt	= 'test';

	$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');

		$siparisSor=$db->prepare("SELECT * FROM balances where order_token=:order_token");
		$siparisSor->execute(array(
			'order_token'=>$post['merchant_oid']
		));
		$siparisCek=$siparisSor->fetch(PDO::FETCH_ASSOC);

	if( $post['status'] == 'success' ) {

		$ayarKaydet=$db->prepare("UPDATE balances SET
			order_status=:order_status
			WHERE order_token={$siparisCek['order_token']}");

		$update=$ayarKaydet->execute(array(
			'order_status' => 1
		));

	} else { ## Ödemeye Onay Verilmedi

		header('Location:' . site_url('payment-failed'));

	}

	## Bildirimin alındığını PayTR sistemine bildir.
	echo "OK";
	exit;
?>

Kod bu şekil burda ok döndürmesi lazım fakat olmuyor ok dönerse eğer ürün sipariş durumunu 1 yapacak ama bir türlü olmuyor eklsik bir şey mi yapıyorum yardımcı olacak varsa sevinirim.

Cevap yaz
Cevaplar (0)
Henüz kimse cevap yazmadı. İlk cevap yazan sen ol!