UNPKG

@muhammedaksam/sipay-node

Version:

Node.js TypeScript SDK for Sipay payment gateway

96 lines 2.8 kB
import { SipayResource } from './base'; export interface SalesWebhookEvent { sipay_status: string; order_no: string; invoice_id: string; status_code: string; status_description: string; sipay_payment_method: string; credit_card_no: string; transaction_type: 'Auth' | 'Pre-Authorization'; payment_status: '0' | '1'; payment_method: '1' | '2' | '3'; error_code: string; error: string; status: string; hash_key: string; } export interface RecurringWebhookEvent { merchant_key: string; invoice_id: string; order_id: string; product_price: number; plan_code: string; recurring_number: string; status: string; attempts: string; action_date: string; } export interface RefundWebhookEvent { invoice_id: string; order_id: string; amount: number; status: string; hash_key: string; } export interface WebhookValidationResult { isValid: boolean; status?: string; total?: number; invoiceId?: string; orderId?: number; currencyCode?: string; error?: string; } /** * Webhooks resource for handling Sipay webhook events * Provides methods to validate and parse webhook notifications * * Uses the existing validateHashKey utility from utils for hash validation, * which provides full AES-256-CBC decryption compatible with PHP SDK */ export declare class SipayWebhooks extends SipayResource { /** * Validate webhook hash key to ensure request authenticity * Uses the existing validateHashKey utility function */ validateHashKey(hashKey: string, secretKey: string): WebhookValidationResult; /** * Parse sales webhook payload */ parseSalesWebhook(payload: any): SalesWebhookEvent; /** * Parse recurring webhook payload */ parseRecurringWebhook(payload: any): RecurringWebhookEvent; /** * Parse refund webhook payload */ parseRefundWebhook(payload: any): RefundWebhookEvent; /** * Verify sales webhook - validates hash and parses event */ verifySalesWebhook(payload: any, appSecret: string): { isValid: boolean; event?: SalesWebhookEvent; validation?: WebhookValidationResult; error?: string; }; /** * Check if payment was successful based on webhook data */ isPaymentSuccessful(event: SalesWebhookEvent): boolean; /** * Check if payment was pre-authorized (needs confirmation) */ isPaymentPreAuthorized(event: SalesWebhookEvent): boolean; /** * Check if payment failed */ isPaymentFailed(event: SalesWebhookEvent): boolean; /** * Get human-readable payment status */ getPaymentStatusDescription(event: SalesWebhookEvent): string; } //# sourceMappingURL=webhooks.d.ts.map