1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.3 2002-02-26 08:53:52 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);
50 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
57 my %content = $self->content();
59 $content{$map{$_}} = $content{$_};
61 $self->content(%content);
66 my %content = $self->content();
68 # warn "$_ = ". ( ref($map{$_})
70 # : $content{$map{$_}} ). "\n";
71 $content{$_} = ref($map{$_})
75 $self->content(%content);
79 my($self,@fields) = @_;
81 my %content = $self->content();
83 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
93 my %content = $self->content;
96 unless ( $content{action} eq 'BillOrders' ) {
98 if ( $self->transaction_type() =~
99 /^(cc|visa|mastercard|american express|discover)$/i
102 Carp::croak("LinkPoint can't handle transaction type: ".
103 $self->transaction_type());
106 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
107 or croak "unparsable expiration $content{expiration}";
109 ( $month, $year ) = ( $1, $2 );
110 $month = '0'. $month if $month =~ /^\d$/;
111 $year += 2000 if $year < 2000; #not y4k safe, oh shit
114 $content{'address'} =~ /^(\S+)\s/;
117 $self->server('staging.linkpt.net') if $self->test_transaction;
119 $self->revmap_fields(
120 hostname => \( $self->server ),
121 port => \( $self->port ),
122 storename => \( $self->storename ),
123 keyfile => \( $self->keyfile ),
124 addrnum => \$addrnum,
126 cardNumber => 'card_number',
127 cardExpMonth => \$month,
128 cardExpYear => \$year,
131 my $lperl = new LPERL
137 my $action = $content{action};
139 $self->required_fields(qw/
140 hostname port storename keyfile amount cardNumber cardExpMonth cardExpYear
143 my %post_data = $self->get_fields(qw/
144 hostname port storename keyfile
146 amount cardNumber cardExpMonth cardExpYear
147 name email phone address city state zip country
150 #print "$_ => $post_data{$_}\n" foreach keys %post_data;
152 my %response = $lperl->$action(\%post_data);
154 if ( $response{'statusCode'} == 0 ) {
155 $self->is_success(0);
156 $self->result_code('');
157 $self->error_message($response{'statusMessage'});
159 $self->is_success(1);
160 $self->result_code($response{'AVCCode'});
161 $self->authorization($response{'trackingID'});
162 # $self->order_number($response{'neworderID'});
172 Business::OnlinePayment::LinkPoint - LinkPoint backend for Business::OnlinePayment
176 use Business::OnlinePayment;
178 my $tx = new Business::OnlinePayment( 'LinkPoint',
179 'storename' => 'your_store_number',
180 'keyfile' => '/path/to/keyfile.pem',
181 'lbin' => '/path/to/binary/lbin',
182 'tmp' => '/secure/tmp', # a secure tmp directory
187 action => 'Normal Authorization',
188 description => 'Business::OnlinePayment test',
190 invoice_number => '100100',
191 customer_id => 'jsk',
192 name => 'Jason Kohles',
193 address => '123 Anystreet',
197 email => 'ivan-linkpoint@420.am',
198 card_number => '4007000000027',
199 expiration => '09/99',
203 if($tx->is_success()) {
204 print "Card processed successfully: ".$tx->authorization."\n";
206 print "Card was rejected: ".$tx->error_message."\n";
209 =head1 SUPPORTED TRANSACTION TYPES
211 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
215 For detailed information see L<Business::OnlinePayment>.
219 This module implements an interface to the LinkPoint Perl Wrapper
220 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
226 Ivan Kohler <ivan-linkpoint@420.am>
228 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
232 perl(1). L<Business::OnlinePayment>.