diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-03 22:47:50 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-03 22:47:50 +0000 |
commit | 85317b0d6cd1a1e30ae9da69039dec32c517e86a (patch) | |
tree | afe38de04b37aabd86688213aeca0444000650f1 | |
parent | 3a96f0cd692dc0aa1f53ae8f96b2f0e552c29449 (diff) |
Adding experimental support for TrustCommerce credit card processing
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@187 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r-- | Changelog | 11 | ||||
-rw-r--r-- | LedgerSMB/CreditCard.pm | 9 | ||||
-rw-r--r-- | LedgerSMB/CreditCard/Config.pm | 7 | ||||
-rw-r--r-- | LedgerSMB/CreditCard/TrustCommerce.pm | 66 | ||||
-rw-r--r-- | LedgerSMB/CreditCard/TrustCommerce/Config.pm | 7 |
5 files changed, 95 insertions, 5 deletions
@@ -1,5 +1,6 @@ Changelog for LedgerSMB 1.2.0 +* Added experimental TrustCommerce credit card processing (Chris T) * Merged most of the rest of the SL-POS interface (Chris T) * Broke out price matrix calls into PriceMatrix.pm (Chris T) * Added Gentoo ebuilds documentation and metadata(Jayson R). @@ -8,14 +9,14 @@ Changelog for LedgerSMB 1.2.0 * Added simple text import function for invoices received (PDT's) (Chris T) * Added whitelist of allowed directories to file editor (Seneca) * Added script to configure Slony replication (Chris Browne) -* Audited OE.pm and AM.pm for SQL injection problems. (Chris Travers) +* Audited OE.pm and AM.pm for SQL injection problems. (Chris T) * Forced edited files to have whitelisted extensions and no .. strings (Chris T) -* Added $form->callproc($procname, @args) returns @hashrefs (Chris Travers) +* Added $form->callproc($procname, @args) returns @hashrefs (Chris T) * Corrected rounding errors (Seneca) -* Audited Form.pm for SQL-injection problems and move to new API (Chris Travers) +* Audited Form.pm for SQL-injection problems and move to new API (Chris T) * Code cleanup and template correction (Chris Murtagh) -* New template system (Chris Travers) -* OE.pm and IS.pm are aware of custom fields (Chris Travers) +* New template system (Chris T) +* OE.pm and IS.pm are aware of custom fields (Chris T) Changelog for LedgerSMB 1.1.1 diff --git a/LedgerSMB/CreditCard.pm b/LedgerSMB/CreditCard.pm new file mode 100644 index 00000000..dfcce7c7 --- /dev/null +++ b/LedgerSMB/CreditCard.pm @@ -0,0 +1,9 @@ + +package CreditCard; +use LedgerSMB::CreditCard::Config; +BEGIN { + $gateway_module = ${Config::gateway_module}; + require "LedgerSMB/CreditCard/$gateway_module.pm"; + import $gateway_module qw(sale credit); +} + diff --git a/LedgerSMB/CreditCard/Config.pm b/LedgerSMB/CreditCard/Config.pm new file mode 100644 index 00000000..4a7ecba5 --- /dev/null +++ b/LedgerSMB/CreditCard/Config.pm @@ -0,0 +1,7 @@ + +package Config; + +$gateway_module = "TrustCommerce"; +$debug = 0; # Debugging off by default + +1; diff --git a/LedgerSMB/CreditCard/TrustCommerce.pm b/LedgerSMB/CreditCard/TrustCommerce.pm new file mode 100644 index 00000000..7d2bf2b2 --- /dev/null +++ b/LedgerSMB/CreditCard/TrustCommerce.pm @@ -0,0 +1,66 @@ + +package TrustCommerce; +use LedgerSMB::CreditCard::TrustCommerce::Config (); +use LedgerSMB::CreditCard::Config (); +use Net::TCLink; + +%baseparams = ${Config::baseparams}; +$debug = ${Config::debug}; + +sub sale { + $form = shift @_; + my %params = %baseparams; + $params{action} = 'sale'; + $params{amount} = $form->{amount} * 100; + $params{track1} = $form->{track1}; + $params{track2} = $form->{track2}; + &process; +} + +sub process { + my %result = Net::TCLink::send(\%params); + $form->{status} = $result{status}; + if ($result{status} eq 'decline'){ + $form->{declinetype} = $result{declinetype}; + $form->{declinemsg} = $declinemsg{$result{declinetype}}; + } + $form->{ccauth} = $result{transID}; + # log transID and status + print STDERR "Info: TCLink CC AUTH transID $result{transid} returned ". + "status $result{status}:$result{declinetype}:$result{baddata}:". + "$result{errortype}\n"; + if ($debug){ + print STDERR "Full Result:\n"; + for (keys %result){ + print "$_= ".$result{$_}."\n"; + } + } + %result; +} + +sub credit { + $form = shift @_; + my %params = %baseparams; + $params{transid} = $form->{transid}; + $params{amount} = $form->{amount}; + &process; +} + + +%declinemsg = ( + decline => 'Transaction declined by bank', + avs => 'AVS failed: Address and/or Zip mismatch', + cvv => 'CVV2 Failure: Check the CVV2 number and try again', + call => 'Call customer service number on card to get authcode', + expiredcard => 'This card has expired', + carderror => 'This card number is invalid.', + authexpired => 'The authorization expired. Can not postauth.', + fraud => 'CrediGuard Fraud Score exceeded desired threshold', + blacklist => 'CrediGuard Declined: blacklisted this transaction.', + velocity => 'Crediguard declined: Too many transactions', + dailylimit => 'Too many transactions in a day.', + weeklylimit => 'Too many transactions in a week', + monthlylimit => 'Too many transactions in a month' +); + +1; diff --git a/LedgerSMB/CreditCard/TrustCommerce/Config.pm b/LedgerSMB/CreditCard/TrustCommerce/Config.pm new file mode 100644 index 00000000..147548b0 --- /dev/null +++ b/LedgerSMB/CreditCard/TrustCommerce/Config.pm @@ -0,0 +1,7 @@ +# TrustCommerce configuration Information goes Here + +package CreditCard::TrustCommerce::Config; + +%baseparams = ( customer_id => 'MyCustomerID', + password => 'MyPassword' +); |