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,100 points
1,151 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,790 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,100 points
878 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,370 points
622 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,100 points

edited Oct 11, 2018 by Omkar 2,703 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,100 points
1,758 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,790 points
1,927 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
45,222 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
885 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
889 views
+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,790 points
1,128 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,790 points
2,007 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