[英]Blockchain api v2: Send payment not working
I am trying to send the btc to the user using blockchain V2 API. 我正在尝试使用区块链V2 API将btc发送给用户。 I have gone through the documentation and using the below code to send the btc to the user.
我已经阅读了文档,并使用以下代码将btc发送给用户。 But it is not being executed.
但是它没有被执行。
<?php
echo " send test<br>";
include 'db_config/connection.php';
$action = "completed";
$order_id = "12345";
$sql = "SELECT * from wallet_config";
$result= $conn->query($sql) or die(mysqli_error($conn));
if ($result->num_rows > 0) {
while($row = $result->fetch_array()) {
$guid = $row['wallet_id'];
$main_password = $row['password'];
$from = $row['wallet'];
}
$amount = 0.01 * 100000000; // 100000000satoshi = 1 btc
$to = "1J528hXvotieFZJkLA66g7NntXCXtNSm78";
$json_url = "https://blockchain.info/merchant/$guid/payment?password=$main_password&to=$to&amount=$amount&from=$from";
echo $json_url;
$json_data = file_get_contents($json_url);
$json_feed = json_decode($json_data);
$message = $json_feed->message;
$tx_hash = $json_feed->tx_hash;
print_r($json_feed);
$sql1 = "UPDATE buy_order set status ='$action', tx_id = '$tx_hash' where order_id = '$order_id'";
$result1=$conn->query($sql1) or die (mysqli_error($conn));
if($result1){
if(!isset($tx_hash)){
echo "Transaction for Order id $order_id not porceeded. Try sending BTC manually.";
}
echo "Order id $order_id marked as $action..";
}else{
echo "Something went wrong... Try Again";
}
}else{
echo "Something went wrong... Try Checking wallet config";
}
echo "<br>last";
?>
The problem is that the transaction is not completed. 问题是事务未完成。 I even tried to echo the $json_feed and it shows nothing.
我什至试图回显$ json_feed ,但什么也没显示。
I really do not understand why it is not working here. 我真的不明白为什么它在这里不起作用。
When i paste the $json_url in the browser, it shows the following error 当我在浏览器中粘贴$ json_url时,它显示以下错误
`<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>`
Did you install library at your local from https://github.com/blockchain/service-my-wallet-v3
? 您是否从
https://github.com/blockchain/service-my-wallet-v3
在本地安装库? if not, install it firstly. 如果不是,请先安装。
Did you create your GUID with this api call? 您是否通过此api调用创建了GUID? as per your error msg, seems you did not create GUID.
根据您的错误消息,似乎您没有创建GUID。 http://localhost:3000/api/v2/create check documentation for details if not created
http:// localhost:3000 / api / v2 / create检查文档以获取详细信息(如果未创建)
then call payment api, your url would be your localhost url like 然后调用付款api,您的网址将是您的本地主机网址,例如
http://localhost:3000/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&fee=$fee
$json_url = "http://localhost:3000/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&fee=$fee";
$json_data = file_get_contents($json_url);
$json_feed = json_decode($json_data);
var_dump($json_feed);
Hope this will help you. 希望这会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.