AuthorizeNet(3pm)

πŸ“¦
version 3.23 Β· 2 versions
  • 3.23 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 3.23 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– AuthorizeNet(3pm) β€” Business::OnlinePayment::AuthorizeNet πŸ’–

okay bestie, sit down, hydrate, and let me tell you about Business::OnlinePayment::AuthorizeNet β€” the AuthorizeNet backend for Business::OnlinePayment. This is a page from the User Contributed Perl Documentation section of the manual, and it is lowkey a whole vibe. It's long so it comes in parts β€” this is part 1, so don't go anywhere. 🫢


✨ NAME ✨

Business::OnlinePayment::AuthorizeNet β€” the AuthorizeNet backend for Business::OnlinePayment. That's it, that's the name, it's giving "I do one thing and I do it iconically." πŸ’…


🌸 SYNOPSIS 🌸

Bestie, here's the whole vibe in code. No cap, this is verbatim, copy it exactly.

  use Business::OnlinePayment;

  ####
  # One step transaction, the simple case.
  ####

  my $tx = new Business::OnlinePayment("AuthorizeNet");
  $tx->content(
      type           => 'VISA',
      login          => 'testdrive',
      password       => '', #password or transaction key
      action         => 'Normal Authorization',
      description    => 'Business::OnlinePayment test',
      amount         => '49.95',
      invoice_number => '100100',
      customer_id    => 'jsk',
      email          => 'jason@example.com',
      first_name     => 'Jason',
      last_name      => 'Kohles',
      address        => '123 Anystreet',
      city           => 'Anywhere',
      state          => 'UT',
      zip            => '84058',
      country        => 'US',
      card_number    => '4007000000027',
      expiration     => '09/02',
      cvv2           => '1234', #optional
      referer        => 'http://valid.referer.url/',
  );
  $tx->submit();

  if($tx->is_success()) {
      print "Card processed successfully: ".$tx->authorization."\n";
  } else {
      print "Card was rejected: ".$tx->error_message."\n";
  }

One step, one submit, one slay. πŸ’– Now the two-step version β€” authorize first, then capture later. If you don't need to review the order before capture, you can literally just process in one step like above. πŸ‘‘

  ####
  # Two step transaction, authorization and capture.
  # If you don't need to review order before capture, you can
  # process in one step as above.
  ####

  my $tx = new Business::OnlinePayment("AuthorizeNet");
  $tx->content(
      type           => 'VISA',
      login          => 'testdrive',
      password       => '',  #password or transaction key
      action         => 'Authorization Only',
      description    => 'Business::OnlinePayment test',
      amount         => '49.95',
      invoice_number => '100100',
      customer_id    => 'jsk',
      email          => 'jason@example.com',
      first_name     => 'Jason',
      last_name      => 'Kohles',
      address        => '123 Anystreet',
      city           => 'Anywhere',
      state          => 'UT',
      zip            => '84058',
      country        => 'US',
      card_number    => '4007000000027',
      expiration     => '09/02',
      cvv2           => '1234', #optional
      referer        => 'http://valid.referer.url/',
  );
  $tx->submit();

  if($tx->is_success()) {
      # get information about authorization
      $authorization = $tx->authorization
      $ordernum = $tx->order_number;
      $avs_code = $tx->avs_code; # AVS Response Code
      $cvv2_response = $tx->cvv2_response; # CVV2/CVC2/CID Response Code
      $cavv_response = $tx->cavv_response; # Cardholder Authentication
                                           # Verification Value (CAVV) Response
                                           # Code

      # now capture transaction
      my $capture = new Business::OnlinePayment("AuthorizeNet");

      $capture->content(
          type           => 'CC',
          action         => 'Post Authorization',
          login          => 'YOURLOGIN
          password       => 'YOURPASSWORD', #or transaction key
          order_number   => $ordernum,
          amount         => '49.95',
      );

      $capture->submit();

      if($capture->is_success()) {
          print "Card captured successfully: ".$capture->authorization."\n";
      } else {
          print "Card was rejected: ".$capture->error_message."\n";
      }

  } else {
      print "Card was rejected: ".$tx->error_message."\n";
  }

Heads up bestie, that login => 'YOURLOGIN line is missing its closing quote in the source β€” that's how it is, I'm not touching it, I don't fix what I didn't break. πŸ™ˆ

