pragma solidity >=0.4.22 <0.7.0; contract Orders { struct Payment { string id; address payable buyerAddress; uint256 paidDate; uint256 refundedDate; } event OrderPaid( string id, address paidAddress, uint256 paidAmount, uint256 date ); mapping(string => Payment) payments; function pay(string memory id) public payable { Order storage order = orders[id]; require(order.createdDate > 0, "Order isn't found"); Payment storage payment = payments[id]; require(payment.paidDate == 0, "The order has been paid"); require( msg.value == order.totalPrice, "The order price doesn't match the value of the transaction" ); order.status = Status.Paid; payments[id] = Payment(id, msg.sender, block.timestamp, 0); emit OrderPaid(id, msg.sender, msg.value, block.timestamp); } }