Not able to send payments using Blockchain API

0 votes

I have installed the API properly and have cross verified it. I can do the basic functions like generating addresses and interacting with wallet. Now I am using the following code 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;

But it does not work. I get the following error:

error : - error: [object object] the response gives me : {"error":"Unexpected error, please try again"}

I don’t understand what the problem is. How do I solve this?

Jul 31, 2018 in Blockchain by digger
• 26,740 points
576 views

1 answer to this question.

0 votes

Try the following code. It should help you solve your problem:

$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 Jul 31, 2018 by slayer
• 29,370 points

Related Questions In Blockchain

0 votes
1 answer

Blockchain Hyperledger private key not able to send coins

From the code you posted, if(whichType == TX_SCRIPTHASH){//pay ...READ MORE

answered Sep 14, 2018 in Blockchain by digger
• 26,740 points
548 views
0 votes
2 answers

Not able to POST chaincode to hyperledger-fabric using API

TypeError: Cannot read property 'curve' of undefined     at ...READ MORE

answered Jan 30, 2019 in Blockchain by SHRADDHA
983 views
+1 vote
1 answer

Unable to send payment using API. Please help.

Firstly, check your passwords, your API code and your wallet ...READ MORE

answered Apr 3, 2018 in Blockchain by Christine
• 15,790 points
1,086 views
0 votes
1 answer
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,882 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,048 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,399 views
0 votes
1 answer

Not able to run chaincode locally using docker

Looks like the Fabric team introduced "nopkcs11" ...READ MORE

answered Sep 18, 2018 in Blockchain by slayer
• 29,370 points
736 views
0 votes
1 answer

Not able to send Ethereum transaction

Hey, Change this line: await crowdsale.sendTransaction({value, from: buyer, gas: ...READ MORE

answered Sep 24, 2018 in Blockchain by slayer
• 29,370 points
644 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