Now the subscription glow-up. ✨ One-step, simple case:

  ####
  # One step subscription, the simple case.
  ####

  my $tx = new Business::OnlinePayment("AuthorizeNet::ARB");
  $tx->content(
      type           => 'CC',
      login          => 'testdrive',
      password       => 'testpass', #or transaction key
      action         => 'Recurring Authorization',
      interval       => '7 days',
      start          => '2008-3-10',
      periods        => '16',
      amount         => '99.95',
      trialperiods   => '4',
      trialamount    => '0',
      description    => 'Business::OnlinePayment test',
      invoice_number => '1153B33F',
      customer_id    => 'vip',
      first_name     => 'Tofu',
      last_name      => 'Beast',
      address        => '123 Anystreet',
      city           => 'Anywhere',
      state          => 'GA',
      zip            => '84058',
      card_number    => '4111111111111111',
      expiration     => '09/02',
  );
  $tx->submit();

  if($tx->is_success()) {
      print "Card processed successfully: ".$tx->order_number."\n";
  } else {
      print "Card was rejected: ".$tx->error_message."\n";
  }
  my $subscription = $tx->order_number

Tofu Beast is a real customer id in this example and honestly? iconic name, 10/10. πŸ“

Subscription change β€” "modestly more complicated" per the source, which is the most polite way anyone has ever described this. 😭

  ####
  # Subscription change.   Modestly more complicated.
  ####

  $tx->content(
      type           => 'CC',
      subscription   => '99W2C',
      login          => 'testdrive',
      password       => 'testpass', #or transaction key
      action         => 'Modify Recurring Authorization',
      interval       => '7 days',
      start          => '2008-3-10',
      periods        => '16',
      amount         => '29.95',
      trialperiods   => '4',
      trialamount    => '0',
      description    => 'Business::OnlinePayment test',
      invoice_number => '1153B340',
      customer_id    => 'vip',
      first_name     => 'Tofu',
      last_name      => 'Beast',
      address        => '123 Anystreet',
      city           => 'Anywhere',
      state          => 'GA',
      zip            => '84058',
      card_number    => '4111111111111111',
      expiration     => '09/02',
  );
  $tx->submit();

  if($tx->is_success()) {
      print "Update processed successfully."\n";
  } else {
      print "Update was rejected: ".$tx->error_message."\n";
  }
  $tx->content(
      subscription   => '99W2D',
      login          => 'testdrive',
      password       => 'testpass', # or transaction key
      action         => 'Cancel Recurring Authorization',
  );
  $tx->submit();

And subscription cancellation β€” it happens, babe, people unsubscribe, it's not personal. πŸ’€

  ####
  # Subscription cancellation.   It happens.
  ####

  if($tx->is_success()) {
      print "Cancellation processed successfully."\n";
  } else {
      print "Cancellation was rejected: ".$tx->error_message."\n";
  }

🌈 SUPPORTED TRANSACTION TYPES 🌈

πŸ’³ CC, Visa, MasterCard, American Express, Discover

Content required: type, login, password, action, amount, first_name, last_name, card_number, expiration.

That's the full list. Nine fields. Not one more, not one less, don't be extra. πŸ’…

🧾 Check

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).

Yes the parentheticals matter β€” bank_name is for the non-subscription case, and account_type + check_type are for the subscription case. Read carefully bestie, iykyk. πŸ‘€

πŸ” Subscriptions

Additional content required: interval, start, periods.


πŸ¦‹ DESCRIPTION πŸ¦‹

For the detailed tea, go read Business::OnlinePayment. That's where the full story lives. ✨


πŸ‘‘ METHODS AND FUNCTIONS πŸ‘‘

See Business::OnlinePayment for the complete list β€” that's the whole roster. The following methods are the special ones: they either override the methods in Business::OnlinePayment, or they're additional functions that only exist here. Main character energy, honestly. πŸ’–

⭐ result_code

Returns the response reason code. (and for subscriptions, it comes from the message.code field 🌈)

⭐ error_message

Returns the response reason text. (and for subscriptions, it comes from the message.text field πŸŽ€)

⭐ server_response

Returns the complete response from the server. The whole thing. Unfiltered. No edits. πŸ’…


