summaryrefslogtreecommitdiff
path: root/LedgerSMB/CreditCard/TrustCommerce.pm
blob: 634af8f2de37a1ef987d8429c1303aad580d1a05 (plain)
  1. #=====================================================================
  2. # LedgerSMB
  3. # Small Medium Business Accounting software
  4. # http://www.ledgersmb.org/
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Simple TrustCommerce API using Net::TCLink
  16. package TrustCommerce;
  17. use LedgerSMB::CreditCard::Config;
  18. use LedgerSMB::CreditCard::TrustCommerce::Config;
  19. use Net::TCLink;
  20. $debug = $1;
  21. sub sale {
  22. $form = shift @_;
  23. $params{action} = 'sale';
  24. $params{amount} = $form->{amount} * 100;
  25. $params{track1} = $form->{track1};
  26. $params{track2} = $form->{track2};
  27. &process;
  28. }
  29. sub process {
  30. for ( keys %params ) {
  31. print "$_= " . $params{$_} . "\n";
  32. }
  33. my %result = Net::TCLink::send( \%params );
  34. $form->{status} = $result{status};
  35. if ( $result{status} eq 'decline' ) {
  36. $form->{declinetype} = $result{declinetype};
  37. $form->{declinemsg} = $declinemsg{ $result{declinetype} };
  38. }
  39. $form->{ccauth} = $result{transID};
  40. # log transID and status
  41. print STDERR "Info: TCLink CC AUTH transID $result{transid} returned "
  42. . "status $result{status}:$result{declinetype}:$result{baddata}:"
  43. . "$result{errortype}\n";
  44. if ($debug) {
  45. print STDERR "Full Result:\n";
  46. for ( keys %result ) {
  47. print STDERR "$_= " . $result{$_} . "\n";
  48. }
  49. }
  50. %result;
  51. }
  52. sub credit {
  53. $form = shift @_;
  54. my %params = %baseparams;
  55. $params{transid} = $form->{transid};
  56. $params{amount} = $form->{amount};
  57. &process;
  58. }
  59. %declinemsg = (
  60. decline => 'Transaction declined by bank',
  61. avs => 'AVS failed: Address and/or Zip mismatch',
  62. cvv => 'CVV2 Failure: Check the CVV2 number and try again',
  63. call => 'Call customer service number on card to get authcode',
  64. expiredcard => 'This card has expired',
  65. carderror => 'This card number is invalid.',
  66. authexpired => 'The authorization expired. Can not postauth.',
  67. fraud => 'CrediGuard Fraud Score exceeded desired threshold',
  68. blacklist => 'CrediGuard Declined: blacklisted this transaction.',
  69. velocity => 'Crediguard declined: Too many transactions',
  70. dailylimit => 'Too many transactions in a day.',
  71. weeklylimit => 'Too many transactions in a week',
  72. monthlylimit => 'Too many transactions in a month'
  73. );
  74. 1;