@suluk/payments - v0.1.0
    Preparing search index...

    Interface PaymentConnector

    A payment processor behind the unified schema. The CORE flows (authorize/capture/void/refund/sync) are required; the advanced surfaces (customer, tokenize/vault, recurring, webhook) are OPTIONAL — a connector declares them as it gains coverage, and the caller feature-detects. A soft decline is returned as status: FAILURE, never thrown.

    interface PaymentConnector {
        name: string;
        authorize(req: AuthorizeRequest): Promise<PaymentResponse>;
        capture(req: CaptureRequest): Promise<PaymentResponse>;
        void(req: VoidRequest): Promise<PaymentResponse>;
        refund(req: RefundRequest): Promise<RefundResponse>;
        sync(req: SyncRequest): Promise<PaymentResponse>;
        createCustomer?(
            req: { email?: string; metadata?: Record<string, string> },
        ): Promise<{ customerId: string }>;
        tokenize?(
            req: { customerId?: string; paymentMethod: PaymentMethod },
        ): Promise<{ token: Secret }>;
        recurringSetup?(
            req: { customerId: string; paymentMethod: PaymentMethod },
        ): Promise<{ mandateId: string }>;
        recurringCharge?(
            req: {
                mandateId: string;
                amount: MinorAmount;
                merchantTransactionId: string;
            },
        ): Promise<PaymentResponse>;
        recurringRevoke?(req: { mandateId: string }): Promise<void>;
        handleWebhook?(
            raw: string,
            headers: Record<string, string>,
        ): Promise<WebhookEvent>;
        createPaymentSession?(
            req: CreatePaymentSessionRequest,
        ): Promise<ClientSession>;
        createSetupSession?(req: CreateSetupSessionRequest): Promise<ClientSession>;
    }
    Index

    Properties

    name: string

    the processor id, e.g. "stripe".

    Methods

    • create a processor customer (returns its id).

      Parameters

      • req: { email?: string; metadata?: Record<string, string> }

      Returns Promise<{ customerId: string }>

    • set up an off-session mandate for recurring charges.

      Parameters

      Returns Promise<{ mandateId: string }>

    • revoke a recurring mandate.

      Parameters

      • req: { mandateId: string }

      Returns Promise<void>