diff options
author | ivan <ivan> | 2001-08-17 10:55:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-08-17 10:55:04 +0000 |
commit | 7cb7cd1990ccd45f50eabce4ca8a57cf1eb69abd (patch) | |
tree | ec57540ad2b61b5b0afc925757da318382aeeaf5 | |
parent | fc4b3561a0e7ecf9cb18c9dae8814917cd741969 (diff) |
Business::OnlinePayment
-rw-r--r-- | FS/FS/cust_main.pm | 94 | ||||
-rw-r--r-- | httemplate/docs/config.html | 3 |
2 files changed, 91 insertions, 6 deletions
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 <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. @@ -96,7 +97,7 @@ All further configuration files and directories are located in <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. |