1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.21 2004-06-24 15:31:58 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');
30 $self->build_subs(qw(order_number avs_code));
37 my %content = $self->content();
40 my %actions = ('normal authorization' => 'SALE',
41 'authorization only' => 'PREAUTH',
43 'post authorization' => 'POSTAUTH',
46 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
48 # stuff it back into %content
49 $self->content(%content);
55 #no warnings; #not 5.005
57 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
64 my %content = $self->content();
66 $content{$map{$_}} = $content{$_};
68 $self->content(%content);
73 my %content = $self->content();
75 # warn "$_ = ". ( ref($map{$_})
77 # : $content{$map{$_}} ). "\n";
78 $content{$_} = ref($map{$_})
82 $self->content(%content);
86 my($self,@fields) = @_;
88 my %content = $self->content();
90 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
99 my %content = $self->content;
102 unless ( $content{action} eq 'POSTAUTH' ) {
104 if ( $self->transaction_type() =~
105 /^(cc|visa|mastercard|american express|discover)$/i
108 Carp::croak("LinkPoint can't handle transaction type: ".
109 $self->transaction_type());
112 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
113 or croak "unparsable expiration $content{expiration}";
115 ( $month, $year ) = ( $1, $2 );
116 $month = '0'. $month if $month =~ /^\d$/;
119 $content{'address'} =~ /^(\S+)\s/;
122 my $result = $content{'result'};
123 if ( $self->test_transaction) {
125 #$self->server('staging.linkpt.net');
130 $self->revmap_fields(
131 host => \( $self->server ),
132 port => \( $self->port ),
133 #storename => \( $self->storename ),
134 configfile => \( $self->storename ),
135 keyfile => \( $self->keyfile ),
136 addrnum => \$addrnum,
138 cardnumber => 'card_number',
139 cardexpmonth => \$month,
140 cardexpyear => \$year,
141 chargetotal => 'amount',
144 my $lperl = new LPPERL;
146 $self->required_fields(qw/
147 host port configfile keyfile amount cardnumber cardexpmonth cardexpyear
150 my %post_data = $self->get_fields(qw/
151 host port configfile keyfile
153 chargetotal cardnumber cardexpmonth cardexpyear
154 name email phone addrnum city state zip country
157 $post_data{'ordertype'} = $content{action};
159 if ( $content{'cvv2'} ) {
160 $post_data{cvmindicator} = 'provided';
161 $post_data{cvmvalue} = $content{'cvv2'};
164 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
169 # %response = $lperl->$action(\%post_data);
171 %response = $lperl->curl_process(\%post_data);
173 warn "$_ => $response{$_}\n" for keys %response;
175 if ( $response{'r_approved'} eq 'APPROVED' ) {
176 $self->is_success(1);
177 $self->result_code($response{'r_code'});
178 $self->authorization($response{'r_ref'});
179 $self->order_number($response{'r_ordernum'});
180 $self->avs_code($response{'r_avs'};
182 $self->is_success(0);
183 $self->result_code('');
184 $self->error_message($response{'r_error'});
194 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
198 use Business::OnlinePayment;
200 my $tx = new Business::OnlinePayment( 'LinkPoint',
201 'storename' => 'your_store_number',
202 'keyfile' => '/path/to/keyfile.pem',
207 action => 'Normal Authorization',
208 description => 'Business::OnlinePayment test',
210 invoice_number => '100100',
211 customer_id => 'jsk',
212 name => 'Jason Kohles',
213 address => '123 Anystreet',
217 email => 'ivan-linkpoint@420.am',
218 card_number => '4007000000027',
219 expiration => '09/99',
223 if($tx->is_success()) {
224 print "Card processed successfully: ".$tx->authorization."\n";
226 print "Card was rejected: ".$tx->error_message."\n";
229 =head1 SUPPORTED TRANSACTION TYPES
231 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
235 For detailed information see L<Business::OnlinePayment>.
239 This module implements an interface to the LinkPoint Perl Wrapper
240 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
242 Version 0.4 of this module has been updated for the LinkPoint Perl Wrapper
249 Ivan Kohler <ivan-linkpoint@420.am>
251 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
255 perl(1), L<Business::OnlinePayment>.