Business-OnlinePayment-IATSPayments

 view release on metacpan or  search on metacpan

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

    }

    # 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.',
  '39' => 'Contact IATS 1-888-955-5455.',
  '40' => 'Invalid card number. Card not supported by IATS.',
  '41' => 'Invalid Expiry date.',
  '42' => 'CVV2 required.',
  '43' => 'Incorrect AVS.',
  '45' => 'Credit card name blocked. Call iATS at 1-888-955-5455.',
  '46' => 'Card tumbling. Call iATS at 1-888-955-5455.',
  '47' => 'Name tumbling. Call iATS at 1-888-955-5455.',
  '48' => 'IP blocked. Call iATS at 1-888-955-5455.',
  '49' => 'Velocity 1 – IP block. Call iATS at 1-888-955-5455.',
  '50' => 'Velocity 2 – IP block. Call iATS at 1-888-955-5455.',
  '51' => 'Velocity 3 – IP block. Call iATS at 1-888-955-5455.',
  '52' => 'Credit card BIN country blocked. Call iATS at 1-888-955-5455.',
  '100' => 'DO NOT REPROCESS. Call iATS at 1-888-955-5455.',
  #Timeout 	The system has not responded in the time allotted. Call iATS at 1-888-955-5455.
);

our %failure_status = (
  '7'  => 'stolen',
  '8'  => 'inactive',
  '9'  => 'inactive',
  '14' => 'nsf',
  '24' => 'expired',
  '25' => 'stolen',
  '45' => 'blacklisted',
  '48' => 'blacklisted',
  '49' => 'blacklisted',
  '50' => 'blacklisted',
  '51' => 'blacklisted',
  '52' => 'blacklisted',
  #'100' => # it sounds serious.  but why?  it says nothing specific
);

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

  $self->map_fields;

  $self->remap_fields(
        login             => 'agentCode',
        password          => 'password',

        description       => 'comment',
        amount            => 'total',
        invoice_number    => 'invoiceNum',
        customer_ip       => 'customerIPAddress',

        last_name         => 'lastName',
        first_name        => 'firstName',
        address           => 'address',
        city              => 'city',
        state             => 'state',
        zip               => 'zipCode',
        #country           => 'x_Country',

        card_number       => 'creditCardNum',
        expiration        => 'creditCardExpiry',
        cvv2              => 'cvv2',

        authorization     => 'transactionId',

        account_type      => 'accountType',

  );

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

  $content{'mop'} = $mop{ cardtype($content{creditCardNum}) }
    if $content{'type'} eq 'CC';

  if ( $self->test_transaction ) {
    $content{agentCode} = 'TEST88';
    $content{password}  = 'TEST88';



( run in 1.446 second using v1.01-cache-2.11-cpan-800906f7e73 )