import { Address, Customer, PaymentSessionStatus } from "../models"; import { MedusaContainer } from "../types/global"; export type PaymentProcessorContext = { billing_address?: Address | null; email: string; currency_code: string; amount: number; resource_id: string; customer?: Customer; context: Record; paymentSessionData: Record; }; export type PaymentProcessorSessionResponse = { update_requests?: { customer_metadata?: Record; }; session_data: Record; }; export interface PaymentProcessorError { error: string; code?: string; detail?: any; } /** * The new payment service plugin interface * This work is still experimental and can be changed until it becomes stable */ export interface PaymentProcessor { /** * Return a unique identifier to retrieve the payment plugin provider */ getIdentifier(): string; /** * Initiate a payment session with the external provider */ initiatePayment(context: PaymentProcessorContext): Promise; /** * Update an existing payment session * @param context */ updatePayment(context: PaymentProcessorContext): Promise; /** * Refund an existing session * @param paymentSessionData * @param refundAmount */ refundPayment(paymentSessionData: Record, refundAmount: number): Promise; /** * Authorize an existing session if it is not already authorized * @param paymentSessionData * @param context */ authorizePayment(paymentSessionData: Record, context: Record): Promise; /** * Capture an existing session * @param paymentSessionData */ capturePayment(paymentSessionData: Record): Promise; /** * Delete an existing session */ deletePayment(paymentSessionData: Record): Promise; /** * Retrieve an existing session */ retrievePayment(paymentSessionData: Record): Promise; /** * Cancel an existing session */ cancelPayment(paymentSessionData: Record): Promise; /** * Return the status of the session */ getPaymentStatus(paymentSessionData: Record): Promise; /** * Update the session data for a payment session */ updatePaymentData(sessionId: string, data: Record): Promise; } /** * Payment processor in charge of creating , managing and processing a payment */ export declare abstract class AbstractPaymentProcessor implements PaymentProcessor { protected readonly container: MedusaContainer; protected readonly config?: Record | undefined; protected constructor(container: MedusaContainer, config?: Record | undefined); static identifier: string; getIdentifier(): string; abstract capturePayment(paymentSessionData: Record): Promise; abstract authorizePayment(paymentSessionData: Record, context: Record): Promise; abstract cancelPayment(paymentSessionData: Record): Promise; abstract initiatePayment(context: PaymentProcessorContext): Promise; abstract deletePayment(paymentSessionData: Record): Promise; abstract getPaymentStatus(paymentSessionData: Record): Promise; abstract refundPayment(paymentSessionData: Record, refundAmount: number): Promise; abstract retrievePayment(paymentSessionData: Record): Promise; abstract updatePayment(context: PaymentProcessorContext): Promise; abstract updatePaymentData(sessionId: string, data: Record): Promise; } /** * Return if the input object is AbstractPaymentProcessor * @param obj */ export declare function isPaymentProcessor(obj: unknown): boolean; /** * Utility function to determine if an object is a processor error * @param obj */ export declare function isPaymentProcessorError(obj: any): obj is PaymentProcessorError;