Partial authorizations
[Business-OnlinePayment.git] / notes_for_module_writers_v3
1 These are the module writer's notes for v3.  See the regular
2 "notes_for_module_writers" file first.
3
4
5 = Business::OnlinePayment::HTTPS =
6
7   If your gateway is HTTPS-based, use (or convert to)
8   Business::OnlinePayment::HTTPS !!
9
10   Note: The correct thing for modern B:OP: gateway modules that need to
11    speak HTTPS to do is to use Business::OnlinePayment::HTTPS and depend on
12    "Net::HTTPS::Any" (since B:OP itself doesn't).
13
14
15 = Handling failures =
16
17     - If your processor module encounters a setup problem, communication
18       error or other problem that's prevents the card from even being
19       run, you should die (or croak) with a useful error message.  Setting
20       is_success to 0 and returning normally should only be done when the
21       transaction *processing* was sucessful (or at least elicited some sort
22       of result from the gateway), but the transaction itself returned a
23       "normal" decline status of some sort.
24       
25     - (NEW IN 3.00_04) You should set "failure_status" depending on the
26       specific failure result, if (and only if) the failure results from one
27       of the defined statuses:
28
29       - "expired"
30       - "nsf" (non-sufficient funds / credit limit)
31       - "stolen"
32       - "pickup"
33       - "blacklisted"
34       - "inactive" (inactive card or not authorized for card-not-present) (?)
35       - "decline" (other card/transaction declines only, not other errors)
36   
37
38 = (NEW IN 3.01) Introspection =
39
40   - Add an _info subroutine to your module that returns a hashref of
41     information:
42
43       sub _info {
44         {
45           'info_compat'           => '0.01', # always 0.01 for now,
46                                              # 0.02 will have requirements
47           'gateway_name'          => 'Example Gateway',
48           'gateway_url'           => 'http://www.example.com/',
49           'module_version'        => $VERSION,
50           'supported_types'       => [ qw( CC ECHECK ) ],
51           'token_support'         => 0, #card storage/tokenization support
52           'test_transaction'      => 0, #set true if ->test_transaction(1) works
53           'supported_actions'     => [
54                                        'Normal Authorization',
55                                        'Authorization Only',
56                                        'Post Authorization',
57                                        'Void',
58                                        'Credit',
59                                      ],
60         };
61       }
62
63     # or a more complicated case:
64
65       sub _info {
66         {
67           'info_compat'           => '0.01', # always 0.01 for now,
68                                              # 0.02 will have requirements
69           'gateway_name'          => 'Example Gateway',
70           'gateway_url'           => 'http://www.example.com/',
71           'module_version'        => $VERSION,
72           'module_notes'          => 'usage notes',
73           'supported_types'       => [ qw( CC ECHECK ) ],
74           'token_support'         => 1,
75           'test_transaction'      => 1,
76           'supported_actions'     => { 'CC' => [
77                                          'Normal Authorization',
78                                          'Authorization Only',
79                                          'Post Authorization',
80                                          'Void',
81                                          'Credit',
82                                          'Recurring Authorization',
83                                          'Modify Recurring Authorization',
84                                          'Cancel Recurring Authorization',
85                                        ],
86                                        'ECHECK' => [
87                                          'Normal Authorization',
88                                          'Void',
89                                          'Credit',
90                                        ],
91                                      },
92           'CC_void_requires_card' => 1,
93           'ECHECK_void_requires_account' => 1, #routing_code, account_number, name 
94         };
95       }
96
97
98 = authorization and order_number (NEWLY DOCUMENTED IN 3.01) =
99
100   Gateways will return one or two values from Authorization Only and
101   Normal Authorization transactions that must be submitted back with a
102   Post Authorization, Void, or Credit transaction.
103
104   If the gateway returns one value, return this as "authorization"
105
106   If the gateway returns two values, return one as "authorization" and the
107   other as "order_number".  Typically "authorization" is the more low-level
108   value returned from the underlying processing network while "order_number"
109   is a unique tranaction id generated by the gateway.
110
111
112 = Moo (NEWLY DOCUMENTED IN 3.04) =
113
114   Feel free to write gateway modules which use Moo.  Please do not require
115   Moo newer than 0.091011 at this time (until 2018 or so).
116
117
118 = Partial authorizations (NEWLY DOCUMENTED IN 3.04) =
119
120   If your gateway supports partial authorizations:
121
122   - Declare this in your "sub _info" introspection subroutine:
123       'partial_auth' => 1,
124
125   - Add "partial_auth_amount to your build_subs call in set_defaults, or add
126     one:
127       $self->build_subs('partial_auth_amount');
128
129   - Honor the transaction 'partial_auth' flag as follows:
130     + If this transaction flag is unset, the application is not expecting to
131       handle a partial authorzation.  So, either set the gateway flag disabling
132       partial authorizations, or (if your gatweay does not have such a
133       setting), immediately void any partial authorization received and
134       return is_success 0.
135     + If this transaction flag is set, the application can handle a partial
136       authorization.  Make sure the flag to enable them is passed to the
137       gateway, if necessary.  When a partial authorization is received, the
138       amount must be returned as "partial_auth_amount":
139         $self->partial_auth_amount( $partial_amount );
140       For normal full authorizations, "partial_auth_amount" must not be set.
141
142