Creating an NFT collection with secondary sales fees

I am about to launch a project that I cannot disclose at the moment. Our core business will be based on secondary sales fees. It is not clear to me if it is something that should be coded into an ERC721 contract or if it is something that has to placed within the NFT's metadata. We shall have our NFTs minted from our website and then they must be compatible at least with the marketplace OpenSea (possibly also Rarible). Has anyone any experience about it?

Bests,
FA

What I understand is that , you can setup the royaly/second sales commission in OpenSea or if you are using a custom ERC721 to deploy you can also built in a fee on each transfer in your transfer function. I would suggest, you checkout the Opensea guide and do their sample project to learn how to handle the additional fees, as opensea charges 2.5% of the sales, and if you setup 4%. you will get 1.5%.

I understand, thanks for the reply. My question then become, is I create a custom function for transfer then I must also provide a custom dApp that supports this function to enforce the royalties and it will not be anymore compatible with OpenSea, am I right?

If you wish to use Opensea solely, there is not need to create royaly/secondary sales function. If you wish you deploy/sell elsewhere as well, they you might want one.
Or you can use Opensea functionality to sell else where or embed opensea marketplace in your own site. You can get more details by following the document below.