πŸŽ€ Handling of content(%content) data πŸŽ€

πŸ’œ action

The following actions are valid:

  normal authorization
  authorization only
  credit
  post authorization
  void
  recurring authorization
  modify recurring authorization
  cancel recurring authorization

Eight actions, all lowercase, exactly as written. If you type something else, that's on you, not on me. πŸ™ˆ

πŸ’œ interval

Interval contains a number of digits, whitespace, and the units of days or months in either singular or plural form.

So like, digits, then some space, then day/days/month/months. Grammar-inclusive. We love a flexible queen. πŸ‘‘


to be continued, bestie β€” part 2 is coming, don't touch that dial πŸ¦‹

✨ Setting AuthorizeNet ARB parameters from content(%content) ✨

Okay so bestie, when you're doing ARB stuff, there are rules about how the data gets mapped. Here's the whole vibe, no cap β€” these are the actual mappings, so read them like a cheat sheet πŸŽ€

# ARB param => $content{<key>}
merchantAuthentication
  name                     =>  'login',
  transactionKey           =>  'password',
subscription
  paymentSchedule
    interval
      length               => \( the digits in 'interval' ),
      unit                 => \( days or months gleaned from 'interval' ),          startDate              => 'start',
    totalOccurrences       => 'periods',
    trialOccurrences       => 'trialperiods',
  amount                   => 'amount',
  trialAmount              => 'trialamount',
  payment
    creditCard
      cardNumber           => 'card_number',
      expiration           => \( $year.'-'.$month ), # YYYY-MM from 'expiration'
    bankAccount
      accountType          => 'account_type',
      routingNumber        => 'routing_code',
      accountNumber        => 'account_number,
      nameOnAccount        => 'name',
      bankName             => 'bank_name',
      echeckType           => 'check_type',
  order
    invoiceNumber          => 'invoice_number',
    description            => 'description',
  customer
    type                   => 'customer_org',
    id                     => 'customer_id',
    email                  => 'email',
    phoneNumber            => 'phone',
    faxNumber              => 'fax',
    driversLicense
      number               => 'license_num',
      state                => 'license_state',
      dateOfBirth          => 'license_dob',
    taxid                  => 'customer_ssn',
  billTo
    firstName              => 'first_name',
    lastName               => 'last_name',
    company                => 'company',
    address                => 'address',
    city                   => 'city',
    state                  => 'state',
    zip                    => 'zip',
    country                => 'country',
  shipTo
    firstName              => 'ship_first_name',
    lastName               => 'ship_last_name',
    company                => 'ship_company',
    address                => 'ship_address',
    city                   => 'ship_city',
    state                  => 'ship_state',
    zip                    => 'ship_zip',
    country                => 'ship_country',

πŸ“ NOTES πŸ“

Put your transaction key in the password field. That's the whole tip, iconic, moving on πŸ’…

Unlike Business::OnlinePayment or pre-3.0 versions of Business::OnlinePayment::AuthorizeNet, version 3.1 needs first_name and last_name as separate fields. No combining, bestie, it's giving independent woman energy πŸ¦‹

Business::OnlinePayment::AuthorizeNet uses Authorize.Net's "Advanced Integration Method (AIM) (formerly known as ADC direct response)" and "Automatic Recurring Billing (ARB)", sending a username and password (or transaction key as password) with every single transaction. Which means Authorize.Net's referrer "security" is not necessary. So in your Authorize.Net interface at https://secure.authorize.net/ make sure the list of allowable referers is blank. Or alternatively, set the referer field in the transaction content. Either way, pick one ✨

To settle an authorization-only transaction (where you set action to 'Authorization Only'), submit the nine-digit transaction id code in the field "order_number" with the action set to "Post Authorization". You can grab that transaction id from the authorization by calling the order_number method on the object returned from the authorization. You must ALSO submit the amount field with a value less than or equal to the amount specified in the original authorization. Do not skip that part, fr fr 😭

For the subscription actions, an authorization code is never returned by the module. Instead it returns the value of subscriptionId in order_number. That's the value you use for changing or cancelling subscriptions. Lowkey important, write it down πŸ’œ

