1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.24 2007-04-05 22:59:27 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'};
49 # stuff it back into %content
50 $self->content(%content);
56 #no warnings; #not 5.005
58 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
65 my %content = $self->content();
67 $content{$map{$_}} = $content{$_};
69 $self->content(%content);
74 my %content = $self->content();
76 # warn "$_ = ". ( ref($map{$_})
78 # : $content{$map{$_}} ). "\n";
79 $content{$_} = ref($map{$_})
83 $self->content(%content);
87 my($self,@fields) = @_;
89 my %content = $self->content();
91 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
100 my %content = $self->content;
103 unless ( $content{action} eq 'POSTAUTH'
104 || ( $content{'action'} =~ /^(CREDIT|VOID)$/
105 && exists $content{'order_number'} )
106 || $self->transaction_type() =~ /^check$/i
109 if ( $self->transaction_type() =~
110 /^(cc|visa|mastercard|american express|discover)$/i
113 Carp::croak("LinkPoint can't handle transaction type: ".
114 $self->transaction_type());
117 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
118 or croak "unparsable expiration $content{expiration}";
120 ( $month, $year ) = ( $1, $2 );
121 $month = '0'. $month if $month =~ /^\d$/;
124 $content{'address'} =~ /^(\S+)\s/;
127 my $result = $content{'result'};
128 if ( $self->test_transaction) {
130 #$self->server('staging.linkpt.net');
135 #docs disagree with lpperl.pm here
136 $content{'voidcheck'} = 1
137 if ($self->transaction_type() =~ /^check$/i
138 && $content{'action'} =~ /^VOID$/);
140 $self->revmap_fields(
141 host => \( $self->server ),
142 port => \( $self->port ),
143 #storename => \( $self->storename ),
144 configfile => \( $self->storename ),
145 keyfile => \( $self->keyfile ),
146 addrnum => \$addrnum,
148 cardnumber => 'card_number',
149 cardexpmonth => \$month,
150 cardexpyear => \$year,
151 chargetotal => 'amount',
152 oid => 'order_number',
153 bankname => 'bank_name',
154 routing => 'routing_code',
155 account => 'account_number',
156 accounttype => 'account_type',
157 name => 'account_name',
159 dlstate => 'state_id_state',
162 my $lperl = new LPPERL;
164 my @required_fields = qw(host port configfile keyfile amount);
165 if ($self->transaction_type() =~ /^(cc|visa|mastercard|american express|discover)$/i) {
166 push @required_fields, qw(cardnumber cardexpmonth cardexpyear);
167 }elsif ($self->transaction_type() =~ /^check$/i) {
168 push @required_fields, qw(
169 dl dlstate routing account accounttype bankname bankstate name
172 $self->required_fields(@required_fields);
174 my %post_data = $self->get_fields(qw/
175 host port configfile keyfile
177 chargetotal cardnumber cardexpmonth cardexpyear
178 name email phone addrnum city state zip country
180 dl dlstate routing account accounttype bankname bankstate name void
184 $post_data{'ordertype'} = $content{action};
186 if ( $content{'cvv2'} ) {
187 $post_data{cvmindicator} = 'provided';
188 $post_data{cvmvalue} = $content{'cvv2'};
192 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
198 # %response = $lperl->$action(\%post_data);
200 %response = $lperl->curl_process(\%post_data);
203 warn "$_ => $response{$_}\n" for keys %response;
206 if ( $response{'r_approved'} eq 'APPROVED' ) {
207 $self->is_success(1);
208 $self->result_code($response{'r_code'});
209 $self->authorization($response{'r_ref'});
210 $self->order_number($response{'r_ordernum'});
211 $self->avs_code($response{'r_avs'});
213 $self->is_success(0);
214 $self->result_code('');
215 $self->error_message($response{'r_error'});
225 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
229 use Business::OnlinePayment;
231 my $tx = new Business::OnlinePayment( 'LinkPoint',
232 'storename' => 'your_store_number',
233 'keyfile' => '/path/to/keyfile.pem',
238 action => 'Normal Authorization',
239 description => 'Business::OnlinePayment test',
241 invoice_number => '100100',
242 customer_id => 'jsk',
243 name => 'Jason Kohles',
244 address => '123 Anystreet',
248 email => 'ivan-linkpoint@420.am',
249 card_number => '4007000000027',
250 expiration => '09/99',
254 if($tx->is_success()) {
255 print "Card processed successfully: ".$tx->authorization."\n";
257 print "Card was rejected: ".$tx->error_message."\n";
260 =head1 SUPPORTED TRANSACTION TYPES
262 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
266 For detailed information see L<Business::OnlinePayment>.
270 This module implements an interface to the LinkPoint Perl Wrapper
271 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
273 Versions 0.4 and on of this module support the LinkPoint Perl Wrapper version
280 Ivan Kohler <ivan-linkpoint@420.am>
282 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
286 perl(1), L<Business::OnlinePayment>.