1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.20 2004-06-24 15:23:40 ivan Exp $
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
9 use Business::OnlinePayment;
13 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
18 use lpperl; #3; #lperl.pm from LinkPoint
19 $LPPERL::VERSION =~ /^(\d+\.\d+)/
20 or die "can't parse lperl.pm version: $LPPERL::VERSION";
21 die "lpperl.pm minimum version 3 required\n" unless $1 >= 3;
26 #$self->server('staging.linkpt.net');
27 $self->server('secure.linkpt.net');
35 my %content = $self->content();
38 my %actions = ('normal authorization' => 'SALE',
39 'authorization only' => 'PREAUTH',
41 'post authorization' => 'POSTAUTH',
44 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
46 # stuff it back into %content
47 $self->content(%content);
53 #no warnings; #not 5.005
55 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
62 my %content = $self->content();
64 $content{$map{$_}} = $content{$_};
66 $self->content(%content);
71 my %content = $self->content();
73 # warn "$_ = ". ( ref($map{$_})
75 # : $content{$map{$_}} ). "\n";
76 $content{$_} = ref($map{$_})
80 $self->content(%content);
84 my($self,@fields) = @_;
86 my %content = $self->content();
88 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
97 my %content = $self->content;
100 unless ( $content{action} eq 'POSTAUTH' ) {
102 if ( $self->transaction_type() =~
103 /^(cc|visa|mastercard|american express|discover)$/i
106 Carp::croak("LinkPoint can't handle transaction type: ".
107 $self->transaction_type());
110 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
111 or croak "unparsable expiration $content{expiration}";
113 ( $month, $year ) = ( $1, $2 );
114 $month = '0'. $month if $month =~ /^\d$/;
117 $content{'address'} =~ /^(\S+)\s/;
120 my $result = $content{'result'};
121 if ( $self->test_transaction) {
123 #$self->server('staging.linkpt.net');
128 $self->revmap_fields(
129 host => \( $self->server ),
130 port => \( $self->port ),
131 #storename => \( $self->storename ),
132 configfile => \( $self->storename ),
133 keyfile => \( $self->keyfile ),
134 addrnum => \$addrnum,
136 cardnumber => 'card_number',
137 cardexpmonth => \$month,
138 cardexpyear => \$year,
139 chargetotal => 'amount',
142 my $lperl = new LPPERL;
144 $self->required_fields(qw/
145 host port configfile keyfile amount cardnumber cardexpmonth cardexpyear
148 my %post_data = $self->get_fields(qw/
149 host port configfile keyfile
151 chargetotal cardnumber cardexpmonth cardexpyear
152 name email phone addrnum city state zip country
155 $post_data{'ordertype'} = $content{action};
157 if ( $content{'cvv2'} ) {
158 $post_data{cvmindicator} = 'provided';
159 $post_data{cvmvalue} = $content{'cvv2'};
162 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
167 # %response = $lperl->$action(\%post_data);
169 %response = $lperl->curl_process(\%post_data);
171 warn "$_ => $response{$_}\n" for keys %response;
173 if ( $response{'r_approved'} eq 'APPROVED' ) {
174 $self->is_success(1);
175 $self->result_code($response{'r_code'});
176 $self->authorization($response{'r_ref'});
177 $self->order_number($response{'r_ordernum'});
179 $self->is_success(0);
180 $self->result_code('');
181 $self->error_message($response{'r_error'});
191 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
195 use Business::OnlinePayment;
197 my $tx = new Business::OnlinePayment( 'LinkPoint',
198 'storename' => 'your_store_number',
199 'keyfile' => '/path/to/keyfile.pem',
204 action => 'Normal Authorization',
205 description => 'Business::OnlinePayment test',
207 invoice_number => '100100',
208 customer_id => 'jsk',
209 name => 'Jason Kohles',
210 address => '123 Anystreet',
214 email => 'ivan-linkpoint@420.am',
215 card_number => '4007000000027',
216 expiration => '09/99',
220 if($tx->is_success()) {
221 print "Card processed successfully: ".$tx->authorization."\n";
223 print "Card was rejected: ".$tx->error_message."\n";
226 =head1 SUPPORTED TRANSACTION TYPES
228 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
232 For detailed information see L<Business::OnlinePayment>.
236 This module implements an interface to the LinkPoint Perl Wrapper
237 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
239 Version 0.4 of this module has been updated for the LinkPoint Perl Wrapper
246 Ivan Kohler <ivan-linkpoint@420.am>
248 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
252 perl(1), L<Business::OnlinePayment>.