1 package Business::OnlinePayment::PayflowPro;
4 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
7 use Business::OnlinePayment;
9 #PayflowPRO SDK from Verisign
10 use PFProAPI qw( pfpro );
14 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
22 #$self->server('staging.linkpt.net');
23 $self->server('payflow.verisign.com');
26 $self->build_subs(qw( vendor partner order_number cert_path ));
33 my %content = $self->content();
35 my $action = lc($content{'action'});
36 if ( $action eq 'normal authorization' ) {
38 croak "$action not (yet) supported";
42 my %actions = ('normal authorization' => 'S', #Sale
43 'authorization only' => 'A', #Authorization
44 'credit' => 'C', #Credit (refund)
45 'post authorization' => 'D', #Delayed Capture
47 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
50 my %types = ('visa' => 'C',
52 'american express' => 'C',
57 $content{'type'} = $types{lc($content{'type'})} || $content{'type'};
58 $self->transaction_type($content{'type'});
60 # stuff it back into %content
61 $self->content(%content);
67 #no warnings; #not 5.005
69 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
76 my %content = $self->content();
78 $content{$map{$_}} = $content{$_};
80 $self->content(%content);
85 my %content = $self->content();
87 # warn "$_ = ". ( ref($map{$_})
89 # : $content{$map{$_}} ). "\n";
90 $content{$_} = ref($map{$_})
94 $self->content(%content);
98 my($self,@fields) = @_;
100 my %content = $self->content();
102 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
114 my %content = $self->content;
116 my($month, $year, $zip);
118 #unless ( $content{action} eq 'BillOrders' ) {
120 if ( $self->transaction_type() eq 'C' ) {
122 Carp::croak("PayflowPro can't (yet?) handle transaction type: ".
123 $self->transaction_type());
126 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
127 or croak "unparsable expiration $content{expiration}";
129 ( $month, $year ) = ( $1, $2 );
130 $month = '0'. $month if $month =~ /^\d$/;
132 $zip = $content{'zip'} =~ s/\D//;
135 #$content{'address'} =~ /^(\S+)\s/;
138 $self->server('test-payflow.verisign.com') if $self->test_transaction;
140 $self->revmap_fields(
141 ACCT => 'card_number',
142 EXPDATE => \( $month.$year ),
145 #VENDOR => \( $self->vendor ),
147 PARTNER => \( $self->partner ),
156 COMMENT1 => 'description',
157 COMMENT2 => 'invoice_number',
158 COMPANYNAME => 'company',
159 COUNTRY => 'country',
160 FIRSTNAME => 'first_name',
161 LASTNAME => 'last_name',
168 $self->required_fields(qw(
169 ACCT EXPDATE AMT USER VENDOR PARTNER PWD TRXTYPE TENDER ));
171 my %params = $self->get_fields(qw(
172 ACCT EXPDATE AMT USER VENDOR PARTNER PWD TRXTYPE TENDER
174 CITY COMMENT1 COMMENT2 COMPANYNAME COUNTRY FIRSTNAME LASTNAME NAME EMAIL
178 #print "$_ => $params{$_}\n" foreach keys %params;
180 $ENV{'PFPRO_CERT_PATH'} = $self->cert_path;
181 my( $response, $resultstr ) = pfpro( \%params, $self->server, $self->port );
183 #if ( $response->{'RESULT'} == 0 ) {
184 if ( $response->{'RESULT'} eq '0' ) { #want an explicit zero, not just
186 $self->is_success(1);
187 $self->result_code( $response->{'RESULT'} );
188 $self->error_message( $response->{'RESPMSG'} );
189 $self->authorization( $response->{'AUTHCODE'} );
190 $self->order_number( $response->{'PNREF'} );
192 $self->is_success(0);
193 $self->result_code( $response->{'RESULT'} );
194 $self->error_message( $response->{'RESPMSG'} );
204 Business::OnlinePayment::PayflowPro - Verisign PayflowPro backend for Business::OnlinePayment
208 use Business::OnlinePayment;
210 my $tx = new Business::OnlinePayment( 'PayflowPro',
211 'vendor' => 'your_vendor',
212 'partner' => 'your_partner',
217 action => 'Normal Authorization',
218 description => 'Business::OnlinePayment test',
220 invoice_number => '100100',
221 customer_id => 'jsk',
222 name => 'Jason Kohles',
223 address => '123 Anystreet',
227 email => 'ivan-payflowpro@420.am',
228 card_number => '4007000000027',
229 expiration => '09/04',
233 if($tx->is_success()) {
234 print "Card processed successfully: ".$tx->authorization."\n";
236 print "Card was rejected: ".$tx->error_message."\n";
239 =head1 SUPPORTED TRANSACTION TYPES
241 =head2 Visa, MasterCard, American Express, JCB, Discover/Novus, Carte blanche/Diners Club
245 For detailed information see L<Business::OnlinePayment>.
249 This module implements an interface to the PayflowPro Perl API, which can
250 be downloaded at https://manager.verisign.com/ with a valid login.
256 Ivan Kohler <ivan-payflowpro@420.am>
258 Based on Busienss::OnlinePayment::AuthorizeNet written by Jason Kohles.
262 perl(1), L<Business::OnlinePayment>.