Bitcoin payment system not working

0 votes

The code for callback:

<?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*"; 
} 


?> 

The code to create address and set callback:

<?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!";
}
?>

This is not working. Need help.

Aug 30, 2018 in Blockchain by digger
• 26,740 points
638 views

1 answer to this question.

0 votes

I found the problem, it was actually the callback.php script. You are checking for this:

if ($price >= $value)

which basically means

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

which iss wrong, change it to:

if ($value >= $price)

and this should solve your problem.

answered Aug 30, 2018 by slayer
• 29,350 points

Related Questions In Blockchain

0 votes
2 answers

Why does not India consider Bitcoin as a legal tender?

to be specific there are few logical ...READ MORE

answered Jul 3, 2018 in Blockchain by Priyaj
• 58,090 points
594 views
0 votes
1 answer

Geth 'sendTransaction' not working

When transactions are put in a loop, ...READ MORE

answered Jul 3, 2018 in Blockchain by Omkar
• 69,210 points
1,195 views
0 votes
1 answer

Is it possible to claim Bitcoin Cash from an exchange that does not support it?

You can't claim BCH without knowing private ...READ MORE

answered Jul 17, 2018 in Blockchain by aryya
• 7,450 points
540 views
0 votes
1 answer

My first Hyperledger fabric network is not working

Delete as admin the channel-artifacts folder, down ...READ MORE

answered Aug 10, 2018 in Blockchain by Johnathon
• 9,090 points
1,625 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
43,946 views
0 votes
1 answer

How to get current value of bitcoin?

You can use json_decode to transform it ...READ MORE

answered Aug 20, 2018 in Blockchain by digger
• 26,740 points
578 views
0 votes
1 answer

Cant make transactions in bitcoind.

Fist you should encrypt your wallet: bitcoin-cli encryptwallet ...READ MORE

answered Aug 23, 2018 in Blockchain by slayer
• 29,350 points
542 views
0 votes
1 answer

Intl.NumberFormat() does not show the Bitcoin Ƀ Symbol

According to bitcoin.it (https://en.bitcoin.it/wiki/Bitcoin_symbol), The ISO 4217 currency code for ...READ MORE

answered Aug 27, 2018 in Blockchain by slayer
• 29,350 points
1,898 views
0 votes
1 answer

mingw32 set command not working

From standard cmd, the unquoted original works just ...READ MORE

answered Aug 31, 2018 in Blockchain by slayer
• 29,350 points
418 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP