use strict;
use vars qw( @ISA $conf $lpr $processor $xaction $E_NoErr $invoice_from
- $smtpmachine $Debug );
+ $smtpmachine $Debug $bop_processor $bop_login $bop_password
+ $bop_action @bop_options);
use Safe;
use Carp;
use Time::Local;
$xaction,
) = $conf->config('cybercash2');
$processor='cybercash2';
+ } elsif ( $conf->exists('business-onlinepayment') ) {
+ ( $bop_processor,
+ $bop_login,
+ $bop_password,
+ $bop_action,
+ @bop_options
+ ) = $conf->config('business-onlinepayment');
+ $bop_action ||= 'normal authorization';
+ eval "use Business::OnlinePayment";
+ $processor="Business::OnlinePayment::$bop_processor";
}
};
return "Real time card processing not enabled!";
}
+ my $address = $self->address1;
+ $address .= ", ". $self->address2 if $self->address2;
+
+ #fix exp. date
+ #$self->paydate =~ /^(\d+)\/\d*(\d{2})$/;
+ $self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
+ my $exp = "$2/$1";
+
if ( $processor =~ /^cybercash/ ) {
#fix exp. date for cybercash
my $payname = $self->payname ||
$self->getfield('first'). ' '. $self->getfield('last');
- my $address = $self->address1;
- $address .= ", ". $self->address2 if $self->address2;
- my $country = 'USA' if $self->country eq 'US';
+ my $country = $self->country eq 'US' ? 'USA' : $self->country;
my @full_xaction = ( $xaction,
'Order-ID' => $paybatch,
return '';
}
+ } elsif ( $processor =~ /^Business::OnlinePayment::(.*)$/ ) {
+
+ my($payname, $payfirst, $paylast);
+ if ( $self->payname ) {
+ $payname = $self->payname;
+ $payname =~ /^\s*([\w \,\.\-\']*\w)?\s+([\w\,\.\-\']+)$/
+ or do {
+ $dbh->rollback if $oldAutoCommit;
+ return "Illegal payname $payname";
+ };
+ ($payfirst, $paylast) = ($1, $2);
+ } else {
+ $payfirst = $self->getfield('first');
+ $paylast = $self->getfield('first');
+ $payname = "$payfirst $paylast";
+ }
+
+ my $transaction = new Business::OnlinePayment( $1, @bop_options );
+ $transaction->content(
+ 'type' => 'CC',
+ 'login' => $bop_login,
+ 'password' => $bop_password,
+ 'action' => $bop_action,
+ 'amount' => $amount,
+ 'invoice_number' => $cust_bill->invnum,
+ 'customer_id' => $self->custnum,
+ 'last_name' => $paylast,
+ 'first_name' => $payfirst,
+ 'name' => $payname,
+ 'address' => $address,
+ 'city' => $self->city,
+ 'state' => $self->state,
+ 'zip' => $self->zip,
+ 'country' => $self->country,
+ 'card_number' => $self->payinfo,
+ 'expiration' => $exp,
+ );
+ $transaction->submit();
+
+ if ( $transaction->is_success()) {
+ my $cust_pay = new FS::cust_pay ( {
+ 'invnum' => $cust_bill->invnum,
+ 'paid' => $amount,
+ '_date' => '',
+ 'payby' => 'CARD',
+ 'payinfo' => $self->payinfo,
+ 'paybatch' => "$processor:". $transaction->authorization,
+ } );
+ my $error = $cust_pay->insert;
+ if ( $error ) {
+ # gah, even with transactions.
+ $dbh->commit if $oldAutoCommit; #well.
+ my $e = 'WARNING: Card debited but database not updated - '.
+ 'error applying payment, invnum #' . $cust_bill->invnum.
+ " ($processor): $error";
+ warn $e;
+ return $e;
+ }
+ } elsif ( $options{'report_badcard'} ) {
+ $dbh->commit if $oldAutoCommit;
+ return "$processor error, invnum #". $cust_bill->invnum. ': '.
+ $transaction->result_code. ": ". $transaction->error_message;
+ } else {
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ return ''
+ }
+
} else {
$dbh->rollback if $oldAutoCommit;
return "Unknown real-time processor $processor\n";
=head1 VERSION
-$Id: cust_main.pm,v 1.17 2001-08-12 00:07:00 ivan Exp $
+$Id: cust_main.pm,v 1.18 2001-08-17 10:55:04 ivan Exp $
=head1 BUGS
<li><a name="autocapnames">autocapnames</a> - The presence of this file will cause Freeside to use Javascript in /htdocs/edit/cust_main.cgi to automatically capitalize the first and last names of customers.
<li><a name="bindprimary">bindprimary</a> - Your BIND primary nameserver. This enables export of /var/named/named.conf and zone files into /var/named
<li><a name="bindsecondaries">bindsecondaries</a> - Your BIND secondary nameservers, one per line. This enables export of /var/named/named.conf
+ <li><a name="business-onlinepayment">business-onlinepayment</a> - <a href="http://search.cpan.org/search?dist=Business-OnlinePayment">Business::OnlinePayment</a> support, at least three lines: processor, login, and password. An optional fourth line specifies the action. Optional additional lines are passed to Business::OnlinePayment as %processor_options.
<li><a name="bsdshellmachines">bsdshellmachines</a> - Your BSD flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd' and `/etc/master.passwd'.
<li><a name="countrydefault">countrydefault</a> - Default two-letter country code (if not supplied, the default is `US')
<li><a name="cybercash2">cybercash2</a> - <a href="http://www.cybercash.com/cybercash/services/cashreg214.html">CyberCash v2</a> support, four lines: paymentserverhost, paymentserverport, paymentserversecret, and transaction type (`mauthonly' or `mauthcapture'). CCLib.pm is required.
<li><a name="soarefresh">soarefresh</a> - SOA refresh for new domains
<li><a name="soaretry">soaretry</a> - SOA retry for new domains
<li><a name="statedefault">statedefault</a> - Default state or province (if not supplied, the default is `CA')
- <li><a name="textradiusprepend">textradiusprepend</a> - The contents of this file will be prepended to the first line of a user's RADIUS entry in text exports. If necessary, usually `Auth-Type = Local, '.
+ <li><a name="textradiusprepend">textradiusprepend</a> - <b>depriciated<b>, use RADIUS check attributes instead. The contents of this file will be prepended to the first line of a user's RADIUS entry in text exports.
<li><a name="usernamemin">usernamemin</a> - Minimum username length (default 2);
<li><a name="usernamemax">usernamemax</a> - Maximum username length (default is the size of the SQL column, probably specified when fs-setup was run)
<li><a name="usernamemax">username-letter</a> - The existance of this file will turn on the requirement that usernames contain at least one letter.