Show ads based on credits available in user account

using the code in a web app with a user login option. Logged users can create ADs and view ADs created by another user. Now want to add pricing plans for users, like user can add particular amount to account and this amount reduced based on the impression and interaction on the ADs he created. The amount per impression and interaction will decide by admin. Need to remove the AD, as soon as the balance in his account becomes zero.