Billing clients automatically

Hello,

I’m in the process of implementing invoce functionality to my Rails app.
The
service is monthly billed. I already have an Authorize.NET test account.

What I would like to do is bill the customers automatically after a
certain
interval has passed after the last payment, sending them the invoice to
pay
for it again and perform some action if the invoice has not been paid in
time.

What would be the best way to do this? A rails controller running as a
cron
job?

Any help would be much appreciated!

Thanks in advance,

Marcelo.

Take a look at BackgroundRb. Its a great solution for off-line or
background tasks.

http://backgroundrb.rubyforge.org/

On Aug 27, 2:13 pm, “Marcelo de Moraes S.” [email protected]

Marcelo de Moraes S. wrote:

What would be the best way to do this? A rails controller running as a
cron job?

The best way I’ve found is just to add an OfflineProcessController with
the functionality I need. I use a before_filter to validate only the IP
address on which I’m running cron, so nobody else can access these
methods.

I use a little shell script like this:

#!/bin/sh

WGET=/usr/bin/wget
BASEURL=http://my_site.com/offline_process/
LOGFILE=
OPTS=’-q --no-check-certificate -O -’

if [ ! -f $LOGFILE ]; then
touch $LOGFILE
fi

${WGET} ${OPTS} ${BASEURL}do_something | cat >> $LOGFILE
${WGET} ${OPTS} ${BASEURL}do_something_else | cat >> $LOGFILE

…and a crontab entry like…

1,31 * * * * /complete/path/to/script/for/offline_process.sh

I’ve done this several different ways, and this is my favorite at the
moment.

–Al Evans

just to correct some spelling errors:

  • worked better, not best
  • approach, not appreach :stuck_out_tongue:

You can get ARB from Authorize.net ($10/mo) and let them charge the
customer each period instead of sending them a bill. Does the amount
change each month? Then you can use Billing Orchard and load invoices
via a simple API. It stores the credit card and bills a.net each
month or it can send an invoice via email to your customer. BO has an
interface for your customer, too.

Fred

rbaldwin, Al Evans - Thank you very much for the help, I really
appreaciate
it!

@Al Evans: You appreach seems simple and flexible, I’ll definetly try it
out, thanks for the tip!
@rbaldwin: BackgroundRb also seems to be great, as simple as Al Evans
approach… I’ll try it too.

Once I get everything set up and working, I’ll let you know which one
worked
best for me.

Thanks!

Marcelo.

I use a little shell script like this:

If you prefer to write ruby instead of a shell script, you could also
write a custom rake task ( http://railscasts.com/episodes/66 ), and call
that using cron.

Regards,

Chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs