Well, since their support seems to be REALLY slow at solving my issues, I'll try my luck here.. I'm sure there's someone who can play with their API structure better than I possibly can.
What I'm trying to do is integrate a xapo cashout option on a custom faucet script. I managed to add FaucetHub and Faucetsystem already without much hassle, but this XAPO thing is giving me a bit of headache, since most of the premade scripts around are for their "V1 API" and apparently the V2 changed it a lot
I registered on their developers page and got my app codes, I have a wallet with them already aswell
Following this -
http://docs.xapo.apiary.io/#I generated the token and started trying to make the transaction code work, without success until now
The error I get is
string(97) "{"error_description": "Invalid transaction type (only 'pay' type available)", "error_code": 7002}"
with this code:
##oauth token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://v2.api.xapo.com/oauth2/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials&redirect_uri=**************");
$basic_token = base64_encode("************APP ID:APP secret***********");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/x-www-form-urlencoded",
"Authorization: Basic ".$basic_token
));
$respons = curl_exec($ch);
curl_close($ch);
$json = json_decode($respons);
##transaction
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://v2.api.xapo.com/accounts/****MY ACCOUNT ID*****/transactions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"to\": \"[email protected]\",
\"amount\": \"1\",
\"currency\": \"SAT\",
\"notes\": \"Random message\",
\"type\": \"pay_email\"
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer ".$json->{'access_token'}
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
?>I then tried to change the transaction "type" scope to "pay" instead of "pay_email" and ended up getting a new error:
string(60) "{"error_description": "Invalid account", "error_code": 7003}"
Which lets me think I'm not getting my account ID right.. I got my account ID from an API request on "accounts" since I couldn't find it anywhere on their website, but maybe that's not the right way to get it
Anyone has any idea on here?