use AutoLoader;
use Business::OnlinePayment;
-use PFProAPI; #Payflow PRO SDK from Verisign
+#PayflowPRO SDK from Verisign
+use PFProAPI qw( pfpro );
require Exporter;
@ISA = qw(Exporter AutoLoader Business::OnlinePayment);
@EXPORT = qw();
@EXPORT_OK = qw();
-$VERSION = '0.02';
+$VERSION = '0.01';
sub set_defaults {
my $self = shift;
#$self->server('staging.linkpt.net');
- $self->server('secure.linkpt.net');
- $self->port('1139');
+ $self->server('payflow.verisign.com');
+ $self->port('443');
+
+ $self->build_subs(qw( vendor partner order_number cert_path ));
}
my %content = $self->content();
+ my $action = lc($content{'action'});
+ if ( $action eq 'normal authorization' ) {
+ } else {
+ croak "$action not (yet) supported";
+ }
+
#ACTION MAP
- my %actions = ('normal authorization' => 'ApproveSale',
- 'authorization only' => 'CapturePayment',
- 'credit' => 'ReturnOrder',
- 'post authorization' => 'BillOrders',
+ my %actions = ('normal authorization' => 'S', #Sale
+ 'authorization only' => 'A', #Authorization
+ 'credit' => 'C', #Credit (refund)
+ 'post authorization' => 'D', #Delayed Capture
);
$content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
+ # TYPE MAP
+ my %types = ('visa' => 'C',
+ 'mastercard' => 'C',
+ 'american express' => 'C',
+ 'discover' => 'C',
+ 'cc' => 'C'
+ #'check' => 'ECHECK',
+ );
+ $content{'type'} = $types{lc($content{'type'})} || $content{'type'};
+ $self->transaction_type($content{'type'});
+
# stuff it back into %content
$self->content(%content);
}
my($self) = @_;
+
+
$self->map_fields();
my %content = $self->content;
- my($month, $year);
- unless ( $content{action} eq 'BillOrders' ) {
+ my($month, $year, $zip);
+
+ #unless ( $content{action} eq 'BillOrders' ) {
- if ( $self->transaction_type() =~
- /^(cc|visa|mastercard|american express|discover)$/i
- ) {
+ if ( $self->transaction_type() eq 'C' ) {
} else {
- Carp::croak("PayflowPro can't handle transaction type: ".
+ Carp::croak("PayflowPro can't (yet?) handle transaction type: ".
$self->transaction_type());
}
( $month, $year ) = ( $1, $2 );
$month = '0'. $month if $month =~ /^\d$/;
- $year += 2000 if $year < 2000; #not y4k safe, oh shit
- }
- $content{'address'} =~ /^(\S+)\s/;
- my $addrnum = $1;
+ $zip = $content{'zip'} =~ s/\D//;
+ #}
+
+ #$content{'address'} =~ /^(\S+)\s/;
+ #my $addrnum = $1;
- $self->server('staging.linkpt.net') if $self->test_transaction;
+ $self->server('test-payflow.verisign.com') if $self->test_transaction;
$self->revmap_fields(
- hostname => \( $self->server ),
- port => \( $self->port ),
- storename => \( $self->storename ),
- keyfile => \( $self->keyfile ),
- addrnum => \$addrnum,
-
- cardNumber => 'card_number',
- cardExpMonth => \$month,
- cardExpYear => \$year,
+ ACCT => 'card_number',
+ EXPDATE => \( $month.$year ),
+ AMT => 'amount',
+ USER => 'login',
+ #VENDOR => \( $self->vendor ),
+ VENDOR => 'login',
+ PARTNER => \( $self->partner ),
+ PWD => 'password',
+ TRXTYPE => 'action',
+ TENDER => 'type',
+
+ STREET => 'address',
+ ZIP => \$zip,
+
+ CITY => 'city',
+ COMMENT1 => 'description',
+ COMMENT2 => 'invoice_number',
+ COMPANYNAME => 'company',
+ COUNTRY => 'country',
+ FIRSTNAME => 'first_name',
+ LASTNAME => 'last_name',
+ NAME => 'name',
+ EMAIL => 'email',
+ STATE => 'state',
+
);
- my $lperl = new LPERL
- $self->lbin,
- 'FILE',
- $self->can('tmp')
- ? $self->tmp
- : '/tmp';
- my $action = $content{action};
-
- $self->required_fields(qw/
- hostname port storename keyfile amount cardNumber cardExpMonth cardExpYear
- /);
-
- my %post_data = $self->get_fields(qw/
- hostname port storename keyfile
- result
- amount cardNumber cardExpMonth cardExpYear
- name email phone address city state zip country
- /);
-
- #print "$_ => $post_data{$_}\n" foreach keys %post_data;
-
- my %response;
- {
- local($^W)=0;
- %response = $lperl->$action(\%post_data);
- }
+ $self->required_fields(qw(
+ ACCT EXPDATE AMT USER VENDOR PARTNER PWD TRXTYPE TENDER ));
- if ( $response{'statusCode'} == 0 ) {
- $self->is_success(0);
- $self->result_code('');
- $self->error_message($response{'statusMessage'});
- } else {
+ my %params = $self->get_fields(qw(
+ ACCT EXPDATE AMT USER VENDOR PARTNER PWD TRXTYPE TENDER
+ STREET ZIP
+ CITY COMMENT1 COMMENT2 COMPANYNAME COUNTRY FIRSTNAME LASTNAME NAME EMAIL
+ STATE
+ ));
+
+ #print "$_ => $params{$_}\n" foreach keys %params;
+
+ $ENV{'PFPRO_CERT_PATH'} = $self->cert_path;
+ my( $response, $resultstr ) = pfpro( \%params, $self->server, $self->port );
+
+ #if ( $response->{'RESULT'} == 0 ) {
+ if ( $response->{'RESULT'} eq '0' ) { #want an explicit zero, not just
+ #numerically equal
$self->is_success(1);
- $self->result_code($response{'AVCCode'});
- $self->authorization($response{'trackingID'});
-# $self->order_number($response{'neworderID'});
+ $self->result_code( $response->{'RESULT'} );
+ $self->error_message( $response->{'RESPMSG'} );
+ $self->authorization( $response->{'AUTHCODE'} );
+ $self->order_number( $response->{'PNREF'} );
+ } else {
+ $self->is_success(0);
+ $self->result_code( $response->{'RESULT'} );
+ $self->error_message( $response->{'RESPMSG'} );
}
}
use Business::OnlinePayment;
my $tx = new Business::OnlinePayment( 'PayflowPro',
- 'storename' => 'your_store_number',
- 'keyfile' => '/path/to/keyfile.pem',
- 'lbin' => '/path/to/binary/lbin',
- 'tmp' => '/secure/tmp', # a secure tmp directory
+ 'vendor' => 'your_vendor',
+ 'partner' => 'your_partner',
);
$tx->content(
zip => '84058',
email => 'ivan-payflowpro@420.am',
card_number => '4007000000027',
- expiration => '09/99',
+ expiration => '09/04',
);
$tx->submit();
-BEGIN { $| = 1; print "1..2\n"; }
+BEGIN { $| = 1; print "1..1\n"; }
use Business::OnlinePayment;
my $tx = new Business::OnlinePayment("PayflowPro",
-# 'storename' => '000000',
-# 'keyfile' => '/path/to/cert.pem',
-# 'lbin' => '/path/to/lbin',
-# 'tmp' => '/path/to/secure/tempdir',
+ #'vendor' => 'your_vendor',
+ 'partner' => 'verisign',
+ 'cert_path' => '/home/ivan/Business-OnlinePayment-PayflowPro.docs/verisign/payflowpro/linux/certs/',
);
$tx->content(
type => 'VISA',
+ login => 'test231',
+ password => '231test',
action => 'Normal Authorization',
description => 'Business::OnlinePayment::PayflowPro visa test',
amount => '0.01',
zip => '84058',
country => 'US',
email => 'ivan-payflowpro@420.am',
- card_number => '4007000000027',
- expiration => '12/2002',
-# result => 'DECLINE',
+ #card_number => '4007000000027',
+ #card_number => '4111111111111111',
+ card_number => '4111111111111112',
+ expiration => '12/2004',
);
$tx->test_transaction(1);
-BEGIN { $| = 1; print "1..2\n"; }
+BEGIN { $| = 1; print "1..1\n"; }
use Business::OnlinePayment;
my $tx = new Business::OnlinePayment("PayflowPro",
-# 'storename' => '000000',
-# 'keyfile' => '/path/to/cert.pem',
-# 'lbin' => '/path/to/lbin',
-# 'tmp' => '/path/to/secure/tempdir',
+ #'vendor' => 'your_vendor',
+ 'partner' => 'verisign',
+ 'cert_path' => '/home/ivan/Business-OnlinePayment-PayflowPro.docs/verisign/payflowpro/linux/certs/',
);
$tx->content(
type => 'VISA',
+ login => 'test231',
+ password => '231test',
action => 'Normal Authorization',
description => 'Business::OnlinePayment::PayflowPro visa test',
amount => '0.01',
zip => '84058',
country => 'US',
email => 'ivan-payflowpro@420.am',
- card_number => '4007000000027',
- expiration => '12/2003',
+ #card_number => '4007000000027',
+ card_number => '4111111111111111',
+ expiration => '12/2004',
);
$tx->test_transaction(1);