UNPKG

node-beamcheckout

Version:
41 lines (40 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BeamCheckout = void 0; class BeamCheckout { constructor(merchantId, apiKey) { this.merchantId = merchantId; this.apiKey = apiKey; } merchantId; apiKey; getHeaders() { return { 'Authorization': `Basic ${Buffer.from(`${this.merchantId}:${this.apiKey}`).toString('base64')}`, 'Content-Type': 'application/json' }; } async createPayment(args) { const res = await fetch(`https://api.beamcheckout.com/purchases/${this.merchantId}`, { method: 'POST', headers: this.getHeaders(), body: JSON.stringify(args), }); return await res.json(); } async getPayment(purchaseId) { const res = await fetch(`https://api.beamcheckout.com/purchases/${this.merchantId}/${purchaseId}/detail`, { method: 'GET', headers: this.getHeaders(), }); return await res.json(); } async disablePayment(purchaseId) { const res = await fetch(`https://api.beamcheckout.com/purchases/${this.merchantId}/${purchaseId}/disable`, { method: 'POST', headers: this.getHeaders(), }); return await res.json(); } } exports.BeamCheckout = BeamCheckout;