
Swap-Pay Invoice
Billing module accepting token swap payment for merchants.
About
Swap-Pay Invoice lets one merchant bill in native ETH or an accepted ERC-20. The merchant chooses which tokens to accept, then creates an invoice for a fixed amount, with an optional due date and an optional payer. If no payer is set, anyone may pay. The merchant sees each invoice’s amount, asset, due date, and status. A payer can settle a pending invoice before the due date, either in the invoice currency or by spending another accepted token that is exchanged into that currency in the same payment. The merchant receives the funds, and the invoice is marked paid. The same billing flow can be offered through an API as part of a digital asset management service. The merchant creates an invoice through the API and receives a link to the payment page. When payment completes, a webhook notifies the merchant’s existing system so the payment can be reconciled with the matching account or invoice.
How it's made
# Uniswap The app builds Uniswap v4 Universal Router calldata off-chain (V4Planner and RoutePlanner). The contract does not choose the pool. It pulls the payer's tokenIn through Permit2, calls Universal Router, and checks the result. Unspent tokenIn is refunded, and the Permit2 allowance is cleared before the call returns. Local tests run against an Anvil mainnet fork so the script can use live v4 pool liquidity. # MultiBaas Tested on Sepolia, as MultiBaas works with live testnets and does not support a local mainnet fork. On Sepolia, the invoice and accepted-token lists are retrieved through MultiBaas event queries rather than eth_getLogs, which helps overcome the limitations imposed by RPC providers on eth_getLogs. MultiBaas makes it easier to query and retrieve data that would otherwise be difficult to access efficiently due to the limitations of smart contract data structures.