Unable to send payment using API. Please help.

+1 vote

I'm using PHP & Curl and can generate bitcoin addresses, get my balance and interact with my wallet, but for some reason I am unable to send a payment via the blockchain API v2. Following is my PHP code:

$my_api_key = 'xxxxx';
$guid='xxxxx';
$firstpassword='xxxx';
$second_password = "xxxx";
$amount = '30000';
$to = '1AQDhKrjvAonjLAUv4PzM9NjGzZZ4HEpU1';
$fee = '2000';

$root_url = 'http://localhost:3000/merchant/'.$guid.'/payment';
$parameters = 'to='.$to.'&amount='.$amount.'&password='.$firstpassword.'&fee='.$fee.'&second_password='.$second_password;

$response = Curl::to($root_url . '?' . $parameters)->get();


return $response;


 I am getting the following error : - 
{"error":"Unexpected error, please try again"}
Apr 3, 2018 in Blockchain by Perry
• 17,090 points
178 views

1 answer to this question.

+1 vote
Best answer

Firstly, check your passwords, your API code and your wallet ID. If the problem still persists, then make sure that the blockchain wallet services are running on your server on port 3000. 

You can check the working of blockchain wallet services by hitting the url in browser i.e. http://localhost:3000. if its giving response error "Not found" that means your blockchain wallet services are running. To send bitcoins to many users at a time, you can use the following API:

http://localhost:3000/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&fee=$fee

or use the following:

$address = null;

try {
    // Uncomment to send
    // var_dump($Blockchain->Wallet->send($address, "0.001"));
} catch (\Blockchain\Exception\ApiError $e) {
    echo $e->getMessage() . '<br />';
}

// Multi-recipient format
$recipients = array();
$recipients[$address] = "0.001";

try {
    // Uncomment to send
// var_dump($Blockchain->Wallet->sendMany($recipients));
} catch (Blockchain_ApiError $e) {
echo $e->getMessage() . '<br />';
}
answered Apr 3, 2018 by Christine
• 15,810 points

selected Aug 3, 2018 by Omkar

Related Questions In Blockchain

0 votes
1 answer

Unable to request channel creation using Rest Api

I'd recommend taking a look at the ordering ...READ MORE

answered Jul 16, 2018 in Blockchain by Perry
• 17,090 points
148 views
0 votes
1 answer

Not able to send payments using Blockchain API.

Try the following code. It should help ...READ MORE

answered Jul 31, 2018 in Blockchain by slayer
• 29,240 points
52 views
+4 votes
2 answers

I am unable to connect Ganache with Truffle/Npm Dev server. Pls help.

The issue is at CurrentProvider. Give the url ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,090 points

edited Oct 11, 2018 by Omkar 374 views
0 votes
1 answer

Send Payment error in Blockchain API

The following code should help: $address = null; try ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,090 points
307 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
188 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,600 points
5,326 views
0 votes
0 answers

Blockchain.info wallet API callback

I am implementing blockchain.info wallet api to ...READ MORE

Jul 4, 2018 in Blockchain by sabby
• 4,370 points
224 views
0 votes
1 answer
+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,810 points
312 views
+1 vote
1 answer

How can I connect to the specified nodes using IPFS?

You can actually connect to the specific ...READ MORE

answered Apr 25, 2018 in Blockchain by Christine
• 15,810 points
495 views