1

打回来:

<?php 
$id =""; 
$pw = "";

$secret = "f8fe526080ec3366eddbb498c6df4e1a"; //md5 hash a unui cuvant 
$address = "1MBF4cGmVac3r561YYRcamqJKN269yk7aD";

if($_GET['secret'] != $secret){ 
echo "Invalid"; 
return; 
} 

if($_GET['mainaddress'] != $address){ 
echo "Invalid"; 
return; 
} 
if (!isset($_GET['btc'])){ 
echo "Invalid"; 
return; 
} 
if (!isset($_GET['value'])){ 
echo "Invalid"; 
return; 
} 

$price = $_GET['btc']; 
$value= $_GET['value'] / 10000000;

if ($price >= $value){ 
$email = "email@yahoo.com"; 
$subject = "Payment Received"; 
$body = "Payment received for invoice #". $_GET['invoice'] . "\r\n" . "Price: " . $price . " BTC" . "\r\n"; 
$headers = "From: GoBets <sales@gobets.pw>". "\r\n"; 
$headers .= "Content-type: text/html\r\n"; 

$mail = mail($email, $subject, $body, $headers);

}else{ 
$mail2 = mail($email, "rekt","hdhdhd",$headers); 
}

if($mail){ 
echo "*ok*"; // return code pentru blockchain 
}

if ($mail2){ 
echo "*ok*"; 
} 


?> 

我创建地址和设置回调 url 的方式:

<?php
session_start();
$secret = "f8fe526080ec3366eddbb498c6df4e1a";   //md5 hash a unui cuvant
$address = "1MBF4cGmVac3r561YYRcamqJKN269yk7aD";  

if ($_GET['test'] == true) {
      echo 'Ignoring Test Callback';
      return;
   }

if(isset($_GET['key'])) {


if ($_GET['key'] == "p1"){
$price_in_usd = 1;
} elseif($_GET['key'] =="p2"){
$price_in_usd = 4.5;
} elseif($_GET['key'] =="p3"){
$price_in_usd = 8;
} elseif($_GET['key'] =="p4"){
$price_in_usd = 15;
}elseif($_GET['key'] == "test"){
$price_in_usd = 0.3;
}else{
echo "Invalid param. Please contact an administrator or try again later";
}

if ($price_in_usd <> ""){

$price_in_btc = file_get_contents("https://blockchain.info/tobtc?currency=USD&value=" . $price_in_usd);
$invoice = $_SESSION['s_ID'] . "-" . rand();
$callback = "http://gobets.pw/purchase/callback.php?invoice=".$invoice."&secret=".$secret."&mainaddress=".$address ."&btc=" . $price_in_btc;
$result = json_decode(file_get_contents("https://blockchain.info/api/receive?method=create&address=".$address."&callback=" .urlencode($callback)), true);
$qrcode = "https://blockchain.info/qr?data=bitcoin:". $result["input_address"]. "?amount=" . $price_in_btc;
echo '<div align="center">';
echo '<img src="'.$qrcode.'"' . 'height="125" width="125"/>' . "</br>";
echo "Invoice #: " . $invoice . "<br>";
echo "Please send <b>" . $price_in_btc ."</b> BTC to <b>".  $result["input_address"] . "</b></br>";
echo "</div>";
}
} else {
    echo "Something went wrong!";
}
?>

当我将钱发送到生成的地址时,什么都没有发生,除了区块链将该金额发送回我的主地址。我究竟做错了什么?

4

1 回答 1

1

我发现了问题。它实际上是callback.php脚本。我正在检查这个:

if ($price >= $value)

这基本上意味着:

if price to be paid > price paid then payment is succesful

这是错误的,lmao。我将其更改为:

if ($value >= $price)

现在它的工作。

于 2015-05-20T18:32:51.033 回答