Just use below code and modified according to your need. Note: this is very useful for COD and Prepaid charge…