How Create a charge by Api?
I filled in my API key but got nothing back
How Create a charge by Api?
I filled in my API key but got nothing back
const axios = require('axios');
let data = JSON.stringify({
"pricing_type": "fixed_price",
"name": "hhhh",
"description": "hhhuuhu"
});
let config = {
method: 'post',
url: 'https://api.commerce.coinbase.com/charges',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CC-Api-Key': 'c6axxxxxx-xxxx-xxxx-xxxx-xxxxxxx72d3'
},
data : data
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Hey @hideegar, Welcome to the forum Community!
To Create a Charge using API, you may use the Create a charge endpoint of Commerce API. For code reference, please have a look at the code-builder available to the right side of the page.
Sample request body is given below:
const axios = require('axios');
let data = JSON.stringify({
"pricing_type": "fixed_price",
"name": "",
"description": "",
"local_price": {
"amount": ,
"currency": ""
}
});
let config = {
method: 'post',
url: 'https://api.commerce.coinbase.com/charges',
headers: {
'X-CC-Version': '2018-03-22',
'Content-Type': 'application/json',
'X-CC-Api-Key': '',
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
We hope this helps. We’d be happy to answer any more questions.
Thank you and have a nice day!