[freeside] Payment types

ivan ivan at 420.am
Tue Jun 13 20:49:41 PDT 2000


On Tue, Jun 13, 2000 at 12:50:15PM -0700, Turtle wrote:
> Ok.. I'm trying to figure out what kind of payment type to use now... It supports
> "Cybercash, Authorize.net, and Verisign (formerly signio)"
> 
> Going to cybercash's website reveals that there is no such thing as a product
> or service called cybercash, only a company, and the only thing that I can guess
> is that it interfaces with Webauthorize?

No, it interfaces with CashRegister for real-time payments. 
<http://www.cybercash.com/cashregister/>.  Sorry about the confusion -
that's the only service they used to offer.  :) 

> Which is the easiest/best one to use?

I don't have enough information to say.

> I would like to use LinkPoint because it has a nice perl module API
> that would make it very easy to do.

If anyone can point out a real-time payment-processing system (that runs
on UNIX or is platform-independant) that I don't support, it's quite
likely I'll add support for it. I'm currently working on Red Hat's CCVS
and Fort Nocs' PaymentAgent.

> Also, I can't immagine how it could possibly interface with authorize.net, because
> in authorize.net the customer is presented with an html form with hidden fields
> that have the amount, etc, and then they are transported to authorize.net's
> site where they enter their credit card info.  There's no way to do this other
> than enter everyone's credit card info every time with authorize.net, unless
> there's some other method not advirtised on their website.  How does this work?

Use the source.  It appears AuthorizeNet has a programmatic interface as
well.

> Also the documentation said that the credit cards can be billed real time but
> you would have to modify site_perl/Bill.pm.   However it doesn't say how or
> why to modify it, or what about it need modifying.

That's no longer necessary - it's controlled with the cybercash2 and
cybercash3.2 configuration files.  Thanks for pointing that out; I've
updated the documentation. 

> What is everyone else using for credit card authorization?  Before I started
> working on freeside I was developing my own version of a similar program and
> I was going to just export a text file with all the info for every credit card
> customer on the 20th of every month, and then import it into PCAuthorize, where
> all 30 or so of our Credit Card customers would be billed simultaneously.  That
> is pretty much what I want to do with Freeside,

This is batch, as opposed to real-time billing.  See
<http://www.sisd.com/freeside/docs/billing.html>.  An example program
which prints the batches (not terribly useful, but a good starting point
for automating this)  was contributed by Joel Griffiths and is attached
(it's also in the current CVS tree and will be included in the next
version). 

> as well as have an interface
> where the customer enters their information and is immediately presented with
> a confirmation screen telling them the status of their signup.

The signup server is documented in htdocs/docs/signup.html.  I suggest
using real-time credit card authorization if you're using the signup
server. 

-- 
meow
_ivan
-------------- next part --------------
#!/usr/bin/perl -Tw

use strict;
#use Date::Format;
use Time::Local;
use Getopt::Std;
use FS::Conf;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::cust_pay;
use FS::cust_pay_batch;

# Get the currennt time and date
my $time = time;
my ($sec,$min,$hour,$mday,$mon,$year) =
	(localtime($time) )[0,1,2,3,4,5]; 
my $_date =
	timelocal($sec,$min,$hour,$mday,$mon,$year);

# Set the mail program
my $mail_program = "/usr/sbin/sendmail -t -n"; 

&untaint_argv;	#what it sounds like  (eww)
use vars qw($opt_v $opt_p $opt_e $opt_a $opt_d);
getopts("vpead");	#switches

# Login to the database
my $user = shift or die &usage;
adminsuidsetup $user;

# Get the needed configuration files
my $conf = new FS::Conf;
my $lpr = $conf->config('lpr');
my $email = $conf->config('email');

my(@batch)=qsearch('cust_pay_batch',{});
if (scalar(@batch) == 0)
{
	exit 1;
}

# Open print and email pipes
# $lpr and opt_p for printing
# $email and opt_e for email
# 
if ($lpr && $main::opt_p)
{
	open(LPR, "|$lpr");
	print LPR qq~C R E D I T  C A R D  P A Y M E N T S  D U E $mon/$mday/$year\n\n~;
}

if ($email && $main::opt_e)
{
	open (MAIL, "|$mail_program");
	print MAIL <<END
To: $email
From: Account Processor
Subject: CREDIT CARD PAYMENTS DUE


C R E D I T  C A R D  P A Y M E N T S  D U E $mon/$mday/$year
END
}

