1 package Business::OnlinePayment::PayflowPro;
4 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
7 use Business::OnlinePayment;
9 use PFProAPI; #Payflow PRO SDK from Verisign
13 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
21 #$self->server('staging.linkpt.net');
22 $self->server('secure.linkpt.net');
30 my %content = $self->content();
33 my %actions = ('normal authorization' => 'ApproveSale',
34 'authorization only' => 'CapturePayment',
35 'credit' => 'ReturnOrder',
36 'post authorization' => 'BillOrders',
38 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
40 # stuff it back into %content
41 $self->content(%content);
47 #no warnings; #not 5.005
49 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
56 my %content = $self->content();
58 $content{$map{$_}} = $content{$_};
60 $self->content(%content);
65 my %content = $self->content();
67 # warn "$_ = ". ( ref($map{$_})
69 # : $content{$map{$_}} ). "\n";
70 $content{$_} = ref($map{$_})
74 $self->content(%content);
78 my($self,@fields) = @_;
80 my %content = $self->content();
82 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
92 my %content = $self->content;
95 unless ( $content{action} eq 'BillOrders' ) {
97 if ( $self->transaction_type() =~
98 /^(cc|visa|mastercard|american express|discover)$/i
101 Carp::croak("PayflowPro can't handle transaction type: ".
102 $self->transaction_type());
105 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
106 or croak "unparsable expiration $content{expiration}";
108 ( $month, $year ) = ( $1, $2 );
109 $month = '0'. $month if $month =~ /^\d$/;
110 $year += 2000 if $year < 2000; #not y4k safe, oh shit
113 $content{'address'} =~ /^(\S+)\s/;
116 $self->server('staging.linkpt.net') if $self->test_transaction;
118 $self->revmap_fields(
119 hostname => \( $self->server ),
120 port => \( $self->port ),
121 storename => \( $self->storename ),
122 keyfile => \( $self->keyfile ),
123 addrnum => \$addrnum,
125 cardNumber => 'card_number',
126 cardExpMonth => \$month,
127 cardExpYear => \$year,
130 my $lperl = new LPERL
136 my $action = $content{action};
138 $self->required_fields(qw/
139 hostname port storename keyfile amount cardNumber cardExpMonth cardExpYear
142 my %post_data = $self->get_fields(qw/
143 hostname port storename keyfile
145 amount cardNumber cardExpMonth cardExpYear
146 name email phone address city state zip country
149 #print "$_ => $post_data{$_}\n" foreach keys %post_data;
154 %response = $lperl->$action(\%post_data);
157 if ( $response{'statusCode'} == 0 ) {
158 $self->is_success(0);
159 $self->result_code('');
160 $self->error_message($response{'statusMessage'});
162 $self->is_success(1);
163 $self->result_code($response{'AVCCode'});
164 $self->authorization($response{'trackingID'});
165 # $self->order_number($response{'neworderID'});
175 Business::OnlinePayment::PayflowPro - Verisign PayflowPro backend for Business::OnlinePayment
179 use Business::OnlinePayment;
181 my $tx = new Business::OnlinePayment( 'PayflowPro',
182 'storename' => 'your_store_number',
183 'keyfile' => '/path/to/keyfile.pem',
184 'lbin' => '/path/to/binary/lbin',
185 'tmp' => '/secure/tmp', # a secure tmp directory
190 action => 'Normal Authorization',
191 description => 'Business::OnlinePayment test',
193 invoice_number => '100100',
194 customer_id => 'jsk',
195 name => 'Jason Kohles',
196 address => '123 Anystreet',
200 email => 'ivan-payflowpro@420.am',
201 card_number => '4007000000027',
202 expiration => '09/99',
206 if($tx->is_success()) {
207 print "Card processed successfully: ".$tx->authorization."\n";
209 print "Card was rejected: ".$tx->error_message."\n";
212 =head1 SUPPORTED TRANSACTION TYPES
214 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
218 For detailed information see L<Business::OnlinePayment>.
222 This module implements an interface to the PayflowPro Perl API, which can
223 be downloaded at https://manager.verisign.com/ with a valid login.
229 Ivan Kohler <ivan-payflowpro@420.am>
231 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
235 perl(1), L<Business::OnlinePayment>.