#################### main pod documentation begin ################### =head1 NAME Zymonic::PayerAuthentication::Test - Zymonic Workflow System PayerAuthentication module =head1 SYNOPSIS A test payer authentication module. =head1 DESCRIPTION For testing purposes only. Response will be based on incoming card number. Card Number = 4444XXBXXXXXXXXX 4444 is 4444 B is 0, card is enrolled B is anything else, card is not enrolled X is any digit PARes ends with 0 is success, ends with anythign else is fail =head1 USAGE Not to be used directly, use one of its subclasses. =head1 BUGS NONE =head1 SUPPORT As in the license, Zymonic is provided without warranty or support unless purchased separately, however... If you email zymonic-support@zednax.com your issue will be noted and may receive a response. For security issues, please contact zymonic-security@zednax.com and someone will respond within 8 working hours. =head1 AUTHOR Alex Masidlover et al.a CPAN ID: MODAUTHOR Zednax Limited alex.masidlover@zednax.com http://www.zednax.com =head1 COPYRIGHT This program is free software licensed under the... Zymonic Public License 1.0 The full text of the license can be found in the LICENSE file included with this module. Other licenses may be acceptable if including parts of Zymonic in larger projects, please contact Zednax for details. =head1 SEE ALSO Zymonic::Field Zymonic perl(1). =cut #################### main pod documentation end ################### package Zymonic::PayerAuthentication::Test; use strict; BEGIN { use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = '0.01'; @ISA = qw(Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw(); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } use base "Zymonic::PayerAuthentication"; use Zymonic::Utils qw(random_string random_base64_string); #################### subroutine header begin #################### =head2 enrolled_result Usage : $payerauth->enrolled_result($card_number, $details) Purpose : Checks whether the incoming card number is enrolled to use payer authentication. Returns : A hashref of enrolled, acs_url, pareq and issuer_cert the latter three if card is enrolled. Argument : Card number to check and hashref of details of transaction Throws : Comment : See Also : =cut #################### subroutine header end #################### sub enrolled_result { my $self = shift; my $card_number = shift; my $details = shift; my $response = {}; if ( $card_number =~ /4444\d\d(\d)\d{9}/ ) { if ( $1 eq '0' ) { $response = { enrolled => 'true', acs_url => 'TEST_URL', pareq => random_base64_string(20) . ( $details->{amount} =~ /1$/ ? random_string( 5, qw($ ; @) ) : '' ), , issuer_cert => 'ISSUER_CERT', status => 'E' }; } else { $response = { enrolled => '' }; } } else { $response = { error => 'Invalid card number.' }; } return $response; } #################### subroutine header begin #################### =head2 pares_result Usage : $payerauth->pares_result($card_number, $details) Purpose : Parses the Payer Authentication Response (pares) value returned after auth. Returns : A hashref of pares, pares_id and pares_auth_code, results of parsing the pares. Argument : Card number and hashref of details including pares, and anything else needed. Throws : nothing Comment : See Also : =cut #################### subroutine header end #################### sub pares_result { my $self = shift; my $card_number = shift; my $details = shift; if ( $details->{pares} ) { if ( $details->{pares} =~ /0$/ ) { return { pares => $details->{pares}, ECI => random_string( 2, 0 .. 9 ), status => 'Y', # random pares of allowed chars, if 2nd-to-last digit is 0, add invalid chars pares_id => random_base64_string(20) . ( $details->{pares} =~ /0\d$/ ? random_string( 5, qw($ ; @) ) : '' ), pares_auth_code => random_base64_string(20) . ( $details->{pares} =~ /0\d\d$/ ? random_string( 5, qw($ ; @) ) : '' ), }; } else { return { pares => $details->{pares}, status => 'N' }; } } else { return ''; } } 1;