# Now I can start looping
foreach my $cust_pay_batch (@batch)
{
	my $state = $cust_pay_batch->getfield('state');
	my $zip = $cust_pay_batch->getfield('zip');
	my $amount = $cust_pay_batch->getfield('amount');
	my $last = $cust_pay_batch->getfield('last');
	my $address1 = $cust_pay_batch->getfield('address1');
	my $address2 = $cust_pay_batch->getfield('address2');
	my $first = $cust_pay_batch->getfield('first');
	my $city = $cust_pay_batch->getfield('city');
	my $cardnum = $cust_pay_batch->getfield('cardnum');
	my $payname = $cust_pay_batch->getfield('payname');
	my $exp = $cust_pay_batch->getfield('exp');
	my $invnum = $cust_pay_batch->getfield('invnum');
	my $custnum = $cust_pay_batch->getfield('custnum');

	# Need a carriage return in address before address2
	# if it exists. Otherwise address will just be address1
	my $address = $address1;
	$address .= "\n$address2" if ($address2);

	# Only print to the screen in verbose mode
	if ($main::opt_v)
	{
		printf("Invoice %d for %s %s\tCustomer Number: %d\n",
			$invnum,
			$first,
			$last,
			$custnum);

		printf("\t%s\n", $address);
		printf("\t%s, %s, %s\n\n",
			$city,
			$state,
			$zip);

		printf("\tCard Number: %s\tExp:%s\n",
			$cardnum,
			$exp);
		printf("\t\tName: %s\n", $payname);
		printf("\t\tAmount: %.2f\n\n\n", $amount);
	}

	if ($lpr && $main::opt_p)
	{
		printf(LPR "Invoice %d for %s %s\tCustomer Number: %d\n",
			$invnum,
			$first,
			$last,
			$custnum);

		printf(LPR "\t%s\n", $address);
		printf(LPR "\t%s, %s, %s\n\n",
			$city,
			$state,
			$zip);

		printf(LPR "\tCard Number: %s\tExp:%s\n",
			$cardnum,
			$exp);
		printf(LPR "\t\tName: %s\n", $payname);
		printf(LPR "\t\tAmount: %.2f\n\n\n", $amount);
	}

	if ($email && $main::opt_e)
	{
		printf(MAIL "Invoice %d for %s %s\tCustomer Number: %d\n",
			$invnum,
			$first,
			$last,
			$custnum);

		printf(MAIL "\t%s\n", $address);
		printf(MAIL "\t%s, %s, %s\n\n",
			$city,
			$state,
			$zip);

		printf(MAIL "\tCard Number: %s\tExp:%s\n",
			$cardnum,
			$exp);
		printf(MAIL "\t\tName: %s\n", $payname);
		printf(MAIL "\t\tAmount: %.2f\n\n\n", $amount);
	}

	# Now I want to delete the records from cust_pay_batch
	# and mark the records in cust_pay as paid today if
	# the delete (-d) command line option is set.
	if($main::opt_a)
	{
		my $payment=new FS::cust_pay {
			'invnum' => $invnum,
			'paid' => $amount,
			'_date' => $_date,
			'payby' => "CARD",
			'payinfo' => $cardnum,
			'paybatch' => "AUTO",
		};
		
		my $pay_error=$payment->insert;
		if ($pay_error)
			{
				# warn might be better if you get root's mail
				# NEED TO TEST THIS BEFORE DELETE IF WARN IS USED
				die "Could not update cust_pay for invnum $invnum. $pay_error\n";
			}
	}
		
	# This just deletes the records
	# Must be last in the foreach loop
	if($main::opt_d)
	{
		my $del_error = $cust_pay_batch->delete;
		if ($del_error)
		{
			die "Could not delete cust_pay_batch for invnum $invnum. $del_error\n";
		}
	}

}

# Now I need to close LPR and EMAIL if they were open
if($lpr && $main::opt_p)
{
	close LPR || die "Could not close printer: $lpr\n";
}

if($email && $main::opt_e)
{
	close MAIL || die "Could not close printer: $lpr\n";
}


# subroutines
sub untaint_argv {
  foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
    $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
    $ARGV[$_]=$1;
  }
}

sub usage {
  die "Usage:\n\n  freeside-print-batch [-v] [-p] [-e] [-a] [-d] user\n";
}

=head1 NAME

freeside-print-batch - Prints or emails cust_pay_batch. Also deletes
              old records and adds payment to cust_pay.
							Usually run after the bill command.

=head1 SYNOPSIS

  freeside-print-batch [-v] [-p] [-e] [-a] [-d] user

=head1 DESCRIPTION

Prints or emails cust_pay_batch. Can enter payment and delete
printed records. Usually run as a cron job.

-v: Verbose - Prints records to STDOUT.

-p: Print to printer lpr as found in the conf directory.

-e: Email output to user found in the Conf email file.

-a: Automatically pays all records in cust_pay_batch. Use -d with this option usually.

-d:	Delete - Pays account and deletes record from cust_pay_batch.

user: From the mapsecrets file - see config.html from the base documentation

=head1 VERSION

$Id: freeside-print-batch,v 1.1 2000/05/13 21:57:56 ivan Exp $

=head1 BUGS

Yes..... Use at your own risk. No guarantees or warrantees of any
kind apply to this program. Parts of this program are hacked from
other GNU licensed software created mainly by Ivan Kohler.

This is released under the GNU Public License. See www.gnu.org
for more information regarding this license.

=head1 SEE ALSO

L<FS::cust_main>, config.html from the base documentation

=head1 HISTORY

griff at aver-computer.com July 99

$Log: freeside-print-batch,v $
Revision 1.1  2000/05/13 21:57:56  ivan
add print_batch script from Joel Griffiths


=cut




More information about the freeside-users mailing list