failure_status support
authorMark Wells <mark@freeside.biz>
Thu, 15 Aug 2013 19:51:44 +0000 (12:51 -0700)
committerMark Wells <mark@freeside.biz>
Fri, 16 Aug 2013 01:28:12 +0000 (18:28 -0700)
lib/Business/OnlinePayment/PaymenTech.pm

index 3d060bb..5ae91b7 100644 (file)
@@ -98,6 +98,32 @@ my %currency_code = (
 );
 
 my %paymentech_countries = map { $_ => 1 } qw( US CA GB UK );
+my %failure_status = (
+  # values of the RespCode element
+  # in theory RespMsg should be set to a descriptive message, but it looks
+  # like that's not reliable
+  # XXX we should have a way to indicate other actions required by the 
+  # processor, such as "honor with identification", "call for instructions",
+  # etc.
+  '00'  => undef,         # Approved
+  '04'  => 'pickup',      # Pickup
+  '33'  => 'expired',     # Card is Expired
+  '41'  => 'stolen',      # Lost/Stolen
+  '42'  => 'inactive',    # Account Not Active
+  '43'  => 'stolen',      # Lost/Stolen Card
+  '44'  => 'inactive',    # Account Not Active
+  #'45' duplicate transaction, should also have its own status
+  'B7'  => 'blacklisted', # Fraud
+  'B9'  => 'blacklisted', # On Negative File
+  'BB'  => 'stolen',      # Possible Compromise
+  'BG'  => 'blacklisted', # Blocked Account
+  'BQ'  => 'blacklisted', # Issuer has Flagged Account as Suspected Fraud
+  'C4'  => 'nsf',         # Over Credit Limit
+  'D5'  => 'blacklisted', # On Negative File
+  'D7'  => 'nsf',         # Insufficient Funds
+  'F3'  => 'inactive',    # Account Closed
+  'K6'  => 'nsf',         # NSF
+);
 
 sub set_defaults {
     my $self = shift;
@@ -304,6 +330,7 @@ sub submit {
             )
     {
 
+      $self->failure_status( $failure_status{ $r->{RespCode} } || 'decline' );
       $self->is_success(0);
       $self->error_message( "Transaction error: '".
                             ($r->{'ProcStatusMsg'} || $r->{'StatusMsg'}) . "'"