You can use a smart contract as an agreement between a seller and a buyer when planning a remote purchase.
The main idea is that both seller and buyer send double the value of the item in Ether. When the buyer receives it, they get half of their Ether back. The other half is sent to the seller as payment. Therefore, the seller receives triple the value of their sale, as they also get their Ether refunded.
For your query, you are required to follow a few steps. I would suggest you visit here for the code and functionalities https://www.bitdegree.org/learn/solidity-examples