lumepay-sdk
Version:
SDK for Payment Gateway - Easily verify bank transfer payments
37 lines (32 loc) • 920 B
JavaScript
// src/httpClient.js
const axios = require('axios');
const { PaymentGatewayError } = require('./errors');
class HttpClient {
constructor({ apiKey, baseUrl }) {
this.client = axios.create({
baseURL: baseUrl,
headers: {
'x-api-key': apiKey, // 👈 changed from Authorization Bearer to x-api-key
'Content-Type': 'application/json'
},
timeout: 60000
});
}
async get(path) {
try {
const res = await this.client.get(path);
return res.data;
} catch (error) {
throw new PaymentGatewayError(error.response?.data?.error || error.message);
}
}
async post(path, data) {
try {
const res = await this.client.post(path, data);
return res.data;
} catch (error) {
throw new PaymentGatewayError(error.response?.data?.error || error.message);
}
}
}
module.exports = HttpClient;