1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.9 2003-05-13 11:22:36 ivan Exp $
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
9 use Business::OnlinePayment;
13 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
18 use lperl; #2.6; #lperl.pm from LinkPoint
19 $LPERL::VERSION =~ /^(\d+\.\d+)/
20 or die "can't parse lperl.pm version: $LPERL::VERSION";
21 die "lperl.pm minimum version 2.6 required\n" unless $1 >= 2.6;
26 #$self->server('staging.linkpt.net');
27 $self->server('secure.linkpt.net');
35 my %content = $self->content();
38 my %actions = ('normal authorization' => 'ApproveSale',
39 'authorization only' => 'CapturePayment',
40 'credit' => 'ReturnOrder',
41 'post authorization' => 'BillOrders',
43 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
45 # stuff it back into %content
46 $self->content(%content);
52 #no warnings; #not 5.005
54 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
61 my %content = $self->content();
63 $content{$map{$_}} = $content{$_};
65 $self->content(%content);
70 my %content = $self->content();
72 # warn "$_ = ". ( ref($map{$_})
74 # : $content{$map{$_}} ). "\n";
75 $content{$_} = ref($map{$_})
79 $self->content(%content);
83 my($self,@fields) = @_;
85 my %content = $self->content();
87 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
96 my %content = $self->content;
99 unless ( $content{action} eq 'BillOrders' ) {
101 if ( $self->transaction_type() =~
102 /^(cc|visa|mastercard|american express|discover)$/i
105 Carp::croak("LinkPoint can't handle transaction type: ".
106 $self->transaction_type());
109 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
110 or croak "unparsable expiration $content{expiration}";
112 ( $month, $year ) = ( $1, $2 );
113 $month = '0'. $month if $month =~ /^\d$/;
114 $year += 2000 if $year < 2000; #not y4k safe, oh shit
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 hostname => \( $self->server ),
130 port => \( $self->port ),
131 storename => \( $self->storename ),
132 keyfile => \( $self->keyfile ),
133 addrnum => \$addrnum,
135 cardNumber => 'card_number',
136 cardExpMonth => \$month,
137 cardExpYear => \$year,
140 my $lperl = new LPERL;
141 my $action = $content{action};
143 $self->required_fields(qw/
144 hostname port storename keyfile amount cardNumber cardExpMonth cardExpYear
147 my %post_data = $self->get_fields(qw/
148 hostname port storename keyfile
150 amount cardNumber cardExpMonth cardExpYear
151 name email phone address city state zip country
154 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
159 %response = $lperl->$action(\%post_data);
162 #if ( $response{'statusCode'} == 0 ) {
163 if ( $response{'statusMessage'} ) {
164 $self->is_success(0);
165 $self->result_code('');
166 $self->error_message($response{'statusMessage'});
167 } elsif ( $response{'statusCode'} ) {
168 $self->is_success(1);
169 $self->result_code($response{'AVSCode'});
170 $self->authorization($response{'trackingID'});
171 # $self->order_number($response{'neworderID'});
173 #if ( exists($response{'statusMessage'})
174 # && defined($response{'statusMessage'}) ) { # "normal" error
175 #} else { # "should not happen" error (should this die/croak?)
176 $self->error_message("No statusMessage returned! Response follows:".
177 join(' / ', map { "$_=>".$response{$_} } keys %response ) );
187 Business::OnlinePayment::LinkPoint - LinkPoint backend for Business::OnlinePayment
191 use Business::OnlinePayment;
193 my $tx = new Business::OnlinePayment( 'LinkPoint',
194 'storename' => 'your_store_number',
195 'keyfile' => '/path/to/keyfile.pem',
200 action => 'Normal Authorization',
201 description => 'Business::OnlinePayment test',
203 invoice_number => '100100',
204 customer_id => 'jsk',
205 name => 'Jason Kohles',
206 address => '123 Anystreet',
210 email => 'ivan-linkpoint@420.am',
211 card_number => '4007000000027',
212 expiration => '09/99',
216 if($tx->is_success()) {
217 print "Card processed successfully: ".$tx->authorization."\n";
219 print "Card was rejected: ".$tx->error_message."\n";
222 =head1 SUPPORTED TRANSACTION TYPES
224 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
228 For detailed information see L<Business::OnlinePayment>.
232 This module implements an interface to the LinkPoint Perl Wrapper
233 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
235 Version 0.2 of this module has been updated for the LinkPoint Perl Wrapper
242 Ivan Kohler <ivan-linkpoint@420.am>
244 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
248 perl(1), L<Business::OnlinePayment>.