A Perl script for processing credit card transactions and creating recurring billing subscriptions through Authorize.net's payment gateway.
- Credit card processing through Authorize.net
- Support for recurring billing/subscriptions
- XML-based API integration
- Error handling and response processing
- Secure HTTPS communication
- Perl 5.x or higher
- Required Perl modules:
- LWP::UserAgent
- HTTP::Request::Common
- POSIX
- Valid Authorize.net credentials:
- API Login ID
- Transaction Key
- Replace the placeholder credentials in the script:
$authorize_api_login = "*********************************";
$authorize_api_key = "*********************************";
- Set the appropriate gateway URL:
$post_url = "https://secure.authorize.net/gateway/transact.dll";
ProcessCreditCardAtAuthorizeNet(
$cardnumber, # Credit card number
$expiremonth, # Expiration month
$expireyear, # Expiration year
$amount, # Transaction amount
$ordernum, # Order number
$description, # Transaction description
$lastname, # Customer last name
$firstname, # Customer first name
$email, # Customer email
$address, # Billing address
$city, # Billing city
$state, # Billing state
$zip, # Billing zip
$country # Billing country
);
The script includes three main response handling functions:
GetResponseData
: Processes the raw API responseHandleResponseData
: Processes successful transactionsHandleFailure
: Manages failed transactions
- Never store raw credit card data in your database
- Ensure PCI compliance when handling credit card data
- Use HTTPS for all transactions
- Sanitize all input data before processing
- Keep API credentials secure and never commit them to version control
- Implement proper error logging
- Use environment variables for sensitive credentials
The script includes basic error handling for:
- Failed API connections
- Invalid responses
- Transaction processing errors
Error messages are stored in $AN_response_reason_text
.
Before using in production:
- Test with Authorize.net's sandbox environment
- Verify error handling
- Test recurring billing setup
- Validate response processing
For more information about the Authorize.net API:
This code is released under the MIT License. See LICENSE file for details.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
For issues with the script, please open a GitHub issue. For Authorize.net API issues, contact their support directly.
This code is provided as-is. Ensure proper testing and security measures before using in a production environment. The authors are not responsible for any misuse or security breaches.