1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.26 2007-04-07 00:00:31 jeff Exp $
6 use vars qw($VERSION @ISA $DEBUG @EXPORT @EXPORT_OK);
9 use Business::OnlinePayment;
13 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
19 use lpperl; #3; #lpperl.pm from LinkPoint
20 $LPPERL::VERSION =~ /^(\d+\.\d+)/
21 or die "can't parse lpperl.pm version: $LPPERL::VERSION";
22 die "lpperl.pm minimum version 3 required\n" unless $1 >= 3;
27 #$self->server('staging.linkpt.net');
28 $self->server('secure.linkpt.net');
31 $self->build_subs(qw(order_number avs_code));
38 my %content = $self->content();
41 my %actions = ('normal authorization' => 'SALE',
42 'authorization only' => 'PREAUTH',
44 'post authorization' => 'POSTAUTH',
47 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
50 my %account_types = ('personal checking' => 'pc',
51 'personal savings' => 'ps',
52 'business checking' => 'bc',
53 'business savings' => 'bs',
55 $content{'account_type'} = $account_types{lc($content{'account_type'})}
56 || $content{'account_type'};
58 # stuff it back into %content
59 $self->content(%content);
65 #no warnings; #not 5.005
67 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
74 my %content = $self->content();
76 $content{$map{$_}} = $content{$_};
78 $self->content(%content);
83 my %content = $self->content();
85 # warn "$_ = ". ( ref($map{$_})
87 # : $content{$map{$_}} ). "\n";
88 $content{$_} = ref($map{$_})
92 $self->content(%content);
96 my($self,@fields) = @_;
98 my %content = $self->content();
100 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
109 my %content = $self->content;
112 unless ( $content{action} eq 'POSTAUTH'
113 || ( $content{'action'} =~ /^(CREDIT|VOID)$/
114 && exists $content{'order_number'} )
115 || $self->transaction_type() =~ /^e?check$/i
118 if ( $self->transaction_type() =~
119 /^(cc|visa|mastercard|american express|discover)$/i
122 Carp::croak("LinkPoint can't handle transaction type: ".
123 $self->transaction_type());
126 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
127 or croak "unparsable expiration $content{expiration}";
129 ( $month, $year ) = ( $1, $2 );
130 $month = '0'. $month if $month =~ /^\d$/;
133 $content{'address'} =~ /^(\S+)\s/;
136 my $result = $content{'result'};
137 if ( $self->test_transaction) {
139 #$self->server('staging.linkpt.net');
144 #docs disagree with lpperl.pm here
145 $content{'voidcheck'} = 1
146 if ($self->transaction_type() =~ /^e?check$/i
147 && $content{'action'} =~ /^VOID$/);
149 $self->revmap_fields(
150 host => \( $self->server ),
151 port => \( $self->port ),
152 #storename => \( $self->storename ),
153 configfile => \( $self->storename ),
154 keyfile => \( $self->keyfile ),
155 addrnum => \$addrnum,
157 cardnumber => 'card_number',
158 cardexpmonth => \$month,
159 cardexpyear => \$year,
160 chargetotal => 'amount',
161 oid => 'order_number',
162 bankname => 'bank_name',
163 bankstate => 'bank_state',
164 routing => 'routing_code',
165 account => 'account_number',
166 accounttype => 'account_type',
167 name => 'account_name',
169 dlstate => 'state_id_state',
172 my $lperl = new LPPERL;
174 my @required_fields = qw(host port configfile keyfile amount);
175 if ($self->transaction_type() =~ /^(cc|visa|mastercard|american express|discover)$/i) {
176 push @required_fields, qw(cardnumber cardexpmonth cardexpyear);
177 }elsif ($self->transaction_type() =~ /^e?check$/i) {
178 push @required_fields, qw(
179 dl dlstate routing account accounttype bankname bankstate name
182 $self->required_fields(@required_fields);
184 my %post_data = $self->get_fields(qw/
185 host port configfile keyfile
187 chargetotal cardnumber cardexpmonth cardexpyear
188 name email phone addrnum city state zip country
190 dl dlstate routing account accounttype bankname bankstate name void
194 $post_data{'ordertype'} = $content{action};
196 if ( $content{'cvv2'} ) {
197 $post_data{cvmindicator} = 'provided';
198 $post_data{cvmvalue} = $content{'cvv2'};
202 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
208 # %response = $lperl->$action(\%post_data);
210 %response = $lperl->curl_process(\%post_data);
213 warn "$_ => $response{$_}\n" for keys %response;
216 if ( $response{'r_approved'} eq 'APPROVED' ) {
217 $self->is_success(1);
218 $self->result_code($response{'r_code'});
219 $self->authorization($response{'r_ref'});
220 $self->order_number($response{'r_ordernum'});
221 $self->avs_code($response{'r_avs'});
223 $self->is_success(0);
224 $self->result_code('');
225 $self->error_message($response{'r_error'});
235 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
239 use Business::OnlinePayment;
241 my $tx = new Business::OnlinePayment( 'LinkPoint',
242 'storename' => 'your_store_number',
243 'keyfile' => '/path/to/keyfile.pem',
248 action => 'Normal Authorization',
249 description => 'Business::OnlinePayment test',
251 invoice_number => '100100',
252 customer_id => 'jsk',
253 name => 'Jason Kohles',
254 address => '123 Anystreet',
258 email => 'ivan-linkpoint@420.am',
259 card_number => '4007000000027',
260 expiration => '09/99',
264 if($tx->is_success()) {
265 print "Card processed successfully: ".$tx->authorization."\n";
267 print "Card was rejected: ".$tx->error_message."\n";
270 =head1 SUPPORTED TRANSACTION TYPES
272 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
276 For detailed information see L<Business::OnlinePayment>.
280 This module implements an interface to the LinkPoint Perl Wrapper
281 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
283 Versions 0.4 and on of this module support the LinkPoint Perl Wrapper version
290 Ivan Kohler <ivan-linkpoint@420.am>
292 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
296 perl(1), L<Business::OnlinePayment>.