0 votes
1 view
in Blockchain by (12.8k 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.8k points)

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

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 23, 2019 in Blockchain by Abhishek_31 (12.8k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...