Partial authorizations
authorIvan Kohler <ivan@freeside.biz>
Thu, 5 Nov 2015 18:20:27 +0000 (10:20 -0800)
committerIvan Kohler <ivan@freeside.biz>
Thu, 5 Nov 2015 18:20:27 +0000 (10:20 -0800)
1  2 
OnlinePayment.pm
notes_for_module_writers_v3

diff --combined OnlinePayment.pm
@@@ -19,7 -19,6 +19,7 @@@ my @methods = qw
      failure_status
      fraud_detect
      is_success
 +    partial_auth_amount
      maximum_risk
      path
      port
@@@ -36,6 -35,8 +36,8 @@@
      response_page
      avs_code
      cvv2_response
+     partial_auth
+     partial_auth_amount
  );
  
  __PACKAGE__->build_subs(@methods);
@@@ -382,6 -383,11 +384,11 @@@ just a whole or floating point number (
  
  =over 4
  
+ =item partial_auth
+ Set true to accept a partial authorization.  If this flag is not set, a partial
+ authorization will be immediately reversed or voided.
  =item description
  
  A description of the transaction (used by some processors to send
@@@ -417,13 -423,6 +424,13 @@@ Tax exempt flag (i.e. TRUE, FALSE, T, F
  Currency, specified as an ISO 4217 three-letter code, such as USD, CAD, EUR,
  AUD, DKK, GBP, JPY, NZD, etc.
  
 +=item partial_auth
 +
 +If you are prepared to handle partial authorizations
 +(see L<partial_auth_amount()|/"partial_auth_amount()">
 + in L<TRANSACTION RESULT FIELDS|/"TRANSACTION RESULT FIELDS">),
 +pass a true value in this field to enable them.
 +
  =back
  
  =head3 CUSTOMER INFO FIELDS
@@@ -662,15 -661,6 +669,15 @@@ Returns true if the transaction was app
  it was submitted but not approved, or undef if it has not been 
  submitted yet.
  
 +=head2 partial_auth_amount()
 +
 +If this transaction was a partial authorization (i.e. successful, but less than
 +the requested amount was processed), then the amount processed is returned in
 +this field.
 +
 +(When is_success is true but this field is empty or 0, that indicates a normal
 +full authorization for the entire requested amount.)
 +
  =head2 error_message()
  
  If the transaction has been submitted but was not accepted, this
@@@ -688,6 -678,11 +695,11 @@@ other errors)
  Note that not all processor modules support this, and that if supported,
  it may not be set for all declines.
  
+ =head2 partial_auth_amount()
+ Amount of the partial authorization, if the processor supports them and the
+ partial_auth flag was passed to indicate they should be processed.
  =head2 authorization()
  
  If the transaction has been submitted and accepted, this function will
@@@ -2,17 -2,14 +2,17 @@@ These are the module writer's notes fo
  "notes_for_module_writers" file first.
  
  
 -- If your gateway is HTTPS-based, use (or convert to)
 += Business::OnlinePayment::HTTPS =
 +
 +  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:
 += Handling failures =
  
      - If your processor module encounters a setup problem, communication
        error or other problem that's prevents the card from even being
@@@ -35,7 -32,7 +35,7 @@@
        - "decline" (other card/transaction declines only, not other errors)
    
  
 -- (NEW IN 3.01) Introspection:
 += (NEW IN 3.01) Introspection =
  
    - Add an _info subroutine to your module that returns a hashref of
      information:
@@@ -50,6 -47,7 +50,7 @@@
            'supported_types'       => [ qw( CC ECHECK ) ],
            'token_support'         => 0, #card storage/tokenization support
            'test_transaction'      => 0, #set true if ->test_transaction(1) works
+           'partial_auth'          => 1, #can gateway partial auth (new in 3.04)
            'supported_actions'     => [
                                         'Normal Authorization',
                                         'Authorization Only',
@@@ -95,7 -93,7 +96,7 @@@
        }
  
  
 -- authorization and order_number (NEWLY DOCUMENTED IN 3.01):
 += authorization and order_number (NEWLY DOCUMENTED IN 3.01) =
  
    Gateways will return one or two values from Authorization Only and
    Normal Authorization transactions that must be submitted back with a
    is a unique tranaction id generated by the gateway.
  
  
 -- Moo (NEWLY DOCUMENTED IN 3.04)
 += Moo (NEWLY DOCUMENTED IN 3.04) =
  
    Feel free to write gateway modules which use Moo.  Please do not require
    Moo newer than 0.091011 at this time (until 2018 or so).
  
 -- Partial authorization (NEW in 3.04)
 +
 += Partial authorizations (NEWLY DOCUMENTED IN 3.04) =
  
    If your gateway supports partial authorizations:
  
 -  + Indicate this in the introspection _info subroutine (see above)
 -  + Accept the partial_auth transaction field:
 -    * if not explicitly set, partial authorizations should be reversed/voided
 -      and returned as is_success 0
 -    * if explicitly set, partial authorizations should return is_success 1
 -      and the authorized amount as partial_auth_amount
 +  - Declare this in your "sub _info" introspection subroutine:
 +      'partial_auth' => 1,
 +
 +  - Add "partial_auth_amount to your build_subs call in set_defaults, or add
 +    one:
 +      $self->build_subs('partial_auth_amount');
 +
 +  - Honor the transaction 'partial_auth' flag as follows:
 +    + If this transaction flag is unset, the application is not expecting to
 +      handle a partial authorzation.  So, either set the gateway flag disabling
 +      partial authorizations, or (if your gatweay does not have such a
 +      setting), immediately void any partial authorization received and
 +      return is_success 0.
 +    + If this transaction flag is set, the application can handle a partial
 +      authorization.  Make sure the flag to enable them is passed to the
-       gateway, if necessary.  When a partial authorization is received, the
-       amount must be returned as "partial_auth_amount":
++      gateway, if necessary.  When a partial authorization is received, return
++      is_success 1, and the amount as "partial_auth_amount":
 +        $self->partial_auth_amount( $partial_amount );
 +      For normal full authorizations, "partial_auth_amount" must not be set.
 +
 +