esnekpos
Version:
Node.js entegrasyon paketi - EsnekPOS ödeme sistemi için resmi olmayan istemci
55 lines (47 loc) • 1.72 kB
JavaScript
/**
* EsnekPOS Client
*/
const PaymentService = require('./services/payment');
const QueryService = require('./services/query');
const RefundService = require('./services/refund');
const MarketplaceService = require('./services/marketplace');
const RecurringService = require('./services/recurring');
const PhysicalPosService = require('./services/physicalPos');
const { BASE_URLS } = require('./constants');
const { validateClientConfig } = require('./validators');
class EsnekPOSClient {
/**
* EsnekPOS istemcisi oluşturur
* @param {Object} options - Yapılandırma seçenekleri
* @param {string} options.merchant - Üye işyeri kodu
* @param {string} options.merchantKey - Üye işyeri anahtarı
* @param {boolean} [options.testMode=false] - Test modu (true: test ortamı, false: gerçek ortam)
*/
constructor(options) {
validateClientConfig(options);
this.config = {
merchant: options.merchant,
merchantKey: options.merchantKey,
testMode: options.testMode || false
};
this.baseUrl = this.config.testMode ? BASE_URLS.TEST : BASE_URLS.PRODUCTION;
// Servis nesnelerini başlat
this.payment = new PaymentService(this);
this.query = new QueryService(this);
this.refund = new RefundService(this);
this.marketplace = new MarketplaceService(this);
this.recurring = new RecurringService(this);
this.physicalPos = new PhysicalPosService(this);
}
/**
* İstemci yapılandırmasını döndürür
* @returns {Object} istemci yapılandırması
*/
getConfig() {
return {
...this.config,
baseUrl: this.baseUrl
};
}
}
module.exports = EsnekPOSClient;