Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Blockchain by (12.7k points)

Im trying to send a payment via the blockchain API v2. Im using PHP & Curl.

blockchain-wallet-service : 0.26.0 v node.js : 8.9.0 v

I can generate bitcoin addresses, get my balance and interact with my wallet, but for an unknown reason, I cannot SEND payments via the API, please help I have looked up many websites for answers.

my PHP code ( just testing ) to send a payment :

$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;

on the console I get the following error : - error: [object object] the response gives me : {"error":"Unexpected error, please try again"}

I tested both my passwords, my API code + my wallet ID, all 100% correct.

1 Answer

0 votes
by (29.5k points)
edited by

Try this:

$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 />';

}

Want to make your career in Blockchain? Enroll in Blockchain Course to acquire the essential skills.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 23, 2019 in Blockchain by Abhishek_31 (12.7k points)
0 votes
1 answer

Browse Categories

...