In most countries, such as South Africa, a patent expires permanently when it reaches 20 years from its application date. In that 20 year period, to be in force, a renewal fee is paid to the patent office and if this renewal fee is not paid when it is due or during any permitted extension period, typically with a fine, then the patent will lapse, not expire.
Under certain circumstances a lapsed patent which has not yet expired can be restored. Lapsing of a patent should not be taken lightly as it has consequences on the enforceability of the patent even after it is restored in terms of Sections 47 and 48 of the Patents Act 57 of 1978 and it may be that a person who commences use of a patent while it is lapsed cannot be stopped after the patent has been restored or must be compensated for their efforts and expenses. In some countries it is not possible or extremely onerous to restore a lapsed patent and proof of the reasons beyond the control of the patentee for lapsing of the patent must be provided, however, the burden of proof is high so it is critical to pay the renewal fees before they fall due. Finally, to be clear, an expired patent is permanently expired and cannot be renewed, revived, or refiled as it would not meet the patentability requirements of novelty and inventive step.
Unlike in South Africa, renewal fees referred to as maintenance fees on US patents are due 3.5, 7.5 and 11.5 years after grant of the patent (in South Africa and many other countries, they are due every year and are called renewals, renewal fees, or annuities). They can be paid for an additional six months after the due date with a surcharge (this actually is a provision of the Paris Convention).
The USPTO provides a web application to view the payment windows for each maintenance fee.