@@ -788,6 +788,18 @@ export type ProxyOptions = {
788788 /** Port to listen on (default: 8402) */
789789 port ?: number ;
790790 routingConfig ?: Partial < RoutingConfig > ;
791+ /**
792+ * Custom payment-enabled fetch function. When provided, replaces the built-in
793+ * x402 payment handler. Use this to integrate alternative payment systems
794+ * (e.g., spend limits, budget enforcement, or custom payment flows).
795+ *
796+ * If not provided, uses built-in createPaymentFetch with walletKey.
797+ */
798+ paymentFetch ?: (
799+ input : RequestInfo | URL ,
800+ init ?: RequestInit ,
801+ preAuth ?: PreAuthParams ,
802+ ) => Promise < Response > ;
791803 /** Request timeout in ms (default: 180000 = 3 minutes). Covers on-chain tx + LLM response. */
792804 requestTimeoutMs ?: number ;
793805 /** Skip balance checks (for testing only). Default: false */
@@ -956,9 +968,10 @@ export async function startProxy(options: ProxyOptions): Promise<ProxyHandle> {
956968 } ;
957969 }
958970
959- // Create x402 payment-enabled fetch from wallet private key
971+ // Create x402 payment-enabled fetch from wallet private key (or use custom paymentFetch)
960972 const account = privateKeyToAccount ( options . walletKey as `0x${string } `) ;
961- const { fetch : payFetch } = createPaymentFetch ( options . walletKey as `0x${string } `) ;
973+ const payFetch =
974+ options . paymentFetch ?? createPaymentFetch ( options . walletKey as `0x${string } `) . fetch ;
962975
963976 // Create balance monitor for pre-request checks
964977 const balanceMonitor = new BalanceMonitor ( account . address ) ;
0 commit comments