Business-OnlinePayment-IPPay
view release on metacpan or search on metacpan
$self->path('/ippay') unless $self->path;
$self->build_subs(qw( order_number avs_code cvv2_response
response_page response_code response_headers
));
$DEBUG = exists($opts{debug}) ? $opts{debug} : 0;
# module specific data
my %_defaults = ();
foreach my $key (keys %opts) {
$key =~ /^default_(\w*)$/ or next;
$_defaults{$1} = $opts{$key};
delete $opts{$key};
}
$self->{_defaults} = \%_defaults;
}
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' => 'SALE',
'authorization only' => 'AUTHONLY',
'post authorization' => 'CAPT',
'reverse authorization' => 'REVERSEAUTH',
'void' => 'VOID',
'credit' => 'CREDIT',
);
my %check_actions =
( 'normal authorization' => 'CHECK',
'void' => 'VOIDACH',
'credit' => 'REVERSAL',
);
if ($self->transaction_type eq 'CC') {
$content{'TransactionType'} = $actions{$action} || $action;
} elsif ($self->transaction_type eq 'ECHECK') {
$content{'TransactionType'} = $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'};
}
$content{Origin} = 'RECURRING'
if ($content{recurring_billing} &&$content{recurring_billing} eq 'YES' );
# stuff it back into %content
$self->content(%content);
}
sub expdate_month {
my ($self, $exp) = (shift, shift);
my $month;
if ( defined($exp) and $exp =~ /^(\d+)\D+\d*\d{2}$/ ) {
$month = sprintf( "%02d", $1 );
}elsif ( defined($exp) and $exp =~ /^(\d{2})\d{2}$/ ) {
$month = sprintf( "%02d", $1 );
}
return $month;
}
sub expdate_year {
my ($self, $exp) = (shift, shift);
my $year;
if ( defined($exp) and $exp =~ /^\d+\D+\d*(\d{2})$/ ) {
$year = sprintf( "%02d", $1 );
}elsif ( defined($exp) and $exp =~ /^\d{2}(\d{2})$/ ) {
$year = sprintf( "%02d", $1 );
}
return $year;
}
sub revmap_fields {
my $self = shift;
tie my(%map), 'Tie::IxHash', @_;
my %content = $self->content();
map {
my $value;
if ( ref( $map{$_} ) eq 'HASH' ) {
$value = $map{$_} if ( keys %{ $map{$_} } );
}elsif( ref( $map{$_} ) ) {
$value = ${ $map{$_} };
}elsif( exists( $content{ $map{$_} } ) ) {
$value = $content{ $map{$_} };
}
if (defined($value)) {
($_ => $value);
}else{
();
}
} (keys %map);
}
sub submit {
( run in 4.064 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )