@monei-js/node-sdk
Version:
Node.js SDK for MONEI Digital Payment Gateway
80 lines (79 loc) • 2.88 kB
TypeScript
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import { ApplePayDomainApi, BizumApi, PaymentMethodsApi, PaymentsApi, SubscriptionsApi } from './src';
export * from './src';
/**
* Response structure for API exceptions returned by the MONEI API
*/
export type ApiExceptionResponse = {
status: string;
statusCode: number;
requestId: string;
message: string;
requestTime: string;
};
/**
* Exception class for handling MONEI API errors
* Contains detailed information about the error including status, statusCode,
* requestId, and requestTime for debugging and logging purposes
*/
export declare class ApiException extends Error {
status: string;
statusCode: number;
requestId: string;
requestTime: Date;
/**
* Creates a new ApiException instance
* @param res - The API exception response from the MONEI API
*/
constructor(res: ApiExceptionResponse);
}
/**
* Main MONEI SDK client class
* Provides access to MONEI's payment processing APIs including payments,
* payment methods, subscriptions, and Apple Pay domain verification
*/
export declare class Monei {
private apiKey;
private accountId?;
private userAgent;
/** Axios HTTP client instance used for API requests */
client: AxiosInstance;
/** API for managing payments */
payments: PaymentsApi;
/** API for managing payment methods */
paymentMethods: PaymentMethodsApi;
/** API for managing subscriptions */
subscriptions: SubscriptionsApi;
/** API for Apple Pay domain verification */
applePayDomain: ApplePayDomainApi;
/** API for managing Bizum */
bizum: BizumApi;
/**
* Creates a new MONEI SDK client instance
* @param apiKey - Your MONEI API key
* @param options - Additional configuration options including accountId for acting on behalf of merchants,
* userAgent for identifying your application, and any Axios request configuration
*/
constructor(apiKey: string, options?: AxiosRequestConfig & {
accountId?: string;
userAgent?: string;
});
/**
* Set the account ID to act on behalf of a merchant
* @param accountId - The merchant's account ID
* @throws {Error} When trying to set an account ID with the default User-Agent
*/
setAccountId(accountId: string | undefined): void;
/**
* Set a custom User-Agent header
* @param userAgent - Custom User-Agent string to identify your application
*/
setUserAgent(userAgent: string): void;
/**
* Verify webhook signature to ensure the webhook was sent by MONEI
* @param body - Raw request body as string
* @param signature - Signature from the MONEI-Signature header
* @returns boolean indicating if the signature is valid
*/
verifySignature(body: string, signature: string): boolean;
}