UNPKG

@battle-racing/br-common-lib

Version:

Common library for all Battle Racing Repositorios

35 lines (34 loc) 1.13 kB
import { PAYMENT_PROVIDERS, PAYMENT_STATUSES } from '../../constants'; export type PaymentProviderName = (typeof PAYMENT_PROVIDERS)[keyof typeof PAYMENT_PROVIDERS]; export type PaymentStatus = (typeof PAYMENT_STATUSES)[keyof typeof PAYMENT_STATUSES]; /** * Generic payment provider data that can be reused across different providers * This allows easy switching between Stripe, PayPal, etc. */ export interface PaymentProviderData { provider: PaymentProviderName; paymentIntentId?: string; transactionId: string; amountPaid: number; currency: string; paymentStatus: PaymentStatus; paymentMethod?: string; metadata?: Record<string, any>; } /** * Strategy interface for payment providers */ export interface PaymentProvider { /** * Confirm and validate a purchase from webhook payload */ confirmPurchase(payload: any, signature?: string): Promise<PaymentProviderData>; /** * Validate webhook signature if provided */ validateWebhookSignature?(payload: any, signature: string): boolean; /** * Get provider name */ getProviderName(): string; }