Business-OnlinePayment-PayflowPro-1.01/0000755000076400007640000000000011256237036016731 5ustar philadminBusiness-OnlinePayment-PayflowPro-1.01/MANIFEST0000644000076400007640000000027511256237037020067 0ustar philadminPayflowPro.pm Changes MANIFEST Makefile.PL README t/00load.t t/bop.t t/credit_card.t t/pod-coverage.t t/pod.t META.yml Module meta-data (added by MakeMaker) Business-OnlinePayment-PayflowPro-1.01/META.yml0000644000076400007640000000073311256237036020205 0ustar philadmin# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Business-OnlinePayment-PayflowPro version: 1.01 version_from: PayflowPro.pm installdirs: site requires: Business::OnlinePayment: 3 Business::OnlinePayment::HTTPS: 0.06 CGI: 0 Digest::MD5: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Business-OnlinePayment-PayflowPro-1.01/README0000644000076400007640000000245511055006014017602 0ustar philadminCopyright (c) 2003 Ivan Kohler Copyright (c) 2007 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This is Business::OnlinePayment::PayflowPro, a Business::OnlinePayment back end module for PayPal Payflow Pro. It is only useful if you have a merchant account with PayPal Payment Services: https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-gateway-overview-outside As of 0.07, this module communicates with the Payflow gateway directly and no longer requires the Payflow Pro SDK. Thanks to Phil Lobbes for this great work. The Payflow API that this module interfaces with is not yet an officially supported service and is still subject to change. At this time, you need to contact payflowintegrator@paypal.com for a certification ID to connect and run transactions using this module. Based on Business::OnlinePayment::AuthorizeNet written by Jason Kohles. Currently maintained by Ivan Kohler and Phil Lobbes . Business::OnlinePayment is a generic interface for processing payments through online credit card processors, online check acceptance houses, etc. (If you like buzzwords, call it an "multiplatform ecommerce-enabling middleware solution"). Business-OnlinePayment-PayflowPro-1.01/t/0000755000076400007640000000000011256237036017174 5ustar philadminBusiness-OnlinePayment-PayflowPro-1.01/t/pod.t0000644000076400007640000000035411076416715020150 0ustar philadmin#!/usr/bin/perl use strict; use warnings; use Test::More; plan skip_all => 'Set RELEASE_TESTING=1 to run this test' if not $ENV{RELEASE_TESTING}; eval "use Test::Pod"; plan skip_all => 'Needs Test::Pod' if $@; all_pod_files_ok(); Business-OnlinePayment-PayflowPro-1.01/t/bop.t0000644000076400007640000000745311243701451020143 0ustar philadmin#!/usr/bin/perl use strict; use warnings; use Test::More tests => 30; use Business::OnlinePayment; my $package = "Business::OnlinePayment"; my $driver = "PayflowPro"; { # new my $obj; $obj = $package->new($driver); isa_ok( $obj, $package ); # convenience methods can_ok( $obj, qw(vendor partner) ); can_ok( $obj, qw(order_number avs_code cvv2_response) ); can_ok( $obj, qw(request_id debug expdate_mmyy) ); # internal methods can_ok( $obj, qw(_map_fields _revmap_fields) ); # defaults my $server = "payflowpro.paypal.com"; is( $obj->server, $server, "server($server)" ); is( $obj->port, "443", "port(443)" ); } { # cvv2_response / cvv2_code my $obj = $package->new($driver); my $exp = "Z"; $obj->cvv2_response($exp); is( $obj->cvv2_response, $exp, "cvv2_response() is set" ); is( $obj->cvv2_code, $exp, "cvv2_code() calls cvv2_response" ); } { # client_certification_id my $obj = $package->new($driver); my $id = $obj->client_certification_id; isnt( $id, "", "client_certification_id() is set" ); $id = "foo"; is( $obj->client_certification_id($id), $id, "client_certification_id() can be set" ); is( $obj->client_certification_id, $id, "client_certification_id() remains set" ); } { # client_timeout my $obj = $package->new($driver); is( $obj->client_timeout, 45, "client_timeout() returns 45 by default" ); my $to = 60; is( $obj->client_timeout($to), $to, "client_timeout() can be set" ); is( $obj->client_timeout, $to, "client_timeout() remains set" ); } { # expdate my $obj = $package->new($driver); my @exp = ( #OFF [qw(1999.8 0899)], #OFF [qw(1984-11 1184)], #OFF [qw(06/7 0706)], #OFF [qw(06-12 1206)], [qw(12/06 1206)], [qw(6/2000 0600)], [qw(10/2000 1000)], [qw(1/99 0199)], ); foreach my $aref (@exp) { my ( $exp, $moyr ) = @$aref; my ($mmyy) = $obj->expdate_mmyy($exp); is( $mmyy, $moyr, "$exp: MMYY '$mmyy' eq '$moyr' from $exp" ); } } { # request_id my $obj = $package->new($driver); my $id = $obj->request_id; isnt( $id, "", "request_id() returns something" ); is( $obj->request_id, $id, "request_id() returns the same value" ); $obj = $package->new($driver); isnt( $obj->request_id, $id, "request_id() is different for each object" ); $id = "foo"; is( $obj->request_id($id), $id, "request_id() can be set" ); is( $obj->request_id, $id, "request_id() remains set" ); } { # _get_response - response parsing my $obj = $package->new($driver); is_deeply( $obj->_get_response('%66%6F%78=%71%75%69%63%6B%20%25%26%3B&e=3+3'), { fox => 'quick %&;', e => '3 3' }, "_get_response 1 returns correct value" ); is_deeply( $obj->_get_response('Foo=&&&&;;ab=t+t;q=2'), { Foo => '', ab => 't t', q => '2' }, "_get_response 2 returns correct value" ); is_deeply( $obj->_get_response('f=s'), { f => 's' }, "_get_response 3 returns correct value" ); is_deeply( $obj->_get_response(''), {}, "_get_response 4 returns correct value" ); is_deeply( $obj->_get_response(undef), {}, "_get_response 5 returns correct value" ); is_deeply( $obj->_get_response( 'RESULT=0&PNREF=QAAA1DF4B4F4&RESPMSG=Approved&AUTHCODE=111PNQ&AVSADDR=X&AVSZIP=X&CVV2MATCH=Y&IAVS=X' ), { RESULT => '0', PNREF => 'QAAA1DF4B4F4', RESPMSG => 'Approved', AUTHCODE => '111PNQ', AVSADDR => 'X', AVSZIP => 'X', CVV2MATCH => 'Y', IAVS => 'X' }, "_get_response 6 returns correct value" ); } Business-OnlinePayment-PayflowPro-1.01/t/00load.t0000644000076400007640000000046410554166110020436 0ustar philadmin#!/usr/bin/perl use strict; use warnings; use Test::More tests => 2; BEGIN { use_ok("Business::OnlinePayment") or BAIL_OUT("unable to load Business::OnlinePayment\n"); use_ok("Business::OnlinePayment::PayflowPro") or BAIL_OUT("unable to load Business::OnlinePayment::PayflowPro\n"); } Business-OnlinePayment-PayflowPro-1.01/t/credit_card.t0000644000076400007640000001410111076373175021626 0ustar philadmin#!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); use Test::More; use Business::OnlinePayment; my $runinfo = "to test set environment variables:" . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD and CLIENTCERTID (for X-VPS-VIT-CLIENT-CERTIFICATION-ID); " . " (optional) PFPRO_PARTNER PFPRO_CERT_PATH"; plan( ( $ENV{"PFPRO_USER"} && $ENV{"PFPRO_VENDOR"} && $ENV{"PFPRO_PWD"} ) ? ( tests => 56 ) : ( skip_all => $runinfo ) ); my %opts = ( "debug" => 0, "vendor" => $ENV{PFPRO_VENDOR}, "partner" => $ENV{PFPRO_PARTNER} || "verisign", "client_certification_id" => $ENV{CLIENTCERTID}, ); my %content = ( login => $ENV{"PFPRO_USER"}, password => $ENV{"PFPRO_PWD"}, action => "Normal Authorization", type => "VISA", description => "Business::OnlinePayment::PayflowPro test", card_number => "4111111111111111", cvv2 => "123", expiration => "12/" . strftime( "%y", localtime ), amount => "0.01", first_name => "Tofu", last_name => "Beast", email => 'ivan-payflowpro@420.am', address => "123 Anystreet", city => "Anywhere", state => "GA", zip => "30004", country => "US", ); { # valid card number test my $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content(%content); tx_check( $tx, desc => "valid card_number", is_success => 1, result_code => 0, error_message => "Approved", authorization => "010101", avs_code => "Y", cvv2_response => "Y", ); } { # invalid card number test my $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content( %content, card_number => "4111111111111112" ); tx_check( $tx, desc => "invalid card_number", is_success => 0, result_code => 23, error_message => "Invalid account number", authorization => undef, avs_code => undef, cvv2_response => undef, ); } SKIP: { # avs_code() / AVSZIP and AVSADDR tests skip "AVS tests broken", 28; my $tx = new Business::OnlinePayment( "PayflowPro", %opts ); # IF first 3 chars of STREET <= 334 and >= 666 THEN AVSADDR == "N" $tx->content( %content, "address" => "500 Any street" ); tx_check( $tx, desc => "AVSADDR=N,AVSZIP=Y", is_success => 0, result_code => 126, error_message => "Under review by Fraud Service", authorization => "010101", avs_code => "Z", cvv2_response => "Y", ); # IF first 3 chars of STREET >= 667 THEN AVSADDR == "X" (and AVSZIP="X") $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content( %content, "address" => "700 Any street" ); tx_check( $tx, desc => "AVSADDR=X,AVSZIP=X", is_success => 1, result_code => 0, error_message => "Approved", authorization => "010101", avs_code => "", cvv2_response => "Y", ); # # IF ZIP <= 50001 and >= 99999 THEN AVSZIP == "N" $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content( %content, "zip" => "99999" ); tx_check( $tx, desc => "AVSADDR=Y,AVSZIP=N", is_success => 0, result_code => 126, error_message => "Under review by Fraud Service", authorization => "010101", avs_code => "A", cvv2_response => "Y", ); # Both AVSADDR and AVSZIP == "N" $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content( %content, "address" => "500 Any street", "zip" => "99999" ); tx_check( $tx, desc => "AVSADDR=N,AVSZIP=N", is_success => 0, result_code => 126, error_message => "Under review by Fraud Service", authorization => "010101", avs_code => "N", cvv2_response => "Y", ); } SKIP: { # cvv2_response() / CVV2MATCH skip "CVV2 tests broken", 14; my $tx = new Business::OnlinePayment( "PayflowPro", %opts ); # IF CVV2 >= 301 and <= 600 THEN CVV2MATCH == "N" $tx->content( %content, "cvv2" => "301" ); tx_check( $tx, desc => "cvv2(301)", is_success => 0, result_code => 126, error_message => "Under review by Fraud Service", authorization => "010101", avs_code => "Y", cvv2_response => "N", ); # IF CVV2 >= 601 THEN CVV2MATCH == "X" $tx = new Business::OnlinePayment( "PayflowPro", %opts ); $tx->content( %content, "cvv2" => "601" ); tx_check( $tx, desc => "cvv2(601)", is_success => 0, result_code => 126, error_message => "Under review by Fraud Service", authorization => "010101", avs_code => "Y", cvv2_response => "X", ); } sub tx_check { my $tx = shift; my %o = @_; $tx->test_transaction(1); $tx->submit; is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) ); is( $tx->result_code, $o{result_code}, "result_code(): RESULT" ); is( $tx->error_message, $o{error_message}, "error_message() / RESPMSG" ); is( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" ); is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" ); is( $tx->cvv2_response, $o{cvv2_response}, "cvv2_response() / CVV2MATCH" ); like( $tx->order_number, qr/^\w{12}/, "order_number() / PNREF" ); } sub tx_info { my $tx = shift; no warnings 'uninitialized'; return ( join( "", "is_success(", $tx->is_success, ")", " order_number(", $tx->order_number, ")", " error_message(", $tx->error_message, ")", " result_code(", $tx->result_code, ")", " auth_info(", $tx->authorization, ")", " avs_code(", $tx->avs_code, ")", " cvv2_response(", $tx->cvv2_response, ")", ) ); } Business-OnlinePayment-PayflowPro-1.01/t/pod-coverage.t0000644000076400007640000000040311076416511021726 0ustar philadmin#!/usr/bin/perl use strict; use warnings; use Test::More; plan skip_all => 'Set RELEASE_TESTING=1 to run this test' if not $ENV{RELEASE_TESTING}; eval 'use Test::Pod::Coverage'; plan skip_all => 'Needs Test::Pod::Coverage' if $@; all_pod_coverage_ok(); Business-OnlinePayment-PayflowPro-1.01/PayflowPro.pm0000644000076400007640000005223111256236631021374 0ustar philadminpackage Business::OnlinePayment::PayflowPro; use strict; use vars qw($VERSION $DEBUG); use Carp qw(carp croak); use Digest::MD5; use Business::OnlinePayment::HTTPS 0.06; use base qw(Business::OnlinePayment::HTTPS); $VERSION = '1.01'; $VERSION = eval $VERSION; $DEBUG = 0; # CGI::Util was included starting with Perl 5.6. For previous # Perls, let them use the old simple CGI method of unescaping my $no_cgi_util; BEGIN { eval { require CGI::Util; }; $no_cgi_util = 1 if $@; } # return current request_id or generate a new one if not yet set sub request_id { my $self = shift; if ( ref($self) ) { $self->{"__request_id"} = shift if (@_); # allow value change/reset $self->{"__request_id"} = $self->_new_request_id() unless ( $self->{"__request_id"} ); return $self->{"__request_id"}; } else { return $self->_new_request_id(); } } sub _new_request_id { my $self = shift; my $md5 = Digest::MD5->new(); $md5->add( $$, time(), rand(time) ); return $md5->hexdigest(); } sub debug { my $self = shift; if (@_) { my $level = shift || 0; if ( ref($self) ) { $self->{"__DEBUG"} = $level; } else { $DEBUG = $level; } $Business::OnlinePayment::HTTPS::DEBUG = $level; } return ref($self) ? ( $self->{"__DEBUG"} || $DEBUG ) : $DEBUG; } # cvv2_code: support legacy code and but deprecate method sub cvv2_code { shift->cvv2_response(@_); } sub set_defaults { my $self = shift; my %opts = @_; # standard B::OP methods/data $self->server("payflowpro.paypal.com"); $self->port("443"); $self->path("/transaction"); $self->build_subs( qw( partner vendor client_certification_id client_timeout headers test_server cert_path order_number avs_code cvv2_response response_page response_code response_headers ) ); # module specific data if ( $opts{debug} ) { $self->debug( $opts{debug} ); delete $opts{debug}; } # HTTPS Interface Dev Guide: must be set but will be removed in future $self->client_certification_id("ClientCertificationIdNotSet"); # required: 45 secs recommended by HTTPS Interface Dev Guide $self->client_timeout(45); $self->test_server("pilot-payflowpro.paypal.com"); } sub _map_fields { my ($self) = @_; my %content = $self->content(); #ACTION MAP my %actions = ( 'normal authorization' => 'S', # Sale transaction 'credit' => 'C', # Credit (refund) 'authorization only' => 'A', # Authorization 'post authorization' => 'D', # Delayed Capture 'void' => 'V', # Void ); $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); } sub _revmap_fields { my ( $self, %map ) = @_; my %content = $self->content(); foreach ( keys %map ) { $content{$_} = ref( $map{$_} ) ? ${ $map{$_} } : $content{ $map{$_} }; } $self->content(%content); } sub expdate_mmyy { my $self = shift; my $expiration = shift; my $expdate_mmyy; if ( defined($expiration) and $expiration =~ /^(\d+)\D+\d*(\d{2})$/ ) { my ( $month, $year ) = ( $1, $2 ); $expdate_mmyy = sprintf( "%02d", $month ) . $year; } return defined($expdate_mmyy) ? $expdate_mmyy : $expiration; } sub submit { my ($self) = @_; $self->_map_fields(); my %content = $self->content; if ( $self->transaction_type() ne 'C' ) { croak( "PayflowPro can't (yet?) handle transaction type: " . $self->transaction_type() ); } my $expdate_mmyy = $self->expdate_mmyy( $content{"expiration"} ); my $zip = $content{'zip'}; $zip =~ s/[^[:alnum:]]//g; $self->server( $self->test_server ) if $self->test_transaction; my $vendor = $self->vendor; my $partner = $self->partner; $self->_revmap_fields( # BUG?: VENDOR B::OP:PayflowPro < 0.05 backward compatibility. If # vendor not set use login although test indicate undef vendor is ok VENDOR => $vendor ? \$vendor : 'login', PARTNER => \$partner, USER => 'login', PWD => 'password', TRXTYPE => 'action', TENDER => 'type', ORIGID => 'order_number', COMMENT1 => 'description', COMMENT2 => 'invoice_number', ACCT => 'card_number', CVV2 => 'cvv2', EXPDATE => \$expdate_mmyy, # MM/YY from 'expiration' AMT => 'amount', FIRSTNAME => 'first_name', LASTNAME => 'last_name', NAME => 'name', EMAIL => 'email', COMPANYNAME => 'company', STREET => 'address', CITY => 'city', STATE => 'state', ZIP => \$zip, # 'zip' with non-alnums removed COUNTRY => 'country', # As of 8/18/2009: CUSTCODE appears to be cut off at 18 # characters and isn't currently reportable. Consider storing # local customer ids in the COMMENT1/2 fields as a workaround. CUSTCODE => 'customer_id', SHIPTOFIRSTNAME => 'ship_first_name', SHIPTOLASTNAME => 'ship_last_name', SHIPTOSTREET => 'ship_address', SHIPTOCITY => 'ship_city', SHIPTOSTATE => 'ship_state', SHIPTOZIP => 'ship_zip', SHIPTOCOUNTRY => 'ship_country', ); # Reload %content as _revmap_fields makes our copy old/invalid! %content = $self->content; my @required = qw( TRXTYPE TENDER PARTNER VENDOR USER PWD ); # NOTE: we croak above if transaction_type ne 'C' if ( $self->transaction_type() eq 'C' ) { # credit card if ( defined( $content{'ORIGID'} ) && length( $content{'ORIGID'} ) ) { push @required, qw(ORIGID); } else { push @required, qw(AMT ACCT EXPDATE); } } $self->required_fields(@required); my %params = $self->get_fields( qw( VENDOR PARTNER USER PWD TRXTYPE TENDER ORIGID COMMENT1 COMMENT2 ACCT CVV2 EXPDATE AMT FIRSTNAME LASTNAME NAME EMAIL COMPANYNAME STREET CITY STATE ZIP COUNTRY SHIPTOFIRSTNAME SHIPTOLASTNAME SHIPTOSTREET SHIPTOCITY SHIPTOSTATE SHIPTOZIP SHIPTOCOUNTRY CUSTCODE ) ); # get header data my %req_headers = %{ $self->headers || {} }; # get request_id from %content if defined for ease of use if ( defined $content{"request_id"} ) { $self->request_id( $content{"request_id"} ); } unless ( defined( $req_headers{"X-VPS-Request-ID"} ) ) { $req_headers{"X-VPS-Request-ID"} = $self->request_id(); } unless ( defined( $req_headers{"X-VPS-VIT-Client-Certification-Id"} ) ) { $req_headers{"X-VPS-VIT-Client-Certification-Id"} = $self->client_certification_id; } unless ( defined( $req_headers{"X-VPS-Client-Timeout"} ) ) { $req_headers{"X-VPS-Client-Timeout"} = $self->client_timeout(); } my %options = ( "Content-Type" => "text/namevalue", "headers" => \%req_headers, ); # Payflow Pro does not use URL encoding for the request. The # following implements their custom encoding scheme. Per the # developer docs, the PARMLIST Syntax Guidelines are: # - Spaces are allowed in values # - Enclose the PARMLIST in quotation marks ("") # - Do not place quotation marks ("") within the body of the PARMLIST # - Separate all PARMLIST name-value pairs using an ampersand (&) # # Because '&' and '=' have special meanings/uses values containing # these special characters must be encoded using a special "length # tag". The "length tag" is simply the length of the "value" # enclosed in square brackets ([]) and appended to the "name" # portion of the name-value pair. # # For more details see the sections 'Using Special Characters in # Values' and 'PARMLIST Syntax Guidelines' in the PayPal Payflow # Pro Developer's Guide # # NOTE: we pass a string to https_post so it does not do encoding my $params_string = join( '&', map { my $key = $_; my $value = defined( $params{$key} ) ? $params{$key} : ''; if ( index( $value, '&' ) != -1 || index( $value, '=' ) != -1 ) { $key = $key . "[" . length($value) . "]"; } "$key=$value"; } keys %params ); my ( $page, $resp, %resp_headers ) = $self->https_post( \%options, $params_string ); $self->response_code($resp); $self->response_page($page); $self->response_headers( \%resp_headers ); # $page should contain name=value[[&name=value]...] pairs my $response = $self->_get_response( \$page ); # AVS and CVS values may be set on success or failure my $avs_code; if ( defined $response->{"AVSADDR"} or defined $response->{"AVSZIP"} ) { if ( $response->{"AVSADDR"} eq "Y" && $response->{"AVSZIP"} eq "Y" ) { $avs_code = "Y"; } elsif ( $response->{"AVSADDR"} eq "Y" ) { $avs_code = "A"; } elsif ( $response->{"AVSZIP"} eq "Y" ) { $avs_code = "Z"; } elsif ( $response->{"AVSADDR"} eq "N" or $response->{"AVSZIP"} eq "N" ) { $avs_code = "N"; } else { $avs_code = ""; } } $self->avs_code($avs_code); $self->cvv2_response( $response->{"CVV2MATCH"} ); $self->result_code( $response->{"RESULT"} ); $self->order_number( $response->{"PNREF"} ); $self->error_message( $response->{"RESPMSG"} ); $self->authorization( $response->{"AUTHCODE"} ); # RESULT must be an explicit zero, not just numerically equal if ( defined( $response->{"RESULT"} ) && $response->{"RESULT"} eq "0" ) { $self->is_success(1); } else { $self->is_success(0); } } # Process the response page for params. Based on parse_params in CGI # by Lincoln D. Stein. sub _get_response { my ( $self, $page ) = @_; my %response; if ( !defined($page) || ( ref($page) && !defined($$page) ) ) { return \%response; } my ( $param, $value ); foreach ( split( /[&;]/, ref($page) ? $$page : $page ) ) { ( $param, $value ) = split( '=', $_, 2 ); next unless defined $param; $value = '' unless defined $value; if ($no_cgi_util) { # use old pre-CGI::Util method of unescaping $param =~ tr/+/ /; # pluses become spaces $param =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; $value =~ tr/+/ /; # pluses become spaces $value =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; } else { $param = CGI::Util::unescape($param); $value = CGI::Util::unescape($value); } $response{$param} = $value; } return \%response; } 1; __END__ =head1 NAME Business::OnlinePayment::PayflowPro - Payflow Pro backend for Business::OnlinePayment =head1 SYNOPSIS use Business::OnlinePayment; my $tx = new Business::OnlinePayment( 'PayflowPro', 'vendor' => 'your_vendor', 'partner' => 'your_partner', 'client_certification_id' => 'GuidUpTo32Chars', ); # See the module documentation for details of content() $tx->content( type => 'VISA', action => 'Normal Authorization', description => 'Business::OnlinePayment::PayflowPro test', amount => '49.95', invoice_number => '100100', customer_id => 'jsk', name => 'Jason Kohles', address => '123 Anystreet', city => 'Anywhere', state => 'GA', zip => '30004', email => 'ivan-payflowpro@420.am', card_number => '4111111111111111', expiration => '12/09', cvv2 => '123', order_number => 'string', request_id => 'unique_identifier_for_transaction', ); $tx->submit(); if ( $tx->is_success() ) { print( "Card processed successfully: ", $tx->authorization, "\n", "order number: ", $tx->order_number, "\n", "CVV2 response: ", $tx->cvv2_response, "\n", "AVS code: ", $tx->avs_code, "\n", ); } else { my $info = ""; $info = " (CVV2 mismatch)" if ( $tx->result_code == 114 ); print( "Card was rejected: ", $tx->error_message, $info, "\n", "order number: ", $tx->order_number, "\n", ); } =head1 DESCRIPTION This module is a back end driver that implements the interface specified by L to support payment handling via the PayPal's Payflow Pro Internet payment solution. See L for details on the interface this modules supports. =head1 Standard methods =over 4 =item set_defaults() This method sets the 'server' attribute to 'payflowpro.paypal.com' and the port attribute to '443'. This method also sets up the L described below. =item submit() =back =head1 Unofficial methods This module provides the following methods which are not officially part of the standard Business::OnlinePayment interface (as of 3.00_06) but are nevertheless supported by multiple gateways modules and expected to be standardized soon: =over 4 =item L =item L =item L =back =head1 Module specific methods This module provides the following methods which are not currently part of the standard Business::OnlinePayment interface: =head2 client_certification_id() This gets/sets the X-VPS-VITCLIENTCERTIFICATION-ID which is REQUIRED and defaults to "ClientCertificationIdNotSet". This is described in Website Payments Pro HTTPS Interface Developer's Guide as follows: "A random globally unique identifier (GUID) that is currently required. This requirement will be removed in the future. At this time, you can send any alpha-numeric ID up to 32 characters in length. NOTE: Once you have created this ID, do not change it. Use the same ID for every transaction." =head2 client_timeout() Timeout value, in seconds, after which this transaction should be aborted. Defaults to 45, the value recommended by the Website Payments Pro HTTPS Interface Developer's Guide. =head2 debug() Enable or disble debugging. The value specified here will also set $Business::OnlinePayment::HTTPS::DEBUG in submit() to aid in troubleshooting problems. =head2 expdate_mmyy() The expdate_mmyy() method takes a single scalar argument (typically the value in $content{expiration}) and attempts to parse and format and put the date in MMYY format as required by PayflowPro specification. If unable to parse the expiration date simply leave it as is and let the PayflowPro system attempt to handle it as-is. =head2 request_id() It is recommended that you specify your own unique request_id for each transaction in %content. A request_id is REQUIRED by the PayflowPro processor. If a request_id is not set, then Digest::MD5 is used to attempt to generate a request_id for a transaction. =head2 Deprecated methods The following methods are deprecated and may be removed in a future release. Values for vendor and partner should now be set as arguments to Business::OnlinePayment->new(). The value for cert_path was used to support passing a path to PFProAPI.pm (a Perl module/SDK from Verisign/Paypal) which is no longer used. =over 4 =item vendor() =item partner() =item cert_path() =item cvv2_code() =back =head1 Settings The following default settings exist: =over 4 =item server payflowpro.paypal.com or pilot-payflowpro.paypal.com if test_transaction() is TRUE =item port 443 =back =head1 Handling of content(%content) The following rules apply to content(%content) data: =head2 action If 'action' matches one of the following keys it is replaced by the right hand side value: 'normal authorization' => 'S', # Sale transaction 'credit' => 'C', # Credit (refund) 'authorization only' => 'A', # Authorization 'post authorization' => 'D', # Delayed Capture 'void' => 'V', If 'action' is 'C', 'D' or 'V' and 'order_number' is not set then 'amount', 'card_number' and 'expiration' must be set. =head2 type If 'type' matches one of the following keys it is replaced by the right hand side value: 'visa' => 'C', 'mastercard' => 'C', 'american express' => 'C', 'discover' => 'C', 'cc' => 'C', The value of 'type' is used to set transaction_type(). Currently this module only supports a transaction_type() of 'C' any other values will cause Carp::croak() to be called in submit(). Note: Payflow Pro supports multiple credit card types, including: American Express/Optima, Diners Club, Discover/Novus, Enroute, JCB, MasterCard and Visa. =head1 Setting Payflow Pro parameters from content(%content) The following rules are applied to map data to Payflow Pro parameters from content(%content): # PFP param => $content{} VENDOR => $self->vendor ? \( $self->vendor ) : 'login', PARTNER => \( $self->partner ), USER => 'login', PWD => 'password', TRXTYPE => 'action', TENDER => 'type', ORIGID => 'order_number', COMMENT1 => 'description', COMMENT2 => 'invoice_number', ACCT => 'card_number', CVV2 => 'cvv2', EXPDATE => \( $month.$year ), # MM/YY from 'expiration' AMT => 'amount', FIRSTNAME => 'first_name', LASTNAME => 'last_name', NAME => 'name', EMAIL => 'email', COMPANYNAME => 'company', STREET => 'address', CITY => 'city', STATE => 'state', ZIP => \$zip, # 'zip' with non-alphanumerics removed COUNTRY => 'country', # As of 8/18/2009: CUSTCODE appears to be cut off at 18 # characters and isn't currently reportable. Consider storing # local customer ids in the COMMENT1/2 fields as a workaround. CUSTCODE => 'customer_id', SHIPTOFIRSTNAME => 'ship_first_name', SHIPTOLASTNAME => 'ship_last_name', SHIPTOSTREET => 'ship_address', SHIPTOCITY => 'ship_city', SHIPTOSTATE => 'ship_state', SHIPTOZIP => 'ship_zip', SHIPTOCOUNTRY => 'ship_country', The required Payflow Pro parameters for credit card transactions are: TRXTYPE TENDER PARTNER VENDOR USER PWD ORIGID =head1 Mapping Payflow Pro transaction responses to object methods The following methods provides access to the transaction response data resulting from a Payflow Pro request (after submit()) is called: =head2 order_number() This order_number() method returns the PNREF field, also known as the PayPal Reference ID, which is a unique number that identifies the transaction. =head2 result_code() The result_code() method returns the RESULT field, which is the numeric return code indicating the outcome of the attempted transaction. A RESULT of 0 (zero) indicates the transaction was approved and is_success() will return '1' (one/TRUE). Any other RESULT value indicates a decline or error and is_success() will return '0' (zero/FALSE). =head2 error_message() The error_message() method returns the RESPMSG field, which is a response message returned with the transaction result. =head2 authorization() The authorization() method returns the AUTHCODE field, which is the approval code obtained from the processing network. =head2 avs_code() The avs_code() method returns a combination of the AVSADDR and AVSZIP fields from the transaction result. The value in avs_code is as follows: Y - Address and ZIP match A - Address matches but not ZIP Z - ZIP matches but not address N - no match undef - AVS values not available =head2 cvv2_response() The cvv2_response() method returns the CVV2MATCH field, which is a response message returned with the transaction result. =head1 COMPATIBILITY As of 0.07, this module communicates with the Payflow gateway directly and no longer requires the Payflow Pro SDK or other download. Thanks to Phil Lobbes for this great work and Josh Rosenbaum for additional enhancements and bug fixes. =head1 AUTHORS Ivan Kohler Phil Lobbes Ephil at perkpartners.comE Based on Business::OnlinePayment::AuthorizeNet written by Jason Kohles. =head1 SEE ALSO perl(1), L, L, and the PayPal Integration Center Payflow Pro resources at L =cut Business-OnlinePayment-PayflowPro-1.01/Changes0000644000076400007640000001330111256236373020225 0ustar philadminRevision history for Perl extension Business::OnlinePayment::PayflowPro. 1.01 Tue Sep 22 17:03:00 EDT 2009 plobbes - rt.cpan.org#49349: Fix Reference Transactions NOTE: enable in PayfloPro manager transaction settings Josh Rosenbaum 1.00 Sat Aug 22 01:13:34 EDT 2009 plobbes - bump version to 1.00, should have probably done this with 0.07 as it was a radical enough departure from 0.06, also BOP 3.x is no longer just a developers release - rt.cpan.org#48696 Use CGI::Util instead of CGI Josh Rosenbaum + updated code to be faster/more efficient - rt.cpan.org#48816 Request Encoding Issue & Missing fields Josh Rosenbaum + use PayPal custom encoding (not URL encoding) per PP spec + added missing shipping parameters similar to Authorize.Net - rt.cpan.org#48820 %content not reloaded after mapping breaks credits Josh Rosenbaum + fix a problem with credits where the ACCT, AMT, and EXPDATE were being required, because the ORIGID detection code was not working 0.07 Tue Apr 14 13:49:50 EDT 2009 plobbes - update server names per latest PayPal docs: payflow.verisign.com => payflowpro.verisign.com pilot-payflowpro.verisign.com => pilot-payflowpro.paypal.com [0.07_06 Sat Oct 18 14:15:03 EDT 2008] plobbes - include most of the patches from Frédéric Brière at fbriere.net - request_id now only generates a new id when not set - cvv2_code brought back for backwards compatibility - client_certification_id now default to "ClientCertificationIdNotSet" - client_timeout set to 45 by default - several doc updates and some reorg [0.07_05 Wed Apr 4 12:56:57 PDT 2007] ivan - add note about inteface & contacting payflowintegrator@paypal.com [0.07_04 Tue Mar 13 18:26:12 EDT 2007] ivan - ripped out a bunch of hastily-conceived ->param BS more appropriate for implementation in a base class. Server names were incorrect. Tests were broken (some specific to a particular account). - depend on B:OP:HTTPS 0.06 for Crypt::SSLeay fixes [0.07_03 Tue Mar 13 18:26:12 EDT 2007] plobbes - add "shortcut" param 'client_certification_id' (can be passed as an argument for B::OP->new() which will set the X-VPS-VIT-CLIENT-CERTIFICATION-ID header [0.07_02 Tue Mar 13 12:32:57 EDT 2007] plobbes - made generic method for deprecating cert_path, etc. - doc'd vendor() and partner() as deprecated but will not put out warnings on those (B::OP new() behavior would make this annoying) - shortened code for the custom methods (we are not using build_subs()) - use path() again as "/commit" is not needed/used by PayflowPro HTTPS - removed code in submit() related to "/commit" - set param("test_server") so the test server name can be changed [0.07_01 Mon Mar 12 01:56:58 EDT 2007] plobbes - rewrite/updates for new B::OP::PayflowPro using HTTP protocol - no longer using PFProAPI.pm (from Verisign/PayPal) - cert_path() is now deprecated - rewrite/updates for new B::OP::PayflowPro using HTTP protocol - no longer use PFProAPI.pm from Verisign/PayPal - now using name-value pair transactions - require: CGI to parse name-value pair responses from server - require: Digest::MD5 to generate (hopefully) unique request_id which is required by PayflowPro HTTP protocol - new methods: request_id(), param(), debug(), expdate_mmyy() - renamed internal methods to start with an underscore - removed unused remap_fields() method - if unable to parse expiration given in %content no longer croak, but let PayflowPro servers attempt to deal with the value as-is - submit() now two phased per PFP HTTP protocol - X-VPS-VIT-CLIENT-CERTIFICATION-ID is required (supposedly this is a temporary requirement from PayPal) - request_id() method will generate a hopefully unique id using Digest::MD5 for use in the X-VPS-REQUEST-ID HTTP header. A 'request_id' key may be passed in %content to specify an ID - path() is not used as the PFP HTTP protocol uses two different URLs (step 1) /transaction, (step 2) /commit - patches to B::OP::HTTPS were required to support needed functionality - debug() sets $Business::OnlinePayment::HTTPS::DEBUG for debugging 0.06 Thu Mar 1 10:01:33 EST 2007 - zip now allows alphanumerics for non-US zips 0.05 Mon Jan 22 00:58:04 EST 2007 [Jan 22 2007 by Phil Lobbes ] - Test cases: new tests and cleanup of existing tests - Major update of documentation - Now attempt to set avs_code, cvv2_code, result_code, error_message and authorization on success or failure. - Ran PayflowPro.pm through perltidy (1.12 -> 1.13) [Dec 23 2006 by Phil Lobbes ] - CPAN bug #13896 order_number() (which provides access to PNREF) is not set when transaction fails [FIXED]. - Remove AutoLoader/Exporter per Jo Rhett - "use" (instead of "require") Business::OnlinePayment - remove build_subs() and get_fields() (provided by B::OP) - Fixed bug: VENDOR set to login instead of vendor (will still use login if VENDOR is not set) - minor cleanup remove commented out code, reformat docs a little 0.04 Wed Oct 11 04:00:36 PDT 2006 - Prevent unnecessary warnings when no AVS response elements are received, patch from Michael Peters - have tests work with environment variables - forgot to increment the version number in 0.03 0.03 Tue Aug 2 17:56:11 PDT 2005 - Fix inadvertant clobbering of zip code, patch from , CPAN bug #13896 0.02 Thu Oct 7 15:58:44 PDT 2004 - sponsored by Pro Softnet Corp. / ibackup.com: - cvv2 support - authorization only, post authorization, void and credit support - patch from Robert Graff for credits 0.01 Wed Jan 22 02:47:25 PST 2003 - original version; created by ivan 1.0 Business-OnlinePayment-PayflowPro-1.01/Makefile.PL0000644000076400007640000000146211076424775020716 0ustar philadminuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Business::OnlinePayment::PayflowPro', VERSION_FROM => 'PayflowPro.pm', PREREQ_PM => { Business::OnlinePayment => '3', Business::OnlinePayment::HTTPS => '0.06', CGI => 0, Digest::MD5 => 0, }, ( $] >= 5.005 ? ## Add these new keywords supported since 5.005 ( ABSTRACT_FROM => 'PayflowPro.pm', AUTHOR => join( ' and ', 'Ivan Kohler ', 'Phil Lobbes ', ), ) : () ), );