It is perfectly possible, and the easiest for you is a packaged system designed to do exactly what you want.
These are usually called Hot-Spot routers, and come with a ticket printer, and allow you to set the time that people can access the wi-fi, and the access is cut off after that time expires. D-Link used to make one of these, but is now discontinued, however I have found the following from SMC, that appears to do the same thing. It is not particularly cheap, but could save you all the hassle in the long run. The product model number is the SMCWHSG14-G. Have a look at this review, and I think this does what you need.
Just a thought, free access is good, but why not have a Charity box, and ask users to contribute a little into that box when they get their ticket to use the Wi-Fi ? That way you help a good cause, and keep the Customers happy, and get a good reputation