By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,779 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,779 IT Pros & Developers. It's quick & easy.

billing based on usage concept

P: 32
Hi guys,

I want to implement this logic in my application 'payment based on usage once in every month'.First let me explain my application running PHP & MySQL.

User will access my application for creating ads(image,flash,movie).There is no limit for ad creation.At end of each month we will bill them based on total no of ads created by that user.

I am planned to implement like this:

I will set a crontab that will run once in 15th of each month and calculate the total ads and recorded in DB.I will bill them on 30 th of that month using the details from DB.


Drawback(issue's) :

1) If user is creating ads after 15th.We can't able to bill them at the current month
2) If user is creating an ad on 2nd and he deleted that ad on 14.we can't able to bill that ad also
3) I thought we can set one autoincrement field in the DB.That will be incremented by 1 once user creates an ad.(This logic is not so efficient).


I Like to implement this logic in efficient manner.Any one can give some idea's or suggesstions.

I am looking for some help from you guys.

A.suresh
May 27 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Since Users are probably going to want to be able to look at ads they've been charged for (e.g, billing history), you'll need to keep ads around after you've charged for them.

On the other hand, though, you only want to charge for an ad once (well, at least you're only ethically allowed to charge for an ad once :P).

The easiest thing I can think of would be to add a `billed` or similarly-named field to your ads table. On the 15th, the script would compile a list of all ads that don't have a value for this field. Then it would assign NOW() to those fields.

That way, a User could keep track of not only which ads he was charged for, but also which billing cycle the charge occurred during.

You'll probably also want to create an index for this field.
May 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.