| Use Case | Command | Description |
|---|---|---|
| Create processor object | my $tx = new Business::OnlinePayment($processor, %options); | Instantiate gateway |
| Set transaction details | $tx->content(type => 'CC', amount => '49.95', โฆ); | Define payment info |
| Enable test mode | $tx->test_transaction(1); | No real charges |
| Require AVS | $tx->require_avs(1); | Address verification |
| Submit payment | $tx->submit(); | Process transaction |
| Check success | $tx->is_success(); | True if approved |
| Get error | $tx->error_message(); | Human-friendly decline reason |
| Authorization code | $tx->authorization(); | Gateway approval code |
| Order number | $tx->order_number(); | Gateway-generated order ID |
| Partial auth amount | $tx->partial_auth_amount(); | Amount if less than requested |
| Fraud score | $tx->fraud_score(); | From fraud detection plugin |
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";
}
}
Business::OnlinePayment is a generic module for processing payments through online credit card processors, electronic cash systems, etc.
Create a new Business::OnlinePayment object. $processor is required and defines the online processor to use. Optional processor options are Server, Port, and Path, which specify how to reach the processor (https://server:port/path). Individual processor modules supply reasonable defaults; override only if absolutely necessary (especially path), as the processor module was written with a specific target script in mind.
The information necessary for the transaction. This varies by processor; a system of defined frontend fields maps to the correct backend fields.
CC (credit card), ECHECK (electronic check), LEC (phone bill billing). Deprecated: Visa, MasterCard, American Express, Discover, Check. Not all processors support all types.partial_auth_amount()). If not set, a partial auth is immediately reversed/voided.amount, not added to it).amount, not added to it).amount, not added to it).PPD (signed form), CCD (business), WEB (online box), TEL (recorded call).Used in Post Authorization, Reverse Authorization, Void, Credit transactions:
1 month or 30 days).Most processors provide a test mode where submitted transactions are not actually charged. Call with a true argument to enable (if supported); otherwise a fatal error is thrown to prevent accidental real charges.
Provide a true argument to turn on Address Verification (if the processor supports it).
Submit the transaction to the processor for completion. If a gateway communication error or other "meta" issue occurs, submit throws a fatal exception (catch with eval {}).
Returns true if the transaction was approved by the gateway, false if submitted but not approved, or undef if not yet submitted.
If the transaction was a partial authorization (successful but less than the requested amount), returns the actual amount processed. Empty or 0 when is_success is true indicates a normal full authorization.
If the transaction was submitted but not accepted, returns the processorโprovided error message (if any).
If the transaction failed, may return a normalized failure status (not gatewayโspecific). Currently defined: "expired", "nsf" (nonโsufficient funds), "stolen", "pickup", "blacklisted", "declined" (card/transaction declines only). Not all processors support this, and it may not be set for all declines.
If submitted and accepted, returns the authorization code from the processor. Store this for later inquiries or refunds.
The unique order number for the transaction generated by the gateway. Store for later inquiries or refunds.
If supported by your gateway, a card_token that can be used in a subsequent transaction in place of a full card number.
Transaction date as returned by the gateway. Required by some gateways for followโup transactions.
Retrieve or change the fraud score from any Business::FraudDetect plugin.
Retrieve or change the transaction id from any Business::FraudDetect plugin.
Set by some processors (especially HTTPS) when a transaction fails at the communication level. response_code is the HTTP response code and message (e.g. "500 Internal Server Error"), response_headers is a hash reference of response headers, response_page is the raw content.
Returns the precise result code from the processor (often oneโletter codes). Use only if you understand the protocol.
Address verification and CVV2 response values, as returned by the gateway.
Retrieve the transaction type (the type argument to contents()). Generally used internally.
Retrieve or change the processor submission server address, port, or path. CHANGE AT YOUR OWN RISK.
Build setter/getter subroutines for new return values.
Get the named fields if they are defined.
Remap field content (and stuff it back into content).
Croaks if any of the required fields are not present.
Dump the current contents (debugging aid).
Returns 1 if the value starts with y, Y, t, or T; 0 if it starts with n, N, f, or F; otherwise the value itself. Use for handling boolean content like tax_exempt.
(v2 series) Jason Kohles, email AT jasonkohles.com
(v3 rewrite) Ivan Kohler <ivan-business-onlinepayment AT 420.am>
Phil Lobbes <phil at perkpartners dot com>
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: http://perl.business/onlinepayment
Development: http://perl.business/onlinepayment/ng.html
Direct development questions, patches, etc. to: http://mail.freeside.biz/cgi-bin/mailman/listinfo/bop-devel/
Code available from public git:
git clone git://git.freeside.biz/Business-OnlinePayment.git
Or on the web:
Many processor plugins are also available in the same repository:
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.
http://perl.business/onlinepayment
For verification of credit card checksums, see Business::CreditCard.
Generated by phpman v4.9.22-1-g1b0fcb4 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-05 16:29 @216.73.216.52
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format