Business-OnlinePayment-IATSPayments

 view release on metacpan or  search on metacpan

lib/Business/OnlinePayment/IATSPayments.pm  view on Meta::CPAN

    'module_version'    => $VERSION,
    'supported_types'   => [ 'CC', 'ECHECK' ],
    #'token_support'     => 1,
    'test_transaction'  => 1,

    'supported_actions' => [ 'Normal Authorization',
                             'Credit',
                           ],
  };
}

sub set_defaults {
    my $self = shift;
    #my %opts = @_;

    #$self->build_subs(qw( order_number avs_code cvv2_response
    #                      response_page response_code response_headers
    #                 ));

    $self->build_subs(qw( avs_code ));

}

sub map_fields {
    my($self) = @_;

    my %content = $self->content();

    # TYPE MAP
    my %types = ( 'visa'               => 'CC',
                  'mastercard'         => 'CC',
                  'american express'   => 'CC',
                  'discover'           => 'CC',
                  'check'              => 'ECHECK',
                );
    $content{'type'} = $types{lc($content{'type'})} || $content{'type'};
    $self->transaction_type($content{'type'});
    
    # ACTION MAP 
    my $action = lc($content{'action'});
    my %actions =
      ( 'normal authorization'  => 'ProcessCreditCardV1',
        'credit'                => 'ProcessCreditCardRefundWithTransactionIdV1',
      );
    my %check_actions =
      ( 'normal authorization'  => 'ProcessACHEFTV1',
        'credit'                => 'ProcessACHEFTRefundWithTransactionIdV1',
      );

    if ($self->transaction_type eq 'CC') {
      $content{'action'} = $actions{$action} || $action;
    } elsif ($self->transaction_type eq 'ECHECK') {

      $content{'action'} = $check_actions{$action} || $action;

      # ACCOUNT TYPE MAP
      my %account_types = ('personal checking'   => 'CHECKING',
                           'personal savings'    => 'SAVINGS',
                           'business checking'   => 'CHECKING',
                           'business savings'    => 'SAVINGS',
                           #not technically B:OP valid i guess?
                           'checking'            => 'CHECKING',
                           'savings'             => 'SAVINGS',
                          );
      $content{'account_type'} = $account_types{lc($content{'account_type'})}
                                 || $content{'account_type'};
    }

    # stuff it back into %content
    $self->content(%content);

}

sub remap_fields {
    my($self,%map) = @_;

    my %content = $self->content();
    foreach(keys %map) {
        $content{$map{$_}} = $content{$_};
    }
    $self->content(%content);
}

# NA: VISA, MC, AMX, DSC
# UK: VISA, MC, AMX, MAESTR
our %mop = (
  'VISA card'             => 'VISA',
  'MasterCard'            => 'MC',
  'Discover card'         => 'DSC',
  'American Express card' => 'AMEX',
  'Switch'                => 'MAESTR',
  'Solo'                  => 'MAESTR',
);

#https://www.iatspayments.com/english/help/rejects.html
our %reject = (
  '1' => 'Agent code has not been set up on the authorization system. Please call iATS at 1-888-955-5455.',
  '2' => 'Unable to process transaction. Verify and re-enter credit card information.',
  '3' => 'Invalid Customer Code.',
  '4' => 'Incorrect expiration date.',
  '5' => 'Invalid transaction. Verify and re-enter credit card information.',
  '6' => 'Please have cardholder call the number on the back of the card.',
  '7' => 'Lost or stolen card.',
  '8' => 'Invalid card status.',
  '9' => 'Restricted card status. Usually on corporate cards restricted to specific sales.',
  '10' => 'Error. Please verify and re-enter credit card information.',
  '11' => 'General decline code. Please have client call the number on the back of credit card',
  '12' => 'Incorrect CVV2 or Expiry date',
  '14' => 'The card is over the limit.',
  '15' => 'General decline code. Please have client call the number on the back of credit card',
  '16' => 'Invalid charge card number. Verify and re-enter credit card information.',
  '17' => 'Unable to authorize transaction. Authorizer needs more information for approval.',
  '18' => 'Card not supported by institution.',
  '19' => 'Incorrect CVV2 security code',
  '22' => 'Bank timeout. Bank lines may be down or busy. Re-try transaction later.',
  '23' => 'System error. Re-try transaction later.',
  '24' => 'Charge card expired.',
  '25' => 'Capture card. Reported lost or stolen.',
  '26' => 'Invalid transaction, invalid expiry date. Please confirm and retry transaction.',
  '27' => 'Please have cardholder call the number on the back of the card.',
  '32' => 'Invalid charge card number.',



( run in 1.707 second using v1.01-cache-2.11-cpan-5e09290becf )