[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [187] trunk



Revision: 187
          http://svn.sourceforge.net/ledger-smb/?rev=187&view=rev
Author:   einhverfr
Date:     2006-10-03 15:47:50 -0700 (Tue, 03 Oct 2006)

Log Message:
-----------
Adding experimental support for TrustCommerce credit card processing

Modified Paths:
--------------
    trunk/Changelog

Added Paths:
-----------
    trunk/LedgerSMB/CreditCard/
    trunk/LedgerSMB/CreditCard/Config.pm
    trunk/LedgerSMB/CreditCard/TrustCommerce/
    trunk/LedgerSMB/CreditCard/TrustCommerce/Config.pm
    trunk/LedgerSMB/CreditCard/TrustCommerce.pm
    trunk/LedgerSMB/CreditCard.pm

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2006-10-03 04:33:14 UTC (rev 186)
+++ trunk/Changelog	2006-10-03 22:47:50 UTC (rev 187)
@@ -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 @@
 * 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
 

Added: trunk/LedgerSMB/CreditCard/Config.pm
===================================================================
--- trunk/LedgerSMB/CreditCard/Config.pm	                        (rev 0)
+++ trunk/LedgerSMB/CreditCard/Config.pm	2006-10-03 22:47:50 UTC (rev 187)
@@ -0,0 +1,7 @@
+
+package Config;
+
+$gateway_module = "TrustCommerce";
+$debug = 0; # Debugging off by default
+
+1;

Added: trunk/LedgerSMB/CreditCard/TrustCommerce/Config.pm
===================================================================
--- trunk/LedgerSMB/CreditCard/TrustCommerce/Config.pm	                        (rev 0)
+++ trunk/LedgerSMB/CreditCard/TrustCommerce/Config.pm	2006-10-03 22:47:50 UTC (rev 187)
@@ -0,0 +1,7 @@
+# TrustCommerce configuration Information goes Here
+
+package CreditCard::TrustCommerce::Config;
+
+%baseparams = ( customer_id => 'MyCustomerID',
+	password => 'MyPassword'
+);

Added: trunk/LedgerSMB/CreditCard/TrustCommerce.pm
===================================================================
--- trunk/LedgerSMB/CreditCard/TrustCommerce.pm	                        (rev 0)
+++ trunk/LedgerSMB/CreditCard/TrustCommerce.pm	2006-10-03 22:47:50 UTC (rev 187)
@@ -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;

Added: trunk/LedgerSMB/CreditCard.pm
===================================================================
--- trunk/LedgerSMB/CreditCard.pm	                        (rev 0)
+++ trunk/LedgerSMB/CreditCard.pm	2006-10-03 22:47:50 UTC (rev 187)
@@ -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); 
+}
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.