From: ivan Date: Fri, 17 Aug 2001 10:55:04 +0000 (+0000) Subject: Business::OnlinePayment X-Git-Tag: freeside_1_4_0pre11~441 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=7cb7cd1990ccd45f50eabce4ca8a57cf1eb69abd Business::OnlinePayment --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 5804f6868..c3a3e3fc6 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -6,7 +6,8 @@ package FS::cust_main; 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; @@ -71,6 +72,16 @@ $FS::UID::callback{'FS::cust_main'} = sub { $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"; } }; @@ -1019,6 +1030,14 @@ sub collect { 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 @@ -1032,10 +1051,8 @@ sub collect { 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, @@ -1093,6 +1110,73 @@ sub collect { 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"; @@ -1267,7 +1351,7 @@ sub check_invoicing_list { =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 diff --git a/httemplate/docs/config.html b/httemplate/docs/config.html index 9526f697e..0807ac7c7 100644 --- a/httemplate/docs/config.html +++ b/httemplate/docs/config.html @@ -38,6 +38,7 @@ All further configuration files and directories are located in
  • autocapnames - 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.
  • bindprimary - Your BIND primary nameserver. This enables export of /var/named/named.conf and zone files into /var/named
  • bindsecondaries - Your BIND secondary nameservers, one per line. This enables export of /var/named/named.conf +
  • business-onlinepayment - Business::OnlinePayment 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.
  • bsdshellmachines - Your BSD flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd' and `/etc/master.passwd'.
  • countrydefault - Default two-letter country code (if not supplied, the default is `US')
  • cybercash2 - CyberCash v2 support, four lines: paymentserverhost, paymentserverport, paymentserversecret, and transaction type (`mauthonly' or `mauthcapture'). CCLib.pm is required. @@ -96,7 +97,7 @@ All further configuration files and directories are located in
  • soarefresh - SOA refresh for new domains
  • soaretry - SOA retry for new domains
  • statedefault - Default state or province (if not supplied, the default is `CA') -
  • textradiusprepend - 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, '. +
  • textradiusprepend - depriciated, 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.
  • usernamemin - Minimum username length (default 2);
  • usernamemax - Maximum username length (default is the size of the SQL column, probably specified when fs-setup was run)
  • username-letter - The existance of this file will turn on the requirement that usernames contain at least one letter.