/** * Payment Service * * Simplified service for direct payments on Asset Hub * No escrow, no IPFS - just simple direct transfers */ import EventEmitter from 'eventemitter3'; import type { AssetHubService } from './asset-hub.service'; import type { Logger } from './logger.service'; import type { PaymentIntent, CreatePaymentParams, PaymentVerificationResult, PaymentLink, CreatePaymentLinkParams } from '../types/payment.types'; import type { RetryPolicy } from '../pmt-gateway-assethub'; export interface PaymentServiceConfig { storagePrefix: string; instanceId: string; encryptStorage: boolean; enableRateLimiting: boolean; transactionTimeout: number; retryPolicy: RetryPolicy; } /** * Payment Service * * Handles direct payment transfers on Asset Hub */ export declare class PaymentService extends EventEmitter { private assetHub; private payments; private paymentLinks; private logger; private config; private rateLimiter?; private get storageKey(); private get linksStorageKey(); constructor(assetHub: AssetHubService, logger: Logger, config: PaymentServiceConfig); /** * Create a payment intent * * This creates a payment record but doesn't execute the transfer yet */ createPayment(params: CreatePaymentParams): Promise; /** * Execute a payment (direct transfer) */ executePayment(paymentId: string): Promise; /** * Get a payment by ID */ getPayment(paymentId: string): PaymentIntent | undefined; /** * Get all payments */ getAllPayments(): PaymentIntent[]; /** * Get payments for a merchant */ getMerchantPayments(merchantAddress: string): PaymentIntent[]; /** * Get payments for a buyer */ getBuyerPayments(buyerAddress: string): PaymentIntent[]; /** * Cancel a payment (only if not executed) */ cancelPayment(paymentId: string): Promise; /** * Verify a payment on-chain * * This method queries Asset Hub to verify that: * 1. The transaction exists and is finalized * 2. The transfer matches the payment details * 3. The amount is correct * 4. The recipient is correct * * @param paymentId - Payment ID to verify * @returns Verification result with on-chain data */ verifyPayment(paymentId: string): Promise; /** * Clear all payments (for testing) */ clearAll(): void; /** * Create a payment link * * Payment links allow merchants to accept payments without coding. * Users can visit the link URL and pay directly. * * @param params - Payment link parameters * @returns Payment link with unique ID and shareable URL * * @example * ```typescript * const link = await gateway.createPaymentLink({ * merchant: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', * amount: '10.5', // 10.5 DOT * description: 'Premium subscription', * successUrl: 'https://mysite.com/success', * }); * * // Share the link * const url = gateway.getPaymentLinkUrl(link.id); * console.log('Share this URL:', url); * ``` */ createPaymentLink(params: CreatePaymentLinkParams): PaymentLink; /** * Get a payment link by ID */ getPaymentLink(linkId: string): PaymentLink | undefined; /** * Get all payment links for a merchant */ getMerchantPaymentLinks(merchantAddress: string): PaymentLink[]; /** * Get all payment links */ getAllPaymentLinks(): PaymentLink[]; /** * Deactivate a payment link */ deactivatePaymentLink(linkId: string): void; /** * Get the shareable URL for a payment link */ getPaymentLinkUrl(linkId: string, baseUrl?: string): string; /** * Create payment from link * * This is used by the checkout page to create an actual payment from a link */ createPaymentFromLink(linkId: string, customAmount?: string): Promise; private generatePaymentId; private generateLinkId; private getNetworkFromApi; private getNetworkCurrency; private dotToPlanck; private planckToDot; private saveToStorage; private loadFromStorage; private saveLinksToStorage; private loadLinksFromStorage; } //# sourceMappingURL=payment.service.d.ts.map