/** * Payments API SDK * Auto-generated — v1.0 */ class PaymentsClient { constructor(token, baseUrl = 'https://api.aikdata.com/v1/payments') { this.token = token; this.baseUrl = baseUrl.replace(/\/$/, ''); } // ── Charges ── /** * Create a new payment charge */ async createCharge(body = null) { return this._request('POST', `/charge`, {}, body); } /** * Retrieve a charge by ID */ async getCharge(id) { return this._request('GET', `/charge/${id}`); } /** * List all charges with pagination */ async listCharges(query = {}) { return this._request('GET', `/charges`, query); } // ── Refunds ── /** * Refund a charge fully or partially */ async createRefund(body = null) { return this._request('POST', `/refund`, {}, body); } // ── HTTP helper ── async _request(method, path, query = {}, body = null) { const url = new URL(this.baseUrl + path); Object.entries(query).forEach(([k, v]) => { if (v !== undefined && v !== null) url.searchParams.set(k, v); }); const opts = { method, headers: { 'Authorization': `Bearer ${this.token}`, 'Content-Type': 'application/json', 'Accept': 'application/json', }, }; if (body && ['POST', 'PUT', 'PATCH'].includes(method)) { opts.body = JSON.stringify(body); } const res = await fetch(url.toString(), opts); return { status: res.status, data: await res.json() }; } } module.exports = { PaymentsClient };