#################### main pod documentation begin ################### =head1 NAME Zymonic::PaymentGateway::Test - Zymonic Workflow System PaymentGateway module =head1 SYNOPSIS A test payment gateway. =head1 DESCRIPTION For testing purposes only. Response will be based on incoming card number. The following rules are used to determine the response from the card number: Card Number = 4444AAXXXXXXXXXX 4444 is 4444 AA is the response code to return (00=sucess, 02=referral, else=fail), X is any digit =head1 USAGE Add following action to a transition: ... ... ... And set a merchant on the transaction to one with payment gateway name of 'Test'. =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... Alfresco 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::Decryptor::Message::PaymentGateway Zymonic::Action::PaymentGateway Zymonic::PaymentGateway Zymonic perl(1). =cut #################### main pod documentation end ################### package Zymonic::PaymentGateway::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::PaymentGateway'; #################### subroutine header begin #################### =head2 authorise Usage : $pg->authorise($trans) Purpose : Authorises the incoming transaction. Returns : The result of the authorisation. Argument : A hashref containg transaction details Throws : Zymonic::Exception::PaymentGateway::Parameter Comment : Authorisation is based on incoming card number. See Also : =cut #################### subroutine header end #################### sub authorise { my $self = shift; my $trans = shift; Zymonic::Exception::PaymentGateway::Parameter->throw( error => 'card_number needs to be set on incoming transaction.', zname => $self->{zname}, param => 'card_number', catchable => 'false' ) unless $trans->{card_number}; return $self->build_response( $trans->{card_number} ); } #################### subroutine header begin #################### =head2 build_response Usage : $pg->build_response($card_number) Purpose : Generates the test response for the given card_number. Returns : A hashref authorisation result. Argument : A card_number Throws : nothing Comment : See Also : =cut #################### subroutine header end #################### sub build_response { my $self = shift; my $card_number = shift; my $response = { response_code => 11, auth_code => 'AUTH', auth_message => 'Invalid Card Number', referral_phone => '', csc_message => '', csc_response => '' }; if ( $card_number =~ /4444(\d{2})\d{10}/ ) { $response->{response_code} = $1; if ( $response->{response_code} eq '00' ) { $response->{auth_message} = 'Success'; } elsif ( $response->{response_code} eq '02' ) { $response->{auth_message} = 'Referral'; } else { $response->{auth_message} = 'Failure'; } } return $response; } 1;