@sahabaplus/moyasar
Version:
A comprehensive TypeScript SDK for integrating with the Moyasar payment gateway
67 lines • 2.49 kB
TypeScript
import type { ApiClient } from "../../shared/types/index";
import type { Webhook, WebhookPayload, WebhookAttempt, CreateWebhookRequest, UpdateWebhookRequest, ListWebhooksResponse, ListWebhookAttemptsResponse, AvailableEventsResponse, WebhookListOptions, WebhookAttemptListOptions, WebhookVerificationOptions, WebhookEvent, WebhookEventMap } from "./types";
import { TypedEmitter } from "tiny-typed-emitter";
export declare class WebhookService extends TypedEmitter<WebhookEventMap> {
private apiClient;
constructor(params: {
apiClient: ApiClient;
});
/**
* Create a new webhook
*/
create(params: CreateWebhookRequest): Promise<Webhook>;
/**
* List all webhooks
*/
list(options?: WebhookListOptions): Promise<ListWebhooksResponse>;
/**
* Retrieve a specific webhook
*/
retrieve(webhookId: string): Promise<Webhook>;
/**
* Update a webhook
*/
update(webhookId: string, params: UpdateWebhookRequest): Promise<Webhook>;
/**
* Delete a webhook
*/
delete(webhookId: string): Promise<void>;
/**
* Get available webhook events
*/
availableEvents(): Promise<AvailableEventsResponse>;
/**
* Webhook Attempts Sub-service
*/
get attempts(): {
/**
* List all webhook attempts
*/
list: (options?: WebhookAttemptListOptions) => Promise<ListWebhookAttemptsResponse>;
/**
* Retrieve a specific webhook attempt
*/
retrieve: (attemptId: string) => Promise<WebhookAttempt>;
};
/**
* Process incoming webhook payload
* This method should be called from your webhook endpoint
*/
processWebhook(rawPayload: string | Buffer | WebhookPayload, options: WebhookVerificationOptions): Promise<WebhookPayload>;
/**
* Utility method to create type-safe event listeners for payment events
*/
onPaymentEvent(event: WebhookEvent, listener: (payload: WebhookPayload) => void | Promise<void>): this;
/**
* Utility method to listen to all payment events
*/
onAnyPaymentEvent(listener: (payload: WebhookPayload) => void | Promise<void>): this;
/**
* Helper method to extract webhook signature from common header patterns
*/
extractSignature(headers: Record<string, string | string[]>): string | null;
private validateCreateRequest;
private validateUpdateRequest;
private handleError;
}
//# sourceMappingURL=service.d.ts.map