22 lines
524 B
JavaScript
22 lines
524 B
JavaScript
const axios = require('axios');
|
|
const config = require('../config');
|
|
|
|
// Initialize Tap API client
|
|
const tapClient = axios.create({
|
|
baseURL: config.tap.baseURL,
|
|
headers: {
|
|
Authorization: `Bearer ${config.tap.secretKey}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Create a charge via Tap Payments
|
|
* @param {Object} data - payload for /v2/charges
|
|
*/
|
|
async function createCharge(data) {
|
|
const resp = await tapClient.post('/v2/charges', data);
|
|
return resp.data;
|
|
}
|
|
|
|
module.exports = { createCharge }; |