In the previous sections, you have learned how to create a request for payment. We will now explain to you how to pay it.
This section is useful if:
- You plan to embed request payment features like a Pay button
- You want to test the payment stage of requests you create
The payment of a request depends on its payment network:
- Address-based payment networks (available for BTC and ERC20) don't have any specific requirement: any payment sent to the specified address will be considered a payment of this request. Never re-use an address!
- Input data payment networks (ETH only) simply requires you to specify the Payment Reference in the data of the transaction.
- Proxy payment networks (ETH and ERC20) require you to call a smart contract method that forwards the payment.
To simplify the payment procedures of the various payment networks, you can use the dedicated library, @requestnetwork/payment-processor. On top of calculating the Payment Reference and handling the transaction for you, it provides a few utilities to ensure the user meets all requirements to pay the request (enough funds for example)
About the payment-processor library
About ERC20 Contract Approval
Because an ERC20 transaction cannot contain input data, we need to go through a smart contract to document the payment. The user must allow this contract to spend tokens on its behalf. Read more here