- made generic method for deprecating cert_path, etc.
authorplobbes <plobbes>
Tue, 13 Mar 2007 16:28:49 +0000 (16:28 +0000)
committerplobbes <plobbes>
Tue, 13 Mar 2007 16:28:49 +0000 (16:28 +0000)
- doc'd vendor() and partner() as deprecated but will not put out
  warnings on those for now (B::OP new() behavior would make this annoying)
- shortened code for the custom methods (we are not using build_subs())
- now using path() again as "/commit" is not needed/used by PayflowPro HTTPS
- removed code in submit() related to "/commit" that is no longer needed
- set param("test_server") so the test server name can be changed

PayflowPro.pm

index dca45ba..b91e007 100644 (file)
@@ -8,7 +8,7 @@ use Digest::MD5;
 
 use base qw(Business::OnlinePayment::HTTPS);
 
-$VERSION = '0.07_01';
+$VERSION = '0.07_02';
 $VERSION = eval $VERSION;
 $DEBUG   = 0;
 
@@ -65,36 +65,43 @@ sub debug {
     return ref($self) ? ( $self->{"__DEBUG"} || $DEBUG ) : $DEBUG;
 }
 
-sub cert_path {
-    carp( __PACKAGE__ . " cert_path method is deprecated" );
-    return undef;
-}
-
-# maybe get rid of build_subs() someday and use param()?
-sub vendor  { my $self = shift; return $self->param( "vendor",  @_ ); }
-sub partner { my $self = shift; return $self->param( "partner", @_ ); }
-sub order_number {
+sub _deprecate {
     my $self = shift;
-    return $self->param( "order_number", @_ );
+    carp( "method '", __PACKAGE__, "::$_[0]' is deprecated" );
+    return $self->param(@_);
 }
-sub avs_code  { my $self = shift; return $self->param( "avs_code",  @_ ); }
-sub cvv2_code { my $self = shift; return $self->param( "cvv2_code", @_ ); }
+
+# NOTE: for bigger picture perhaps we get rid of build_subs() some day
+# and instead use something like param() as a standard method?
+
+# deprecated methods:
+sub cert_path { return shift->_deprecate( "cert_path", @_ ); }
+
+# custom methods:
+sub avs_code     { return shift->param( "avs_code",     @_ ); }
+sub cvv2_code    { return shift->param( "cvv2_code",    @_ ); }
+sub order_number { return shift->param( "order_number", @_ ); }
+sub partner      { return shift->param( "partner",      @_ ); }
+sub vendor       { return shift->param( "vendor",       @_ ); }
 
 sub set_defaults {
     my $self = shift;
     my %opts = @_;
 
+    # standard B::OP methods/data
     $self->server("payflow.verisign.com");
     $self->port("443");
-    $self->path("");    # PayflowPro uses /transaction and /commit
+    $self->path("/transaction");
+
+    # module specific data
     if ( $opts{debug} ) {
         $self->debug( $opts{debug} );
         delete $opts{debug};
     }
+
     $self->param(
-        "path_transaction" => "/transaction",
-        "path_commit"      => "/commit",
-        %opts
+        "test_server" => "pilot-payflowpro.verisign.com",
+        %opts,
     );
 }
 
@@ -173,10 +180,11 @@ sub submit {
     my $zip          = $content{'zip'};
     $zip =~ s/[^[:alnum:]]//g;
 
-    $self->server('pilot-payflowpro.verisign.com') if $self->test_transaction;
+    $self->server( $self->param("test_server") ) if $self->test_transaction;
+
+    my $vendor  = $self->param("vendor");
+    my $partner = $self->param("partner");
 
-    my $vendor  = $self->vendor;
-    my $partner = $self->partner;
     $self->_revmap_fields(
 
         # BUG?: VENDOR B::OP:PayflowPro < 0.05 backward compatibility.  If
@@ -247,41 +255,19 @@ sub submit {
         "headers"      => \%req_headers,
     );
 
-    $self->path( $self->param("path_transaction") );
-    my ( $tpage, $tresp, %tresp_headers ) =
+    my ( $page, $resp, %resp_headers ) =
       $self->https_post( \%options, \%params );
 
     $self->param(
         "transaction_response" => {
-            page     => $tpage,
-            response => $tresp,
-            headers  => \%tresp_headers,
+            page     => $page,
+            response => $resp,
+            headers  => \%resp_headers,
         },
     );
 
-    # $tpage should contain name=value[[&name=value]...] pairs
-    my $cgi = CGI->new("$tpage");
-
-    if ( $cgi->param("RESULT") eq "0" ) {
-        my $response_id = $tresp_headers{"X-VPS-RESPONSE-ID"};
-        $options{headers}->{"X-VPS-RESPONSE-ID"} = $response_id;
-        $self->path( $self->param("path_commit") );
-        my ( $cpage, $cresp, %cresp_headers ) =
-          $self->https_post( \%options, \%params );
-        $self->param(
-            "commit_response" => {
-                page     => $cpage,
-                response => $cresp,
-                headers  => \%cresp_headers,
-            },
-        );
-        my $comcgi = CGI->new("$cpage");
-
-        # merge commit results with transaction
-        foreach my $p ( $comcgi->param() ) {
-            $cgi->param( $p => $comcgi->param($p) );
-        }
-    }
+    # $page should contain name=value[[&name=value]...] pairs
+    my $cgi = CGI->new("$page");
 
     # AVS and CVS values may be set on success or failure
     my $avs_code;
@@ -408,10 +394,6 @@ part of the standard Business::OnlinePayment interface:
 
 =over 4
 
-=item vendor()
-
-=item partner()
-
 =item L<order_number()|/order_number()>
 
 =item L<avs_code()|/avs_code()>
@@ -426,11 +408,23 @@ part of the standard Business::OnlinePayment interface:
 
 =item L<debug()|/debug()>
 
-=item cert_path()
+=back
 
-This method is deprecated and will be removed in the next release.
-This method was used to support passing a path to PFProAPI.pm (a Perl
-module/SDK from Verisign/Paypal) which is no longer used.
+=head2 Deprecated methods
+
+The following methods are deprecated and may be removed in the next
+release.  Values for vendor and partner should now be set using the
+param() method or 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()
 
 =back