@vegaci_shared/vsplit-payment-gateway
Version:
A B2B payment gateway integration package for Stripe with split payment capabilities
120 lines (119 loc) • 3.56 kB
TypeScript
import { Stripe, StripeElements } from '@stripe/stripe-js';
import { VSplitConfig, PaymentSessionConfig, SplitPaymentConfig, PaymentResult, PaymentIntent, SplitPaymentSession, PaymentStatus, PaymentGatewayEvents, RefundRequest, RefundResponse, PaymentVerificationRequest, PaymentVerificationResponse } from './types';
/**
* Main VSplit Payment Gateway class
*/
export declare class VSplitPaymentGateway {
private stripe;
private config;
private apiClient;
private eventEmitter;
private paymentTimer;
private currentSession;
constructor(config: VSplitConfig);
/**
* Initialize Stripe
*/
private initialize;
/**
* Get Stripe instance
*/
getStripe(): Stripe | null;
/**
* Create payment elements
*/
createElements(clientSecret: string): StripeElements | null;
/**
* Initialize a single payment session
*/
initializePayment(config: PaymentSessionConfig): Promise<PaymentResult>;
/**
* Process a single payment
*/
processPayment(paymentIntentId: string, paymentMethod: {
elements: StripeElements;
id?: string;
returnUrl?: string;
}): Promise<PaymentResult>;
/**
* Initialize split payment session
*/
initializeSplitPayment(config: SplitPaymentConfig): Promise<SplitPaymentSession>;
/**
* Process a split payment step
*/
processSplitPayment(sessionId: string, splitIndex: number, paymentMethod: {
elements: StripeElements;
id?: string;
returnUrl?: string;
}): Promise<PaymentResult>;
/**
* Handle split payment timeout
*/
private handleSplitPaymentTimeout;
/**
* Refund partial payments in a split payment session
*/
private refundPartialPayments;
/**
* Cancel current payment
*/
cancelPayment(): Promise<void>;
/**
* Refund a payment
*/
refundPayment(request: RefundRequest): Promise<RefundResponse>;
/**
* Verify a payment
*/
verifyPayment(request: PaymentVerificationRequest): Promise<PaymentVerificationResponse>;
/**
* Get payment status
*/
getPaymentStatus(paymentId: string): Promise<PaymentStatus>;
/**
* Subscribe to events
*/
on<K extends keyof PaymentGatewayEvents>(event: K, callback: PaymentGatewayEvents[K]): void;
/**
* Unsubscribe from events
*/
off<K extends keyof PaymentGatewayEvents>(event: K, callback: PaymentGatewayEvents[K]): void;
/**
* Get current session
*/
getCurrentSession(): PaymentIntent | SplitPaymentSession | null;
/**
* Initialize payment with merchant revenue splitting
* This processes customer payment and then splits revenue between recipients
*/
initializePaymentWithMerchantSplits(config: PaymentSessionConfig & {
merchantSplits?: Array<{
amount: number;
label: string;
recipient: string;
percentage?: number;
}>;
}): Promise<PaymentResult>;
/**
* Process merchant revenue splits after successful payment
*/
processMerchantSplits(paymentIntentId: string, splits: Array<{
amount: number;
label: string;
recipient: string;
}>): Promise<{
success: boolean;
splits: Array<{
amount: number;
label: string;
recipient: string;
id?: string;
}>;
error?: string;
}>;
/**
* Destroy the gateway instance
*/
destroy(): void;
}