1 package Business::OnlinePayment::LinkPoint;
4 use vars qw($VERSION @ISA $DEBUG @EXPORT @EXPORT_OK);
6 use Business::OnlinePayment;
8 @ISA = qw(Business::OnlinePayment);
12 use lpperl; #3; #lpperl.pm from LinkPoint
13 $LPPERL::VERSION =~ /^(\d+\.\d+)/
14 or die "can't parse lpperl.pm version: $LPPERL::VERSION";
15 die "lpperl.pm minimum version 3 required\n" unless $1 >= 3;
20 #$self->server('staging.linkpt.net');
21 $self->server('secure.linkpt.net');
24 $self->build_subs(qw(order_number avs_code));
31 my %content = $self->content();
34 my %actions = ('normal authorization' => 'SALE',
35 'authorization only' => 'PREAUTH',
37 'post authorization' => 'POSTAUTH',
40 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
43 my %account_types = ('personal checking' => 'pc',
44 'personal savings' => 'ps',
45 'business checking' => 'bc',
46 'business savings' => 'bs',
48 $content{'account_type'} = $account_types{lc($content{'account_type'})}
49 || $content{'account_type'};
51 # stuff it back into %content
52 $self->content(%content);
58 #no warnings; #not 5.005
60 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
67 my %content = $self->content();
69 $content{$map{$_}} = $content{$_};
71 $self->content(%content);
76 my %content = $self->content();
78 # warn "$_ = ". ( ref($map{$_})
80 # : $content{$map{$_}} ). "\n";
81 $content{$_} = ref($map{$_})
85 $self->content(%content);
89 my($self,@fields) = @_;
91 my %content = $self->content();
93 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
102 my %content = $self->content;
105 unless ( $content{action} eq 'POSTAUTH'
106 || ( $content{'action'} =~ /^(CREDIT|VOID)$/
107 && exists $content{'order_number'} )
108 || $self->transaction_type() =~ /^e?check$/i
111 if ( $self->transaction_type() =~
112 /^(cc|visa|mastercard|american express|discover)$/i
115 Carp::croak("LinkPoint can't handle transaction type: ".
116 $self->transaction_type());
119 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
120 or croak "unparsable expiration $content{expiration}";
122 ( $month, $year ) = ( $1, $2 );
123 $month = '0'. $month if $month =~ /^\d$/;
126 $content{'address'} =~ /^(\d+)\s/;
129 my $result = $content{'result'};
130 if ( $self->test_transaction) {
132 #$self->server('staging.linkpt.net');
137 #docs disagree with lpperl.pm here
138 $content{'voidcheck'} = 1
139 if ($self->transaction_type() =~ /^e?check$/i
140 && $content{'action'} =~ /^VOID$/);
142 $self->revmap_fields(
143 host => \( $self->server ),
144 port => \( $self->port ),
145 #storename => \( $self->storename ),
146 configfile => \( $self->storename ),
147 keyfile => \( $self->keyfile ),
149 chargetotal => 'amount',
151 addrnum => \$addrnum,
152 oid => 'order_number',
154 userid => 'customer_id',
155 ponumber => 'invoice_number',
156 comments => 'description',
157 #reference_number => 'reference_number',
159 cardnumber => 'card_number',
160 cardexpmonth => \$month,
161 cardexpyear => \$year,
163 bankname => 'bank_name',
164 bankstate => 'bank_state',
165 routing => 'routing_code',
166 account => 'account_number',
167 accounttype => 'account_type',
168 name => 'account_name',
170 dlstate => 'state_id_state',
173 my $lperl = new LPPERL;
175 my @required_fields = qw(host port configfile keyfile amount);
176 if ($self->transaction_type() =~ /^(cc|visa|mastercard|american express|discover)$/i) {
177 push @required_fields, qw(cardnumber cardexpmonth cardexpyear);
178 }elsif ($self->transaction_type() =~ /^e?check$/i) {
179 push @required_fields, qw(
180 dl dlstate routing account accounttype bankname bankstate name
183 $self->required_fields(@required_fields);
185 my %post_data = $self->get_fields(qw/
186 host port configfile keyfile
188 chargetotal cardnumber cardexpmonth cardexpyear
189 name company email phone fax addrnum city state zip country
191 dl dlstate routing account accounttype bankname bankstate name void
195 $post_data{'ordertype'} = $content{action};
197 if ( $content{'cvv2'} ) {
198 $post_data{cvmindicator} = 'provided';
199 $post_data{cvmvalue} = $content{'cvv2'};
203 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
204 $post_data{debug} = 'true';
207 $post_data{'cargs'} = '-k -m 300 -s -S' if $self->test_transaction;
209 # avoid some uninitialized warnings in lpperl.pm
210 foreach (qw(webspace debug debugging)) { $post_data{$_} ||= '' }
215 # %response = $lperl->$action(\%post_data);
217 my %response = $lperl->curl_process(\%post_data);
220 warn "$_ => $response{$_}\n" for keys %response;
223 if ( $response{'r_approved'} eq 'APPROVED' ) {
224 $self->is_success(1);
225 $self->result_code($response{'r_code'});
226 $self->authorization($response{'r_ref'});
227 $self->order_number($response{'r_ordernum'});
228 $self->avs_code($response{'r_avs'});
230 $self->is_success(0);
231 $self->result_code('');
232 if ( $response{'r_error'} =~ /\S/ ) {
233 $self->error_message($response{'r_error'});
235 $self->error_message($response{'r_approved'}); # no r_error for checks
246 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
250 use Business::OnlinePayment;
252 my $tx = new Business::OnlinePayment( 'LinkPoint',
253 'storename' => 'your_store_number',
254 'keyfile' => '/path/to/keyfile.pem',
259 action => 'Normal Authorization',
260 description => 'Business::OnlinePayment test',
262 invoice_number => '100100',
263 customer_id => 'jsk',
264 name => 'Jason Kohles',
265 address => '123 Anystreet',
269 email => 'ivan-linkpoint@420.am',
270 card_number => '4007000000027',
271 expiration => '09/99',
275 if($tx->is_success()) {
276 print "Card processed successfully: ".$tx->authorization."\n";
278 print "Card was rejected: ".$tx->error_message."\n";
281 =head1 SUPPORTED TRANSACTION TYPES
283 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
287 For detailed information see L<Business::OnlinePayment>.
291 This module implements an interface to the LinkPoint Perl Wrapper "lpperl",
292 which you need to download and install separately.
293 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
294 http://www.linkpoint.com/viewcart/down_index.htm
296 Versions 0.4 and on of this module support the LinkPoint Perl Wrapper version
303 Ivan Kohler <ivan-linkpoint@420.am>
305 Contributions from Mark D. Anderson <mda@discerning.com>
307 Echeck work by Jeff Finucane <jeff@cmh.net>
309 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
313 perl(1), L<Business::OnlinePayment>.