esewa-pay
Version:
A TypeScript SDK for integrating eSewa payments (supports both ESM & CJS)
45 lines (42 loc) • 1.29 kB
text/typescript
interface EsewaConfig {
secretKey: string;
productCode: string;
successUrl: string;
failureUrl: string;
env?: "development" | "production";
}
interface PaymentParams {
amount: string;
tax_amount?: string;
product_service_charge?: string;
product_delivery_charge?: string;
total_amount: string;
transaction_uuid: string;
}
interface VerifyResponse {
transaction_code: string;
status: string;
total_amount: number;
signed_field_names: string;
transaction_uuid: string;
product_code: string;
signature: string;
}
interface StatusResponse {
product_code: string;
transaction_uuid: string;
total_amount: number;
status: string;
ref_id?: string;
}
declare class EsewaClient {
private config;
private baseUrl;
private statusUrl;
constructor(config: EsewaConfig);
generateSignature(total_amount: string, transaction_uuid: string, product_code: string): string;
initiatePayment(params: PaymentParams): Promise<string>;
verifyPayment(data: string): Promise<VerifyResponse>;
getTransactionStatus(transaction_uuid: string, total_amount: string): Promise<StatusResponse>;
}
export { EsewaClient, type EsewaConfig, type PaymentParams, type StatusResponse, type VerifyResponse };