Authorize.Net has turned address verification on by default for all merchants since 2002. So if you don't have valid address information for your customer (like, say, in an IVR application), you must disable address verification in the Merchant Menu page at https://secure.authorize.net/ so that the transactions aren't denied just because there's no address info. Don't let your transactions get rejected for no reason, that's not the vibe πŸ™ˆ


🌈 COMPATIBILITY 🌈

This module implements Authorize.Net's API using the Advanced Integration Method (AIM) version 3.1, formerly known as ADC Direct Response, and the Automatic Recurring Billing version 1.0 using the XML interface. Want the deets? Go read http://www.authorize.net/support/AIM_guide.pdf and http://www.authorize.net/support/ARB_guide.pdf πŸ“š


πŸ‘‘ AUTHORS πŸ‘‘

  • Original author: Jason Kohles, jason@mediabang.com
  • Ivan Kohler <ivan-authorizenet@freeside.biz> updated it for Authorize.Net protocol 3.0/3.1 and is the current maintainer. Please see the next section for info on contributing (yes, the literal next section, keep scrolling bestie).
  • Jason Spence <jspence@lightconsulting.com> contributed support for separate Authorization Only and Post Authorization steps and wrote some docs. OST <services@ostel.com> paid for it. Sponsorship slay πŸ’°
  • Jeff Finucane <authorizenetarb@weasellips.com> added the ARB support. ARB support sponsored by Plus Three, LP. <http://www.plusthree.com>.
  • T.J. Mather <tjmather@maxmind.com> sent a number of CVV2 patches.
  • Mike Barry <mbarry@cos.com> sent in a patch for the referer field and a fix for ship_company.
  • Yuri V. Mkrtumyan <yuramk@novosoft.ru> sent in a patch to add the void action.
  • Paul Zimmer <AuthorizeNetpm@pzimmer.box.bepress.com> sent in a patch for card-less post authorizations.
  • Daemmon Hughes <daemmon@daemmonhughes.com> sent in a patch for "transaction key" authentication as well support for the recurring_billing flag and the md5 method that returns the MD5 hash which is returned by the gateway.
  • Steve Simitzis contributed a patch for better compatibility with eProcessingNetwork's AuthorizeNet compatibility mode.
  • Michael G. Schwern contributed cleanups, test fixes, and more.
  • Erik Hollensbe implemented card-present data (track1/track2), the duplicate_window parameter, and test fixes.
  • Paul Timmins added the check_number field.
  • Nate Nuss implemented the ("Additional Shipping Information (Level 2 Data)" fields: tax, freight, duty, tax_exempt, po_number.
  • Michael Peters fixed a bug in email address handling.
  • Thomas Sibley <trs@bestpractical.com> wrote B:OP:AuthorizeNet::AIM::ErrorCodes which was borged and used to provide more descriptive error messages.
  • Craig Pearlman <cpearlma@yahoo.com> sent in a patch to more accurately declare required fields for E-check transcations.

Look at this contributor list, it's literally a group project that ate πŸ’–


🫢 CONTRIBUTIONS AND REPOSITORY 🫢

Please send patches as unified diffs (diff -u) to (in order of preference):

  1. CPAN RT http://rt.cpan.org/Public/Bug/Report.html?Queue=Business-OnlinePayment-AuthorizeNet
  2. The bop-devel mailing list http://420.am/cgi-bin/mailman/listinfo/bop-devel
  3. Ivan Ivan Kohler <ivan-authorizenet@freeside.biz>

The code is available from our public git repository:

git clone git://fit.freeside.biz/Business-OnlinePayment-AuthorizeNet.git

Or on the web:

http://freeside.biz/gitweb/?p=Business-OnlinePayment-AuthorizeNet.git

⭐ A WORD FROM OUR SPONSOR ⭐

This module and the Business::OnlinePayment framework are maintained by Freeside Internet Services. If you need a complete, open-source, web-based application to manage your customers, billing and trouble ticketing, please visit http://freeside.biz/ β€” go give them a little click, they're funding the whole thing πŸŽ€


Copyright 2010-2015 Freeside Internet Services, Inc. Copyright 2008 Thomas Sibley. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


πŸ”₯ SEE ALSO πŸ”₯


And that's the whole page, bestie, you made it to the end and you ate πŸ’…βœ¨ This one shipped with perl v5.34.0 and it's dated 2022-06-30 β€” so go forth, take payments, and stay iconic πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from