PayFanout API reference
    Preparing search index...

    Interface ServerPaymentAdapter

    interface ServerPaymentAdapter {
        pspName: string;
        cancelPayment(
            pspPaymentId: string,
            idempotencyKey: string,
        ): Promise<PaymentInfo>;
        capturePayment?(
            pspPaymentId: string,
            amount: number | undefined,
            idempotencyKey: string,
        ): Promise<PaymentInfo>;
        chargeSavedPaymentMethod?(
            input: ChargeSavedPaymentMethodInput,
        ): Promise<PaymentInfo>;
        completePayment?(input: CompletePaymentInput): Promise<PaymentInfo>;
        createCustomer?(input: CreateCustomerInput): Promise<CustomerRef>;
        createPaymentSession(
            input: CreatePaymentSessionInput,
        ): Promise<PaymentSession>;
        deleteSavedPaymentMethod?(
            pspCustomerId: string,
            token: string,
        ): Promise<void>;
        fetchEvents?(input?: FetchEventsInput): Promise<FetchEventsResult>;
        getCapabilities(): AdapterCapabilities;
        listPayments?(input?: ListPaymentsInput): Promise<ListPaymentsResult>;
        listRefunds?(input?: ListRefundsInput): Promise<ListRefundsResult>;
        listSavedPaymentMethods?(
            pspCustomerId: string,
        ): Promise<SavedPaymentMethod[]>;
        parseWebhookEvent(
            rawBody: string,
            headers: Record<string, string>,
        ): Promise<UnifiedWebhookEvent>;
        refundPayment(req: RefundRequest): Promise<RefundResult>;
        retrievePayment(pspPaymentId: string): Promise<PaymentInfo>;
        retrieveRefund?(refundId: string): Promise<RefundInfo>;
        savePaymentMethod?(
            input: SavePaymentMethodInput,
        ): Promise<SavedPaymentMethod>;
        updatePaymentSession?(
            input: UpdatePaymentSessionInput,
        ): Promise<PaymentSession>;
        verifyCredentials?(): Promise<VerifyCredentialsResult>;
        verifyPaymentMethod?(input: VerifyPaymentMethodInput): Promise<PaymentInfo>;
        verifyWebhookSignature(
            rawBody: string,
            headers: Record<string, string>,
        ): Promise<boolean>;
    }

    Implemented by

    Index
    pspName: string
    • Only present if getCapabilities().supportsManualCapture. Capture is the canonical double-charge operation — the idempotency key is REQUIRED, and under supportsMultiCapture each partial capture is its own charge with its own key.

      Parameters

      • pspPaymentId: string
      • amount: number | undefined
      • idempotencyKey: string

      Returns Promise<PaymentInfo>

    • Deletes by SavedPaymentMethod.token — the token is dead afterwards.

      Parameters

      • pspCustomerId: string
      • token: string

      Returns Promise<void>

    • Throws PayFanoutError (code "invalid_request") on unparseable payloads; maps genuinely unknown-but-valid event types to type "unknown" rather than throwing.

      Parameters

      • rawBody: string
      • headers: Record<string, string>

      Returns Promise<UnifiedWebhookEvent>

    • Poll a refund to a terminal state. Required whenever getCapabilities().supportsRefunds — refundPayment can return "pending".

      Parameters

      • refundId: string

      Returns Promise<RefundInfo>

    • Webhook handling — same adapter, separate concerns. Both async: future PSPs may need remote key retrieval; the contract stays uniform. MUST operate on the RAW request body bytes/string — re-serializing a parsed body breaks signatures (the conformance suite tests this).

      Parameters

      • rawBody: string
      • headers: Record<string, string>

      Returns Promise<boolean>