The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 08
MANIFEST 02
META.json 042
META.yml 2020
OnlinePayment.pm 2538
README 11
notes_for_module_writers_v3 03
t/override.t 024
8 files changed (This is a version diff) 46138
@@ -1,5 +1,13 @@
 Revision history for Perl extension Business::OnlinePayment.
 
+3.03    Tue Apr 29 11:14:25 PDT 2014
+        - Document Reverse Authorization action
+        - Document expiration is MM/YY and fix the example
+        - Document repository moved from CVS to git
+        - Add avs_code and cvv2_response to build_subs, they're standard fields
+        - Document best-practice eval of the submit() method in example
+        - Rework build_subs(), thanks to Michal Schwern, closes: CPAN#22073
+
 3.02    Fri Aug 19 16:20:04 PDT 2011
         - Fix fatal error calling ->info('supported_actions') on a gateway that
           does not yet support introspection (e.g. AuthorizeNet)
@@ -12,7 +12,9 @@ t/bop.t
 t/fd_precharge.t
 t/pod.t
 t/introspection.t
+t/override.t
 notes_for_module_writers
 notes_for_module_writers_v3
 META.yml                                 Module meta-data (added by MakeMaker)
 TODO
+META.json                                Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,42 @@
+{
+   "abstract" : "unknown",
+   "author" : [
+      "Ivan Kohler <ivan-business-onlinepayment@420.am>"
+   ],
+   "dynamic_config" : 1,
+   "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921",
+   "license" : [
+      "unknown"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "Business-OnlinePayment",
+   "no_index" : {
+      "directory" : [
+         "t",
+         "inc"
+      ]
+   },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "Net::HTTPS::Any" : "0",
+            "Tie::IxHash" : "0"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "version" : "3.03"
+}
@@ -1,23 +1,23 @@
---- #YAML:1.0
-name:               Business-OnlinePayment
-version:            3.02
-abstract:           ~
+---
+abstract: unknown
 author:
-    - Ivan Kohler <ivan-business-onlinepayment@420.am>
-license:            unknown
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
+  - 'Ivan Kohler <ivan-business-onlinepayment@420.am>'
 build_requires:
-    ExtUtils::MakeMaker:  0
-requires:
-    Net::HTTPS::Any:  0
-    Tie::IxHash:      0
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.56
+  ExtUtils::MakeMaker: 0
+configure_requires:
+  ExtUtils::MakeMaker: 0
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921'
+license: unknown
 meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: Business-OnlinePayment
+no_index:
+  directory:
+    - t
+    - inc
+requires:
+  Net::HTTPS::Any: 0
+  Tie::IxHash: 0
+version: 3.03
@@ -6,7 +6,7 @@ use Carp;
 
 require 5.005;
 
-$VERSION = '3.02';
+$VERSION = '3.03';
 $VERSION = eval $VERSION; # modperlstyle: convert the string into a number
 
 # Remember subclasses we have "wrapped" submit() with _pre_submit()
@@ -33,8 +33,12 @@ my @methods = qw(
     response_code
     response_header
     response_page
+    avs_code
+    cvv2_response
 );
 
+__PACKAGE__->build_subs(@methods);
+
 #fallback
 sub _info {
   my $class = shift;
@@ -86,7 +90,6 @@ sub new {
     croak("unknown processor $processor ($@)") if $@;
 
     my $self = bless {processor => $processor}, $subclass;
-    $self->build_subs(@methods);
 
     if($self->can("set_defaults")) {
         $self->set_defaults(%data);
@@ -157,7 +160,6 @@ sub _pre_submit {
               unless ( $@ =~ m/^Can\'t locate/ );
         } else {
             my $risk_tx = bless( { processor => $fraud_detection }, $subclass );
-            $risk_tx->build_subs(@methods);
             if ($risk_tx->can('set_defaults')) {
                 $risk_tx->set_defaults();
             }
@@ -270,15 +272,24 @@ Business::OnlinePayment - Perl extension for online payment processing
                         type        => 'Visa',
                         amount      => '49.95',
                         card_number => '1234123412341238',
-                        expiration  => '0100',
+                        expiration  => '06/15',
                         name        => 'John Q Doe',
                        );
-  $transaction->submit();
-  
-  if($transaction->is_success()) {
-    print "Card processed successfully: ", $transaction->authorization(), "\n";
+
+  eval { $transaction->submit(); };
+
+  if ( $@ ) {
+
+    print "$processor error: $@\n";
+
   } else {
-    print "Card was rejected: ", $transaction->error_message(), "\n";
+  
+    if ( $transaction->is_success() ) {
+      print "Card processed successfully: ". $transaction->authorization()."\n";
+    } else {
+      print "Card was rejected: ". $transaction->error_message(). "\n";
+    }
+
   }
 
 =head1 DESCRIPTION
@@ -345,6 +356,8 @@ What action being taken by this transaction. Currently available are:
 
 =item Post Authorization
 
+=item Reverse Authorization
+
 =item Void
 
 =item Credit
@@ -499,7 +512,7 @@ Credit card number.
 
 =item expiration
 
-Credit card expiration.
+Credit card expiration, MM/YY.
 
 =item cvv2
 
@@ -627,14 +640,19 @@ verification (if the processor supports it).
 
 =head2 submit()
 
-Submit the transaction to the processor for completion
+Submit the transaction to the processor for completion.
+
+If there is a gateway communication error or other "meta" , the submit method
+will throw a fatal exception.  You can catch this with eval {} if you would
+like to treat gateway co
 
 =head1 TRANSACTION RESULT METHODS
 
 =head2 is_success()
 
-Returns true if the transaction was submitted successfully, false if
-it failed (or undef if it has not been submitted yet).
+Returns true if the transaction was approved by the gateway, false if 
+it was submitted but not approved, or undef if it has not been 
+submitted yet.
 
 =head2 error_message()
 
@@ -650,10 +668,8 @@ are: "expired", "nsf" (non-sufficient funds), "stolen", "pickup",
 "blacklisted" and "declined" (card/transaction declines only, not
 other errors).
 
-Note that (as of Aug 2006) this is only supported by some of the
-newest processor modules, and that, even if supported, a failure
-status is an entirely optional field that is only set for specific
-kinds of failures.
+Note that not all processor modules support this, and that if supported,
+it may not be set for all declines.
 
 =head2 authorization()
 
@@ -774,7 +790,7 @@ Phil Lobbes E<lt>phil at perkpartners dot comE<gt>
 
 Copyright (c) 1999-2004 Jason Kohles
 Copyright (c) 2004 Ivan Kohler
-Copyright (c) 2007-2011 Freeside Internet Services, Inc.
+Copyright (c) 2007-2014 Freeside Internet Services, Inc.
 
 All rights reserved.
 
@@ -794,21 +810,18 @@ http://420.am/cgi-bin/mailman/listinfo/bop-devel/
 
 =head1 REPOSITORY
 
-The code is available from our public CVS repository:
+The code is available from our public git repository:
 
-  export CVSROOT=":pserver:anonymous@cvs.freeside.biz:/home/cvs/cvsroot"
-  cvs login
-  # The password for the user `anonymous' is `anonymous'.
-  cvs checkout Business-OnlinePayment
+  git clone git://git.freeside.biz/Business-OnlinePayment.git
 
 Or on the web:
 
-  http://freeside.biz/cgi-bin/viewvc.cgi/Business-OnlinePayment/
+  http://freeside.biz/gitweb/?p=Business-OnlinePayment.git
 
 Many (but by no means all!) processor plugins are also available in the same
 repository, see:
 
-  http://freeside.biz/cgi-bin/viewvc.cgi/
+  http://freeside.biz/gitweb/
 
 =head1 DISCLAIMER
 
@@ -1,6 +1,6 @@
 Copyright (c) 1999-2004 Jason Kohles
 Copyright (c) 2004 Ivan Kohler
-Copyright (c) 2007-2010 Freeside Internet Services, Inc.
+Copyright (c) 2007-2012 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.
@@ -4,6 +4,9 @@ These are the module writer's notes for v3.  See the regular
 
 - If your gateway is HTTPS-based, use (or convert to)
   Business::OnlinePayment::HTTPS !!
+  Note: The correct thing for modern B:OP: gateway modules that need to
+   speak HTTPS to do is to use Business::OnlinePayment::HTTPS and depend on
+   "Net::HTTPS::Any" (since B:OP itself doesn't).
 
 
 - Handling failures:
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use Test::More tests => 2;
+
+{    # fake test driver (with submit method)
+
+    package Business::OnlinePayment::MOCK;
+    use strict;
+    use warnings;
+    use base qw(Business::OnlinePayment);
+    sub test_transaction {
+        my $self = shift;
+        return $self->SUPER::test_transaction(@_);
+    }
+}
+
+$INC{"Business/OnlinePayment/MOCK.pm"} = "testing";
+
+my $tx = Business::OnlinePayment->new("MOCK");
+is eval {
+    $tx->test_transaction(1);
+    $tx->test_transaction;
+}, 1;
+is $@, '';