The payInvoiceERC20 function enables everyone to make an early payment and start earning. The due date of the payment needs to be passed as an argument.
See `payInvoiceERC20Escrow` if you want to make an escrow payment without due date. The payment can be released at a later date.
The _amount and _feeAmount total are transferred to Compound Finance's Comet contract, to earn yield.
The payment details are stored in the paymentMapping.
Parameter _shouldPayOutViaRequestNetwork is a uint8 to save on gas fees (compared to a bool). You can pass a value of 0 if you don't want the payment to be routed through Request Network.
Interact with the payInvoiceERC20 function:
constpaytrContract=newethers.Contract(paytrContractAddress, PaytrABI, signer);awaitpaytrContract.payInvoiceERC20( payeeAddress, feeAddress, dueDate,//in epoch time amount, feeAmount, paymentReference,//bytes shouldPayOutViaRequestNetwork );//example: awaitpaytrContract.payInvoiceERC20("0x67B94473D81D0cd00849D563C94d0432Ac988B49","0xbF7Dc06Bd27BA2C4013cE02380a85aa7fe860f0A",1732779003,100_000_000,//100 USDC5_000_000,//5 USDC fee"0x494e56332d32343034",0//the payment will not be routed through Request Network );
interface IPaytr{functionpayInvoiceERC20(address_payee,address_feeAddress,uint40_dueDate,uint256_amount,uint256_feeAmount,bytescalldata_paymentReference,uint8_shouldPayoutViaRequestNetwork ) external;}IPaytr(deployedPaytrAddress).payInvoiceERC20(address _payee,address _feeAddress,uint40 _dueDate,uint256 _amount,uint256 _feeAmount,bytescalldata _paymentReference,uint8 _shouldPayoutViaRequestNetwork );//exampleIPaytr(deployedPaytrAddress).payInvoiceERC20(0x67B94473D81D0cd00849D563C94d0432Ac988B49,0xbF7Dc06Bd27BA2C4013cE02380a85aa7fe860f0A,1732779003,100_000_000,//100 USDC5_000_000,//5 USDC fee"0x494e56332d32343034",0//the payment will not be routed through Request Network );