1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.23 2005-01-07 02:53:50 ivan 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'} )
108 if ( $self->transaction_type() =~
109 /^(cc|visa|mastercard|american express|discover)$/i
112 Carp::croak("LinkPoint can't handle transaction type: ".
113 $self->transaction_type());
116 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
117 or croak "unparsable expiration $content{expiration}";
119 ( $month, $year ) = ( $1, $2 );
120 $month = '0'. $month if $month =~ /^\d$/;
123 $content{'address'} =~ /^(\S+)\s/;
126 my $result = $content{'result'};
127 if ( $self->test_transaction) {
129 #$self->server('staging.linkpt.net');
134 $self->revmap_fields(
135 host => \( $self->server ),
136 port => \( $self->port ),
137 #storename => \( $self->storename ),
138 configfile => \( $self->storename ),
139 keyfile => \( $self->keyfile ),
140 addrnum => \$addrnum,
142 cardnumber => 'card_number',
143 cardexpmonth => \$month,
144 cardexpyear => \$year,
145 chargetotal => 'amount',
146 oid => 'order_number',
149 my $lperl = new LPPERL;
151 $self->required_fields(qw/
152 host port configfile keyfile amount cardnumber cardexpmonth cardexpyear
155 my %post_data = $self->get_fields(qw/
156 host port configfile keyfile
158 chargetotal cardnumber cardexpmonth cardexpyear
159 name email phone addrnum city state zip country
163 $post_data{'ordertype'} = $content{action};
165 if ( $content{'cvv2'} ) {
166 $post_data{cvmindicator} = 'provided';
167 $post_data{cvmvalue} = $content{'cvv2'};
171 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
177 # %response = $lperl->$action(\%post_data);
179 %response = $lperl->curl_process(\%post_data);
182 warn "$_ => $response{$_}\n" for keys %response;
185 if ( $response{'r_approved'} eq 'APPROVED' ) {
186 $self->is_success(1);
187 $self->result_code($response{'r_code'});
188 $self->authorization($response{'r_ref'});
189 $self->order_number($response{'r_ordernum'});
190 $self->avs_code($response{'r_avs'});
192 $self->is_success(0);
193 $self->result_code('');
194 $self->error_message($response{'r_error'});
204 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
208 use Business::OnlinePayment;
210 my $tx = new Business::OnlinePayment( 'LinkPoint',
211 'storename' => 'your_store_number',
212 'keyfile' => '/path/to/keyfile.pem',
217 action => 'Normal Authorization',
218 description => 'Business::OnlinePayment test',
220 invoice_number => '100100',
221 customer_id => 'jsk',
222 name => 'Jason Kohles',
223 address => '123 Anystreet',
227 email => 'ivan-linkpoint@420.am',
228 card_number => '4007000000027',
229 expiration => '09/99',
233 if($tx->is_success()) {
234 print "Card processed successfully: ".$tx->authorization."\n";
236 print "Card was rejected: ".$tx->error_message."\n";
239 =head1 SUPPORTED TRANSACTION TYPES
241 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
245 For detailed information see L<Business::OnlinePayment>.
249 This module implements an interface to the LinkPoint Perl Wrapper
250 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
252 Versions 0.4 and on of this module support the LinkPoint Perl Wrapper version
259 Ivan Kohler <ivan-linkpoint@420.am>
261 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
265 perl(1), L<Business::OnlinePayment>.