summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/CreditCard.pm9
-rw-r--r--LedgerSMB/CreditCard/Config.pm7
-rw-r--r--LedgerSMB/CreditCard/TrustCommerce.pm66
-rw-r--r--LedgerSMB/CreditCard/TrustCommerce/Config.pm7
4 files changed, 89 insertions, 0 deletions
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'
+);