1 package Business::OnlinePayment::Dummy;
5 use Business::OnlinePayment;
6 use vars qw($VERSION @ISA $me);
8 @ISA = qw(Business::OnlinePayment);
10 $me = 'Business::OnlinePayment::Dummy';
14 $self->authorization(time . int(rand(10000)));
24 Business::OnlinePayment::AuthorizeNet - AuthorizeNet backend for Business::OnlinePayment
28 use Business::OnlinePayment;
31 # One step transaction, the simple case.
34 my $tx = new Business::OnlinePayment("AuthorizeNet");
38 password => '', #password or transaction key
39 action => 'Normal Authorization',
40 description => 'Business::OnlinePayment test',
42 invoice_number => '100100',
44 email => 'jason@example.com',
45 first_name => 'Jason',
46 last_name => 'Kohles',
47 address => '123 Anystreet',
52 card_number => '4007000000027',
53 expiration => '09/02',
54 cvv2 => '1234', #optional
55 referer => 'http://valid.referer.url/',
59 if($tx->is_success()) {
60 print "Card processed successfully: ".$tx->authorization."\n";
62 print "Card was rejected: ".$tx->error_message."\n";
66 # Two step transaction, authorization and capture.
67 # If you don't need to review order before capture, you can
68 # process in one step as above.
71 my $tx = new Business::OnlinePayment("AuthorizeNet");
75 password => '', #password or transaction key
76 action => 'Authorization Only',
77 description => 'Business::OnlinePayment test',
79 invoice_number => '100100',
81 email => 'jason@example.com',
82 first_name => 'Jason',
83 last_name => 'Kohles',
84 address => '123 Anystreet',
89 card_number => '4007000000027',
90 expiration => '09/02',
91 cvv2 => '1234', #optional
92 referer => 'http://valid.referer.url/',
96 if($tx->is_success()) {
97 # get information about authorization
98 $authorization = $tx->authorization
99 $ordernum = $tx->order_number;
100 $avs_code = $tx->avs_code; # AVS Response Code
101 $cvv2_response = $tx->cvv2_response; # CVV2/CVC2/CID Response Code
102 $cavv_response = $tx->cavv_response; # Cardholder Authentication
103 # Verification Value (CAVV) Response
106 # now capture transaction
107 my $capture = new Business::OnlinePayment("AuthorizeNet");
111 action => 'Post Authorization',
113 password => 'YOURPASSWORD', #or transaction key
114 order_number => $ordernum,
120 if($capture->is_success()) {
121 print "Card captured successfully: ".$capture->authorization."\n";
123 print "Card was rejected: ".$capture->error_message."\n";
127 print "Card was rejected: ".$tx->error_message."\n";
131 # One step subscription, the simple case.
134 my $tx = new Business::OnlinePayment("AuthorizeNet::ARB");
137 login => 'testdrive',
138 password => 'testpass', #or transaction key
139 action => 'Recurring Authorization',
140 interval => '7 days',
141 start => '2008-3-10',
146 description => 'Business::OnlinePayment test',
147 invoice_number => '1153B33F',
148 customer_id => 'vip',
149 first_name => 'Tofu',
150 last_name => 'Beast',
151 address => '123 Anystreet',
155 card_number => '4111111111111111',
156 expiration => '09/02',
160 if($tx->is_success()) {
161 print "Card processed successfully: ".$tx->order_number."\n";
163 print "Card was rejected: ".$tx->error_message."\n";
165 my $subscription = $tx->order_number
169 # Subscription change. Modestly more complicated.
174 subscription => '99W2C',
175 login => 'testdrive',
176 password => 'testpass', #or transaction key
177 action => 'Modify Recurring Authorization',
178 interval => '7 days',
179 start => '2008-3-10',
184 description => 'Business::OnlinePayment test',
185 invoice_number => '1153B340',
186 customer_id => 'vip',
187 first_name => 'Tofu',
188 last_name => 'Beast',
189 address => '123 Anystreet',
193 card_number => '4111111111111111',
194 expiration => '09/02',
198 if($tx->is_success()) {
199 print "Update processed successfully."\n";
201 print "Update was rejected: ".$tx->error_message."\n";
204 subscription => '99W2D',
205 login => 'testdrive',
206 password => 'testpass', # or transaction key
207 action => 'Cancel Recurring Authorization',
212 # Subscription cancellation. It happens.
215 if($tx->is_success()) {
216 print "Cancellation processed successfully."\n";
218 print "Cancellation was rejected: ".$tx->error_message."\n";
222 =head1 SUPPORTED TRANSACTION TYPES
224 =head2 CC, Visa, MasterCard, American Express, Discover
226 Content required: type, login, password, action, amount, first_name, last_name, card_number, expiration.
230 Content required: type, login, password, action, amount, first_name, last_name, account_number, routing_code, bank_name (non-subscription), account_type (subscription), check_type (subscription).
234 Additional content required: interval, start, periods.
238 For detailed information see L<Business::OnlinePayment>.
240 =head1 METHODS AND FUNCTIONS
242 See L<Business::OnlinePayment> for the complete list. The following methods either override the methods in L<Business::OnlinePayment> or provide additional functions.
246 Returns the response reason code (from the message.code field for subscriptions).
250 Returns the response reason text (from the message.text field for subscriptions.
252 =head2 server_response
254 Returns the complete response from the server.
256 =head1 Handling of content(%content) data:
260 The following actions are valid
267 recurring authorization
268 modify recurring authorization
269 cancel recurring authorization
273 Interval contains a number of digits, whitespace, and the units of days or months in either singular or plural form.
276 =head1 Setting AuthorizeNet ARB parameters from content(%content)
278 The following rules are applied to map data to AuthorizeNet ARB parameters
279 from content(%content):
281 # ARB param => $content{<key>}
282 merchantAuthentication
284 transactionKey => 'password',
288 length => \( the digits in 'interval' ),
289 unit => \( days or months gleaned from 'interval' ), startDate => 'start',
290 totalOccurrences => 'periods',
291 trialOccurrences => 'trialperiods',
293 trialAmount => 'trialamount',
296 cardNumber => 'card_number',
297 expiration => \( $year.'-'.$month ), # YYYY-MM from 'expiration'
299 accountType => 'account_type',
300 routingNumber => 'routing_code',
301 accountNumber => 'account_number,
302 nameOnAccount => 'name',
303 bankName => 'bank_name',
304 echeckType => 'check_type',
306 invoiceNumber => 'invoice_number',
307 description => 'description',
309 type => 'customer_org',
312 phoneNumber => 'phone',
315 number => 'license_num',
316 state => 'license_state',
317 dateOfBirth => 'license_dob',
318 taxid => 'customer_ssn',
320 firstName => 'first_name',
321 lastName => 'last_name',
322 company => 'company',
323 address => 'address',
327 country => 'country',
329 firstName => 'ship_first_name',
330 lastName => 'ship_last_name',
331 company => 'ship_company',
332 address => 'ship_address',
334 state => 'ship_state',
336 country => 'ship_country',
340 Use your transaction key in the password field.
342 Unlike Business::OnlinePayment or pre-3.0 versions of
343 Business::OnlinePayment::AuthorizeNet, 3.1 requires separate first_name and
346 Business::OnlinePayment::AuthorizeNet uses Authorize.Net's "Advanced
347 Integration Method (AIM) (formerly known as ADC direct response)" and
348 "Automatic Recurring Billing (ARB)", sending a username and password (or
349 transaction key as password) with every transaction. Therefore,
350 Authorize.Net's referrer "security" is not necessary. In your Authorize.Net
351 interface at https://secure.authorize.net/ make sure the list of allowable
352 referers is blank. Alternatively, set the B<referer> field in the transaction
355 To settle an authorization-only transaction (where you set action to
356 'Authorization Only'), submit the nine-digit transaction id code in
357 the field "order_number" with the action set to "Post Authorization".
358 You can get the transaction id from the authorization by calling the
359 order_number method on the object returned from the authorization.
360 You must also submit the amount field with a value less than or equal
361 to the amount specified in the original authorization.
363 For the subscription actions an authorization code is never returned by
364 the module. Instead it returns the value of subscriptionId in order_number.
365 This is the value to use for changing or cancelling subscriptions.
367 Authorize.Net has turned address verification on by default for all merchants
368 since 2002. If you do not have valid address information for your customer
369 (such as in an IVR application), you must disable address verification in the
370 Merchant Menu page at https://secure.authorize.net/ so that the transactions
371 aren't denied due to a lack of address information.
375 This module implements Authorize.Net's API using the Advanced Integration
376 Method (AIM) version 3.1, formerly known as ADC Direct Response and the
377 Automatic Recurring Billing version 1.0 using the XML interface. See
378 http://www.authorize.net/support/AIM_guide.pdf and http://www.authorize.net/support/ARB_guide.pdf for details.
382 Original author: Jason Kohles, jason@mediabang.com
384 Ivan Kohler <ivan-authorizenet@freeside.biz> updated it for Authorize.Net
385 protocol 3.0/3.1 and is the current maintainer. Please see the next section
386 for for information on contributing.
388 Jason Spence <jspence@lightconsulting.com> contributed support for separate
389 Authorization Only and Post Authorization steps and wrote some docs.
390 OST <services@ostel.com> paid for it.
392 Jeff Finucane <authorizenetarb@weasellips.com> added the ARB support.
393 ARB support sponsored by Plus Three, LP. L<http://www.plusthree.com>.
395 T.J. Mather <tjmather@maxmind.com> sent a number of CVV2 patches.
397 Mike Barry <mbarry@cos.com> sent in a patch for the referer field and a fix for
400 Yuri V. Mkrtumyan <yuramk@novosoft.ru> sent in a patch to add the void action.
402 Paul Zimmer <AuthorizeNetpm@pzimmer.box.bepress.com> sent in a patch for
403 card-less post authorizations.
405 Daemmon Hughes <daemmon@daemmonhughes.com> sent in a patch for "transaction
406 key" authentication as well support for the recurring_billing flag and the md5
407 method that returns the MD5 hash which is returned by the gateway.
409 Steve Simitzis contributed a patch for better compatibility with
410 eProcessingNetwork's AuthorizeNet compatibility mode.
412 Michael G. Schwern contributed cleanups, test fixes, and more.
414 Erik Hollensbe implemented card-present data (track1/track2), the
415 duplicate_window parameter, and test fixes.
417 Paul Timmins added the check_number field.
419 Nate Nuss implemented the ("Additional Shipping Information (Level 2 Data)"
420 fields: tax, freight, duty, tax_exempt, po_number.
422 Michael Peters fixed a bug in email address handling.
424 Thomas Sibley <trs@bestpractical.com> wrote B:OP:AuthorizeNet::AIM::ErrorCodes
425 which was borged and used to provide more descriptive error messages.
427 Craig Pearlman <cpearlma@yahoo.com> sent in a patch to more accurately declare
428 required fields for E-check transcations.
430 =head1 CONTRIBUTIONS AND REPOSITORY
432 Please send patches as unified diffs (diff -u) to (in order of preference):
438 http://rt.cpan.org/Public/Bug/Report.html?Queue=Business-OnlinePayment-AuthorizeNet
440 =item The bop-devel mailing list
442 http://420.am/cgi-bin/mailman/listinfo/bop-devel
446 Ivan Kohler <ivan-authorizenet@freeside.biz>
450 The code is available from our public CVS repository:
452 export CVSROOT=":pserver:anonymous@cvs.freeside.biz:/home/cvs/cvsroot"
454 # The password for the user `anonymous' is `anonymous'.
455 cvs checkout Business-OnlinePayment-AuthorizeNet
459 http://freeside.biz/cgi-bin/viewvc.cgi/Business-OnlinePayment-AuthorizeNet/
461 =head1 A WORD FROM OUR SPONSOR
463 This module and the Business::OnlinePayment framework are maintained by by
464 Freeside Internet Services. If you need a complete, open-source web-based
465 application to manage your customers, billing and trouble ticketing, please
466 visit http://freeside.biz/
468 =head1 COPYRIGHT & LICENSE
470 Copyright 2010 Freeside Internet Services, Inc.
471 Copyright 2008 Thomas Sibley
474 This program is free software; you can redistribute it and/or modify it
475 under the same terms as Perl itself.
479 perl(1). L<Business::OnlinePayment>.