Catflowers
Decapat
- Katılım
- 22 Ocak 2022
- Mesajlar
- 226
- Çözümler
- 2
Online kripto ödeme sistemini sayfama entegre etmeye çalışıyorum ama bir türlü edemedim. Otomatik fatura oluşturma sistemini yaptım fakat, kullanıcının faturayı ödedikten sonra sitenin göndermesi gereken bilgileri bir türlü siteme alamadım. Kripto sitesi bu bilgileri göndermek için sayfamı Callback'e girmemi istiyor. Ben de giriyorum ama olmuyor. Benim kodlarımda mı bir sorun var anlayamadım. Bunu anlayabilmek için callback array bilgisine webhook. Site'ın verdiği linki girdim, ardından oluşturduğum test faturasını ödedim direkt orada post olarak sisteme düştü. Sitenin doküman sayfasını okumak için tıkla.
index.html
createandredirect.php Alttaki kodda sorun yaşamadan link oluşturup yönlendirebiliyorum.
odemekontrol.php
Kullanıcı faturayı ödedikten sonra beni tekrardan HTML sayfasına yönlendiriyor Ajax'la gelip gelmediği kontrol ediyorum. Alertte Çıkan sonuç;
Kısacası webhooka düşen json post benim siteme düşmüyor.
index.html
HTML:
<form method="POST" action="createandredirect.php" >
<input type="number" required placeholder="Sayı Gir" name="ucret" min="100" max>
<input type="submit" placeholder="Gönder">
</form>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script>
$(document).ready(function(){
$.ajax({
type: "POST",
url: "odemekontrol.php",
success: function (response) {
alert(response);
}
});
});
</script>
createandredirect.php Alttaki kodda sorun yaşamadan link oluşturup yönlendirebiliyorum.
PHP:
<?php
session_start();
$orderid = mt_rand(1000,9000);
$_SESSION['orderid'] = $orderid;
$ucret = $_POST['ucret'];
$url= 'https://payid19.com/api/v1/create_invoice';
$post = [
'public_key' => 'buraya sitenin verdiği pub keyi giriyorum.',
'private_key' => 'buraya sitenin verdiği private keyi giriyorum',
'email' => '[email protected]',
'price_amount' => $ucret,
'price_currency' => 'TRY',
'merchant_id' => 5,
'order_id' => $orderid,
'customer_id' => 12,
'test' => 1,
'title' => 'test',
'description' => 'test',
'add_fee_to_price' => 1,
'cancel_url' => 'http://localhost:8080/deneme/',
'success_url' => 'http://localhost:8080/deneme/',
'callback_url' => 'http://localhost:8080/deneme/odemekontrol.php',
'expiration_date' => 6,
//'margin_ratio' => 1
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
$result = curl_exec($ch);
curl_close($ch);
if(json_decode($result)->status=='error'){
//error
echo json_decode($result)->message[0];
}else{
//success
$mesaj = json_decode($result)->message;
header("Location: $mesaj");
}
odemekontrol.php
PHP:
<?php
session_start();
$orderid = $_SESSION['orderid'];
$data = json_decode(file_get_contents('php://input')); //catch request data
if($data->privatekey != "private keyimi buraya giriyorum."){ //compare private keys
die;
}
else if($data->order_id == $orderid){
echo "Test";
}
?>
Kullanıcı faturayı ödedikten sonra beni tekrardan HTML sayfasına yönlendiriyor Ajax'la gelip gelmediği kontrol ediyorum. Alertte Çıkan sonuç;
Kısacası webhooka düşen json post benim siteme düşmüyor.
Son düzenleme: