区块链支付系统,无法正常工作
blockchain payment system, cant get it to work
回调:
<?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!";
}
?>
当我向生成的地址汇款时,除了区块链将该金额发送回我的主地址外,没有发生任何事情。我做错了什么?
我发现了问题。它实际上是 callback.php
脚本。
我正在检查这个:
if ($price >= $value)
这基本上意味着:
if price to be paid > price paid then payment is succesful
错了,lmao。我将其更改为:
if ($value >= $price)
现在可以正常使用了。
回调:
<?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!";
}
?>
当我向生成的地址汇款时,除了区块链将该金额发送回我的主地址外,没有发生任何事情。我做错了什么?
我发现了问题。它实际上是 callback.php
脚本。
我正在检查这个:
if ($price >= $value)
这基本上意味着:
if price to be paid > price paid then payment is succesful
错了,lmao。我将其更改为:
if ($value >= $price)
现在可以正常使用了。