1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.6 2002-08-14 01:32:54 ivan Exp $
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
9 use Business::OnlinePayment;
11 use lperl; #lperl.pm from Linkpoint.
15 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
23 #$self->server('staging.linkpt.net');
24 $self->server('secure.linkpt.net');
32 my %content = $self->content();
35 my %actions = ('normal authorization' => 'ApproveSale',
36 'authorization only' => 'CapturePayment',
37 'credit' => 'ReturnOrder',
38 'post authorization' => 'BillOrders',
40 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
42 # stuff it back into %content
43 $self->content(%content);
49 #no warnings; #not 5.005
51 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
58 my %content = $self->content();
60 $content{$map{$_}} = $content{$_};
62 $self->content(%content);
67 my %content = $self->content();
69 # warn "$_ = ". ( ref($map{$_})
71 # : $content{$map{$_}} ). "\n";
72 $content{$_} = ref($map{$_})
76 $self->content(%content);
80 my($self,@fields) = @_;
82 my %content = $self->content();
84 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
94 my %content = $self->content;
97 unless ( $content{action} eq 'BillOrders' ) {
99 if ( $self->transaction_type() =~
100 /^(cc|visa|mastercard|american express|discover)$/i
103 Carp::croak("LinkPoint can't handle transaction type: ".
104 $self->transaction_type());
107 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
108 or croak "unparsable expiration $content{expiration}";
110 ( $month, $year ) = ( $1, $2 );
111 $month = '0'. $month if $month =~ /^\d$/;
112 $year += 2000 if $year < 2000; #not y4k safe, oh shit
115 $content{'address'} =~ /^(\S+)\s/;
118 $self->server('staging.linkpt.net') if $self->test_transaction;
120 $self->revmap_fields(
121 hostname => \( $self->server ),
122 port => \( $self->port ),
123 storename => \( $self->storename ),
124 keyfile => \( $self->keyfile ),
125 addrnum => \$addrnum,
127 cardNumber => 'card_number',
128 cardExpMonth => \$month,
129 cardExpYear => \$year,
132 my $lperl = new LPERL
138 my $action = $content{action};
140 $self->required_fields(qw/
141 hostname port storename keyfile amount cardNumber cardExpMonth cardExpYear
144 my %post_data = $self->get_fields(qw/
145 hostname port storename keyfile
147 amount cardNumber cardExpMonth cardExpYear
148 name email phone address city state zip country
151 #print "$_ => $post_data{$_}\n" foreach keys %post_data;
156 %response = $lperl->$action(\%post_data);
159 if ( $response{'statusCode'} == 0 ) {
160 $self->is_success(0);
161 $self->result_code('');
162 $self->error_message($response{'statusMessage'});
164 $self->is_success(1);
165 $self->result_code($response{'AVCCode'});
166 $self->authorization($response{'trackingID'});
167 # $self->order_number($response{'neworderID'});
177 Business::OnlinePayment::LinkPoint - LinkPoint backend for Business::OnlinePayment
181 use Business::OnlinePayment;
183 my $tx = new Business::OnlinePayment( 'LinkPoint',
184 'storename' => 'your_store_number',
185 'keyfile' => '/path/to/keyfile.pem',
186 'lbin' => '/path/to/binary/lbin',
187 'tmp' => '/secure/tmp', # a secure tmp directory
192 action => 'Normal Authorization',
193 description => 'Business::OnlinePayment test',
195 invoice_number => '100100',
196 customer_id => 'jsk',
197 name => 'Jason Kohles',
198 address => '123 Anystreet',
202 email => 'ivan-linkpoint@420.am',
203 card_number => '4007000000027',
204 expiration => '09/99',
208 if($tx->is_success()) {
209 print "Card processed successfully: ".$tx->authorization."\n";
211 print "Card was rejected: ".$tx->error_message."\n";
214 =head1 SUPPORTED TRANSACTION TYPES
216 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
220 For detailed information see L<Business::OnlinePayment>.
224 This module implements an interface to the LinkPoint Perl Wrapper
225 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
231 Ivan Kohler <ivan-linkpoint@420.am>
233 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
237 perl(1), L<Business::OnlinePayment>.