Bitcoin Forum
June 16, 2024, 09:39:48 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help with XAPO API  (Read 285 times)
BitcoinzB (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100


💰💰💰💰


View Profile
June 01, 2017, 02:12:30 PM
 #1

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
Code:
string(97) "{"error_description": "Invalid transaction type (only 'pay' type available)", "error_code": 7002}" 
with this code:
Code:
<?php

##oauth token

$ch curl_init();

curl_setopt($chCURLOPT_URL"https://v2.api.xapo.com/oauth2/token");
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
curl_setopt($chCURLOPT_HEADERFALSE);
curl_setopt($chCURLOPT_POSTTRUE);
curl_setopt($chCURLOPT_POSTFIELDS"grant_type=client_credentials&redirect_uri=**************");

$basic_token base64_encode("************APP ID:APP secret***********");
curl_setopt($chCURLOPT_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($chCURLOPT_URL"https://v2.api.xapo.com/accounts/****MY ACCOUNT ID*****/transactions");
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
curl_setopt($chCURLOPT_HEADERFALSE);

curl_setopt($chCURLOPT_POSTTRUE);

curl_setopt($chCURLOPT_POSTFIELDS"{
  \"to\": \"test@gmail.com\",
  \"amount\": \"1\",
  \"currency\": \"SAT\",
  \"notes\": \"Random message\",
  \"type\": \"pay_email\"
}"
);

curl_setopt($chCURLOPT_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:
Code:
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? Smiley
botgabe
Full Member
***
Offline Offline

Activity: 229
Merit: 100


View Profile
June 01, 2017, 02:57:54 PM
 #2

Hello!
By default you can send only to "xapo emails"
If you want to send to btc address you need to request this rights to their devs .

You will probably need to upload documents and wait 96hours (or 2 weeks like in my case )

BitcoinzB (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100


💰💰💰💰


View Profile
June 01, 2017, 02:59:53 PM
 #3

Hello!
By default you can send only to "xapo emails"
If you want to send to btc address you need to request this rights to their devs .

You will probably need to upload documents and wait 96hours (or 2 weeks like in my case )


That's exactly what I want to do, send to xapo emails. Nothing else, but it won't let me do it although "pay_email" is activated in my developer app account

You can see the error I get in the first post..

And yes, their support is one of the slowest I've ever seen.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!