Business-PayPoint-MCPE
view release on metacpan or search on metacpan
lib/Business/PayPoint/MCPE.pm view on Meta::CPAN
$self->request(
%args,
TransType => 'CANCEL',
);
}
sub confirm {
my $self = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
$self->request(
%args,
TransType => 'CONFIRM',
);
}
sub nonauth {
my $self = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
$self->request(
%args,
TransType => 'NONAUTH',
);
}
sub request {
my $self = shift;
my %params = @_ % 2 ? %{$_[0]} : @_;
my @intFields = ('TestMode', 'InstID', 'TransID', 'AccountID', 'AuthMode', 'CountryIP', 'AVS', 'Status', 'Time', 'CV2', 'Reference', 'Recurs', 'CancelAfter', 'ScheduleID');
my @fltFields = ('APIVersion', 'Amount', 'OriginalAmount', 'SchAmount', 'FraudScore');
my @datFields = ('Fulfillment');
$params{TestMode} = $self->{TestMode} unless exists $params{TestMode};
$params{InstID} ||= $self->{InstID};
$params{APIVersion} ||= $self->{APIVersion};
my %r;
foreach my $key (keys %params) {
if ($key =~ /^(int|flt|str|dat)/) {
$r{$key} = $params{$key};
} elsif (grep { $_ eq $key } @intFields) {
$r{'int' . $key} = $params{$key};
} elsif (grep { $_ eq $key } @fltFields) {
$r{'flt' . $key} = $params{$key};
} elsif (grep { $_ eq $key } @fltFields) {
$r{'dat' . $key} = $params{$key};
} else {
$r{'str' . $key} = $params{$key};
}
}
my $resp = $self->{ua}->post($self->{POST_URL}, \%r);
# use Data::Dumper; print STDERR Dumper(\$resp);
unless ($resp->is_success) {
return wantarray ? (error => $resp->status_line) : { error => $resp->status_line };
}
my @parts = split('&', $resp->decoded_content);
my %parts;
foreach my $p (@parts) {
my ($a, $b) = split('=', $p, 2);
$a =~ s/^(int|flt|str|dat)//;
$parts{$a} = uri_unescape($b);
$parts{$a} =~ s/\+/ /g;
}
return wantarray ? %parts : \%parts;
}
1;
__END__
=encoding utf-8
=head1 NAME
Business::PayPoint::MCPE - PayPoint: Merchant Card Payment Engine
=head1 SYNOPSIS
use Business::PayPoint::MCPE;
my $bpm = Business::PayPoint::MCPE->new(
TestMode => 1,
InstID => '123456',
);
my %data = $bpm->payment(
CartID => 654321,
Desc => 'description of goods',
Amount => '10.00',
Currency => 'GBP',
CardHolder => 'Joe Bloggs',
Postcode => 'BA12BU',
Email => 'test@paypoint.net',
CardNumber => '1234123412341234',
CV2 => '707',
ExpiryDate => '0616',
CardType => 'VISA',
Country => 'GB',
);
print Dumper(\%data); use Data::Dumper;
=head1 DESCRIPTION
Business::PayPoint::MCPE is for L<https://www.paypoint.net/assets/guides/MCPE_Freedom+IMA_2.3.pdf>
=head1 METHODS
=head2 new
=over 4
=item InstID
required.
=item TestMode
( run in 1.259 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )