1 package Business::OnlinePayment::LinkPoint;
3 # $Id: LinkPoint.pm,v 1.16 2004-06-24 14:57:25 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$/;
115 $year += 2000 if $year < 2000; #not y4k safe, oh shit
118 $content{'address'} =~ /^(\S+)\s/;
121 my $result = $content{'result'};
122 if ( $self->test_transaction) {
124 #$self->server('staging.linkpt.net');
129 $self->revmap_fields(
130 host => \( $self->server ),
131 port => \( $self->port ),
132 #storename => \( $self->storename ),
133 configfile => \( $self->storename ),
134 keyfile => \( $self->keyfile ),
135 addrnum => \$addrnum,
137 cardNumber => 'card_number',
138 cardExpMonth => \$month,
139 cardExpYear => \$year,
140 chargetotal => 'amount',
143 my $lperl = new LPPERL;
145 $self->required_fields(qw/
146 host port configfile keyfile amount cardNumber cardExpMonth cardExpYear
149 my %post_data = $self->get_fields(qw/
150 host port configfile keyfile
152 chargetotal cardNumber cardExpMonth cardExpYear
153 name email phone addrnum city state zip country
156 $post_data{'order_type'} = $content{action};
158 if ( $content{'cvv2'} ) {
159 $post_data{cvmindicator} = 'provided';
160 $post_data{cvmvalue} = $content{'cvv2'};
163 warn "$_ => $post_data{$_}\n" foreach keys %post_data;
168 # %response = $lperl->$action(\%post_data);
170 %response = $lperl->curl_process(\%post_data);
172 if ( $response{'r_approved'} eq 'APPROVED' ) {
173 $self->is_success(1);
174 $self->result_code($response{'r_code'});
175 $self->authorization($response{'r_ref'});
176 $self->order_number($response{'r_ordernum'});
178 $self->is_success(0);
179 $self->result_code('');
180 $self->error_message($response{'r_error'});
190 Business::OnlinePayment::LinkPoint - LinkPoint (Cardservice) backend for Business::OnlinePayment
194 use Business::OnlinePayment;
196 my $tx = new Business::OnlinePayment( 'LinkPoint',
197 'storename' => 'your_store_number',
198 'keyfile' => '/path/to/keyfile.pem',
203 action => 'Normal Authorization',
204 description => 'Business::OnlinePayment test',
206 invoice_number => '100100',
207 customer_id => 'jsk',
208 name => 'Jason Kohles',
209 address => '123 Anystreet',
213 email => 'ivan-linkpoint@420.am',
214 card_number => '4007000000027',
215 expiration => '09/99',
219 if($tx->is_success()) {
220 print "Card processed successfully: ".$tx->authorization."\n";
222 print "Card was rejected: ".$tx->error_message."\n";
225 =head1 SUPPORTED TRANSACTION TYPES
227 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
231 For detailed information see L<Business::OnlinePayment>.
235 This module implements an interface to the LinkPoint Perl Wrapper
236 http://www.linkpoint.com/product_solutions/internet/lperl/lperl_main.html
238 Version 0.4 of this module has been updated for the LinkPoint Perl Wrapper
245 Ivan Kohler <ivan-linkpoint@420.am>
247 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
251 perl(1), L<Business::OnlinePayment>.