OnlinePayment(3pm)
π Business::OnlinePayment π
okay so bestie, you've landed on OnlinePayment(3pm) and honestly? you're in the right place. this is the manual page for the Perl module Business::OnlinePayment, and by the end of it you're gonna be processing payments like it's nothing. let's GO π«Ά
β¨ NAME β¨
Business::OnlinePayment β Perl extension for online payment processing π³
πΈ SYNOPSIS πΈ
here's the vibe, copy-paste ready:
use Business::OnlinePayment;
my $transaction = new Business::OnlinePayment($processor, %processor_info);
$transaction->content(
type => 'Visa',
amount => '49.95',
card_number => '1234123412341238',
expiration => '06/15',
name => 'John Q Doe',
);
eval { $transaction->submit(); };
if ( $@ ) {
print "$processor error: $@\n";
} else {
if ( $transaction->is_success() ) {
print "Card processed successfully: ". $transaction->authorization()."\n";
} else {
print "Card was rejected: ". $transaction->error_message(). "\n";
}
}
look at that. clean. iconic. slay π
π¦ DESCRIPTION π¦
Business::OnlinePayment is a generic module for processing payments through online credit card processors, electronic cash systems, etc.
that's it, that's the whole concept. one module, many processors, zero chaos (well⦠minimal chaos). periodt.
π CONSTRUCTOR π
π new($processor, %processor_options)
make yourself a brand new Business::OnlinePayment object β¨
$processoris required β this is the whole point, it defines the online processor you're gonna use.- if necessary, you can also pass processor options. the currently supported options are:
'Server''Port''Path'
those three tell the module how to find the online processor: https://server:port/path
but bestie, listen β the individual processor modules should supply reasonable defaults for this info. only override the defaults if it's absolutely necessary (especially Path π), because the processor module was probably written with one specific target script in mind. don't go rogue.
π TRANSACTION SETUP METHODS π
π content(%content)
this is where you hand over the info the transaction needs. it varies a lil bit depending on the processor, so the design here is: you define specific fields in the frontend, and they get mapped to the correct fields in the backend. cute, right?
the currently defined fields are:
π₯ PROCESSOR FIELDS
loginβ your login name, used for authentication to the online processor.passwordβ your password, used for authentication to the online processor.
π REQUIRED TRANSACTION FIELDS
typeβ transaction type. supported types are:CC(credit card),ECHECK(electronic check) andLEC(phone bill billing). deprecated types are:Visa,MasterCard,American Express,Discover,Check. heads up: not all processors support all transaction types.actionβ what action is being taken by this transaction. currently available are:- Normal Authorization
- Authorization Only
- Post Authorization
- Reverse Authorization
- Void
- Credit
- Tokenize
- Recurring Authorization
- Modify Recurring Authorization
- Cancel Recurring Authorization
amountβ the amount of the transaction. no dollar signs, no currency identifiers, just a whole or floating point number (i.e.26,26.1or26.13).
πΈ OPTIONAL TRANSACTION FIELDS
partial_authβ if you're prepared to handle partial authorizations (seepartial_auth_amount()in TRANSACTION RESULT FIELDS), pass a true value in this field to enable them.
β οΈ if this flag is not set, a partial authorization will be immediately reversed or voided. no take-backs.
descriptionβ a description of the transaction (used by some processors to send info to the client, normally not a required field).invoice_numberβ an invoice number, for your use and not normally required. many processors require this field to be a numeric only field, so keep it digits.po_numberβ purchase order number (normally not required).taxβ tax amount (portion ofamountfield, not added to it).freightβ freight amount (portion ofamountfield, not added to it).dutyβ duty amount (portion ofamountfield, not added to it).tax_exemptβ tax exempt flag (i.e.TRUE,FALSE,T,F,YES,NO,Y,N,1,0).currencyβ currency, specified as an ISO 4217 three-letter code, such asUSD,CAD,EUR,AUD,DKK,GBP,JPY,NZD, etc.
π§ CUSTOMER INFO FIELDS
customer_idβ a customer identifier, again not normally required.nameβ the customer's name. your processor may not require this.first_name,last_nameβ the customer's first and last name as separate fields.companyβ the customer's company name, not normally required.addressβ the customer's address (your processor may not require this unless you're requiring AVS Verification).cityβ the customer's city (your processor may not require this unless you're requiring AVS Verification).stateβ the customer's state (your processor may not require this unless you're requiring AVS Verification).zipβ the customer's zip code (your processor may not require this unless you're requiring AVS Verification).countryβ customer's country.ship_first_name,ship_last_name,ship_company,ship_address,ship_city,ship_state,ship_zip,ship_countryβ these shipping address fields may be accepted by your processor. refer to the description for the corresponding non-shipfield for general info on each field. (soship_city= same energy ascity, you get it π)phoneβ customer's phone number.faxβ customer's fax number.emailβ customer's email address.customer_ipβ IP Address from which the transaction originated.
π³ CREDIT CARD FIELDS
card_numberβ credit card number.expirationβ credit card expiration,MM/YY.cvv2β CVV2 number (also called CVC2 or CID) is a three- or four-digit security code used to reduce credit card fraud.card_tokenβ if supported by your gateway, you can pass acard_tokeninstead of acard_numberandexpiration.track1β Track 1 on the magnetic stripe (Card present only)track2β Track 2 on the magnetic stripe (Card present only)recurring_billingβ recurring billing flag
π ELECTRONIC CHECK FIELDS
account_numberβ Bank account numberrouting_codeβ Bank's routing codeaccount_typeβ Account type. can be (case-insensitive):Personal Checking,Personal Savings,Business CheckingorBusiness Savings.nacha_sec_codeβ NACHA SEC Code for US ACH transactions.'PPD'indicates customer signed a form giving authorization for the charge,'CCD'same for a business checking/savings account,'WEB'for online transactions where a box was checked authorizing the charge, and'TEL'for authorization via recorded phone call (NACHA script required).account_nameβ Account holder's name.bank_nameβ Bank name.bank_cityβ Bank city.bank_stateβ Bank state.check_typeβ Check type.customer_orgβ Customer organization type.customer_ssnβ Customer's social security number.license_numβ Customer's driver's license number.license_dobβ Customer's date of birth.
π¦ FOLLOW-UP TRANSACTION FIELDS
these fields are used in follow-up transactions related to an original transaction (Post Authorization, Reverse Authorization, Void, Credit).
authorizationorder_numbertxn_date
π RECURRING BILLING FIELDS
intervalβ Interval expresses the amount of time between billings: digits, whitespace and units (currently"days"or"months"in either singular or plural form).startβ the date of the first transaction (used for processors which allow delayed start) expressed asYYYY-MM-DD.periodsβ the number of cycles of interval length for which billing should occur (inclusive of'trial periods'if the processor supports recurring billing at more than one rate).
β test_transaction()
most processors provide a test mode, where submitted transactions will not actually be charged or added to your batch. calling this function with a true argument will turn that mode on β if the processor supports it. if the processor does not support a test mode, it'll generate a fatal error.
honestly? that's probably better than accidentally making real charges π test mode or bust.
π«Ά require_avs()
providing a true argument to this module will turn on address verification (if the processor supports it). π β¨
π TRANSACTION SUBMISSION METHOD π
π₯ submit()
submit the transaction to the processor for completion. this is the moment. main character energy.
if there's a gateway communication error or other "meta" , the submit method will throw a fatal exception. you can catch this with eval {} if you'd like to treat gateway co
π TRANSACTION RESULT METHODS π
Okay bestie, this is the part where you find out what actually happened with your transaction. The receipts section. Let's go π§Ύβ¨
is_success()β Returns true if the gateway approved the transaction, false if it got submitted but wasn't approved, orundefif it hasn't been submitted yet at all. So likeβ¦undefis the "we haven't even tried yet" vibe, not a fail. π«Άpartial_auth_amount()β If this transaction was a partial authorization (meaning: successful, but less than the amount you asked for actually got processed), then the amount that did get processed comes back in this field.
And listen β whenis_successis true but this field is empty or0, that means it's a totally normal full authorization for the whole requested amount. No crumbs left behind, we ate the entire plate. π
error_message()β If the transaction got submitted but wasn't accepted, this function hands you the error message (if there even was one) that the processor sent back. The "what went wrong" text, straight from the source. πfailure_status()β If the transaction failed, this can optionally return a specific failure status β and it's normalized, not gateway-specific, so it's the same language no matter who you're talking to. Currently defined statuses are:"expired","nsf"(non-sufficient funds),"stolen","pickup","blacklisted"and"declined"(card/transaction declines only, not other errors).
Heads up fr fr: not all processor modules support this, and even when they do, it might not be set for all declines. So don't hard-depend on it, bestie. π
authorization()β If the transaction was submitted and accepted, this gives you the authorization code the processor returned. π Store this if you wanna run inquiries or refunds on the transaction later. Future you will thank present you.order_number()β The unique order number for the transaction, generated by the gateway. Also π store this if you want to run inquiries or refunds on it later.card_token()β If your gateway supports it, acard_tokencan be used in a subsequent transaction to refer to a card number. Iconic, honestly. πtxn_date()β Transaction date, as returned by the gateway. Some gateways require this for follow-up transactions. π Store this if you'd like to run inquiries or refunds on the transaction later.fraud_score()β Retrieve or change the fraud score from anyBusiness::FraudDetectplugin. π΅οΈββοΈfraud_transaction_id()β Retrieve or change the transaction id from anyBusiness::FraudDetectplugin.response_code(),response_headers(),response_page()β These three fields get set by some processors (especially the HTTPS ones π) when the transaction fails at the communication level rather than as a transaction. Like, the wires themselves got tangled.response_codeis the HTTP response code and message, i.e.'500 Internal Server Error'.response_headersis a hash reference of the response headers.response_pageis the raw content.
result_code()β Returns the precise result code that the processor returned. These are normally one-letter codes that don't mean much unless you understand the protocol they speak. You probably don't need thisβ¦ but it's there just in case. πavs_code()cvv2_response()
π MISCELLANEOUS INTERNAL METHODS π
These are the backstage-pass functions. Mostly plumbing, but they're documented anyway because why gatekeep. β¨
transaction_type()β Retrieve the transaction type (that's the'type'argument tocontents()). Generally only used internally, but provided in case it's useful.server()β Retrieve or change the processor submission server address.
β οΈ CHANGE AT YOUR OWN RISK.
port()β Retrieve or change the processor submission port.
β οΈ CHANGE AT YOUR OWN RISK.
path()β Retrieve or change the processor submission path.
β οΈ CHANGE AT YOUR OWN RISK.
π οΈ HELPER METHODS FOR GATEWAY MODULE AUTHORS π οΈ
So you're writing a gateway module?? Main character energy, honestly. Here's your toolbox. π§°π
build_subs( @sub_names )β Build setter/getter subroutines for new return values.get_fields( @fields )β Get the named fields if they are defined.remap_fields( %map )β Remap field content (and stuff it back into content).required_fields( @fields )β Croaks if any of the required fields are not present. πΈ (yes, literally croaks)dump_contentssilly_bool( $value )β Returns1if the value starts withy,Y,torT. Returns0if the value starts withn,N,forF. Otherwise returns the value itself.
Use this for handling boolean content like tax_exempt.
π AUTHORS π
(v2 series)
Jason Kohles, email@jasonkohles.com
(v3 rewrite)
Ivan Kohler <ivan-business-onlinepayment@420.am>
Phil Lobbes <phil at perkpartners dot com>
π COPYRIGHT π
Copyright (c) 1999-2004 Jason Kohles Copyright (c) 2004 Ivan Kohler Copyright (c) 2007-2018 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.
π HOMEPAGE π
Homepage: http://perl.business/onlinepayment
Development: http://perl.business/onlinepayment/ng.html
π MAILING LIST π
Please direct current development questions, patches, etc. to the mailing list:
http://mail.freeside.biz/cgi-bin/mailman/listinfo/bop-devel/
π³ REPOSITORY π³
The code is available from our public git repository:
git clone git://git.freeside.biz/Business-OnlinePayment.git
Or on the web:
http://git.freeside.biz/gitweb/?p=Business-OnlinePayment.git
Or:
http://git.freeside.biz/cgit/Business-OnlinePayment.git
Many (but by no means all!) processor plugins are also available in the same repository, see:
http://git.freeside.biz/gitweb/
Or:
π DISCLAIMER π
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
No cap, no warranty, no take-backs. Read it and weep (respectfully). π
π SEE ALSO π
http://perl.business/onlinepayment
For verification of credit card checksums, see Business::CreditCard.
And that's the whole page, bestie!! π This was Perl v5.36.0, dated 2023-01-22, and it's the OnlinePayment(3pm) manual page β you read the entire thing, which is honestly iconic behavior. Go process some transactions, you absolute legend. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libbusiness-onlinepayment-perl 3.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libbusiness-onlinepayment-perl 3.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbusiness-onlinepayment-perl 3.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbusiness-onlinepayment-perl 3.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libbusiness-onlinepayment-perl 3.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms