[interchange-cvs] interchange - heins modified
lib/Vend/Payment/TestPayment.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Sun Jan 16 11:31:31 EST 2005
User: heins
Date: 2005-01-16 16:31:31 GMT
Modified: lib/Vend/Payment TestPayment.pm
Log:
* Add logging capability to be able to trace payment status for testing.
Enable with:
# Enable logging
Route testpayment log 1
# Change log file from default error.log
Route testpayment logfile logs/testpayment.log
Revision Changes Path
1.6 +34 -14 interchange/lib/Vend/Payment/TestPayment.pm
rev 1.6, prev_rev 1.5
Index: TestPayment.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Payment/TestPayment.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestPayment.pm 7 Jun 2004 20:59:18 -0000 1.5
+++ TestPayment.pm 16 Jan 2005 16:31:31 -0000 1.6
@@ -1,6 +1,6 @@
# Vend::Payment::TestPayment - Interchange payment test module
#
-# $Id: TestPayment.pm,v 1.5 2004/06/07 20:59:18 mheins Exp $
+# $Id: TestPayment.pm,v 1.6 2005/01/16 16:31:31 mheins Exp $
#
# Copyright (C) 2002 Cursor Software Limited.
# All Rights Reserved.
@@ -190,7 +190,7 @@
unless $Vend::Quiet or ! $Global::VendRoot or ! $Global::VendRoot;
}
-$VERSION = substr(q$Revision: 1.5 $,10);
+$VERSION = substr(q$Revision: 1.6 $,10);
package Vend::Payment;
@@ -211,19 +211,25 @@
if ($opt->{actual}){
$actual = $opt->{actual};
}
- else{
- my (%actual) = map_actual();
- $actual = \%actual;
+ else {
+ my (%actual) = map_actual();
+ $actual = \%actual;
}
#::logDebug("actual map result: " . ::uneval($actual));
- unless ($user){
- $user = charge_param('id') or return (
- MStatus => 'failure-hard',
- MErrMsg => errmsg('No account id'),
- );
+ unless ($user) {
+ $user = charge_param('id') or return (
+ MStatus => 'failure-hard',
+ MErrMsg => errmsg('No account id'),
+ );
}
+ my $logfile;
+ my $log;
+ if($log = charge_param('log')) {
+ $logfile = charge_param('logfile') || $Vend::Cfg->{ErrorFile};
+ }
+
$secret ||= charge_param('secret');
my $precision = $opt->{precision} || 2;
@@ -245,10 +251,11 @@
$actual->{mv_credit_card_exp_year} =~ s/\D//g;
$actual->{mv_credit_card_number} =~ s/\D//g;
- my $exp = sprintf('%02d%02d',
- $actual->{mv_credit_card_exp_month},
- $actual->{mv_credit_card_exp_year},
- );
+ my $exp = sprintf(
+ '%02d%02d',
+ $actual->{mv_credit_card_exp_month},
+ $actual->{mv_credit_card_exp_year},
+ );
$opt->{transaction} ||= 'sale';
@@ -330,6 +337,19 @@
$msg ||= 'TestPayment error: %s. Please call in your order or try again.';
$result{'pop.error-message'} = errmsg($msg,'Invalid test card number');
}
+
+ if($log) {
+ logError(
+ errmsg('TestPayment %s id=%s: function=%s status=%s amount=%s error=%s',
+ $user,
+ $opt->{order_id},
+ $amount,
+ $result{'pop.status'},
+ $result{'pop.error-message'},
+ ),
+ { file => $logfile },
+ );
+ }
$result{MStatus} = $result{'pop.status'};
$result{MErrMsg} = $result{'pop.error-message'} if $result{'pop.error-message'};
More information about the interchange-cvs
mailing list