UNPKG

@sahabaplus/moyasar

Version:

A comprehensive TypeScript SDK for integrating with the Moyasar payment gateway

42 lines 1.27 kB
import { BaseApiClient } from "./base-client"; import { WebhookService } from "../features/webhook/index"; import { InvoiceService } from "../features/invoice/index"; import { PaymentService } from "../features/payment/index"; export class MoyasarClient extends BaseApiClient { constructor(options) { if (options.apiKey.length < 3) { throw new Error(`apiKey is required!, got ${options.apiKey}`); } super(options.apiKey, options); // Initialize feature services this.webhook = new WebhookService({ apiClient: this }); this.invoice = new InvoiceService({ apiClient: this }); this.payment = new PaymentService({ apiClient: this }); } /** * Test the API connection */ async ping() { try { await this.webhook.availableEvents(); return { status: "ok", timestamp: Date.now(), }; } catch (error) { throw error; } } /** * Get client information */ getClientInfo() { return { baseUrl: this.baseUrl, userAgent: "Moyasar-SDK/1.0.0", version: "1.0.0", }; } } //# sourceMappingURL=moyasar-client.js.map