[interchange-cvs] interchange - heins modified lib/Vend/Payment.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Jul 18 12:14:00 2002
User: heins
Date: 2002-07-18 16:13:56 GMT
Modified: lib/Vend Payment.pm
Log:
* Fixed bug where decimal pricing would not be forced, causing failure for
round amounts with some gateways.
* Additional debug put in DEVEL, not stable, for future development.
Revision Changes Path
2.4 +17 -2 interchange/lib/Vend/Payment.pm
rev 2.4, prev_rev 2.3
Index: Payment.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/lib/Vend/Payment.pm,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -r2.3 -r2.4
--- Payment.pm 17 Jun 2002 22:24:08 -0000 2.3
+++ Payment.pm 18 Jul 2002 16:13:56 -0000 2.4
@@ -1,6 +1,6 @@
# Vend::Payment - Interchange payment processing routines
#
-# $Id: Payment.pm,v 2.3 2002/06/17 22:24:08 jon Exp $
+# $Id: Payment.pm,v 2.4 2002/07/18 16:13:56 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -22,7 +22,7 @@
package Vend::Payment;
require Exporter;
=20
-$VERSION =3D substr(q$Revision: 2.3 $, 10);
+$VERSION =3D substr(q$Revision: 2.4 $, 10);
=20
@ISA =3D qw(Exporter);
=20
@@ -306,9 +306,13 @@
=20
# Uses the {precision} -> MV_PAYMENT_PRECISION options if set
my $precision =3D charge_param('precision') || 2;
+ my $penny =3D charge_param('penny_pricing') || 0;
=20
my $amount =3D $pay_opt->{amount} || Vend::Interpolate::total_cost();
$amount =3D round_to_frac_digits($amount, $precision);
+ $amount =3D sprintf "%.${precision}f", $amount;
+ $amount *=3D 100 if $penny;
+
$pay_opt->{total_cost} =3D $amount;
$pay_opt->{amount} =3D "$currency $amount";
=20
@@ -321,11 +325,17 @@
delete $Vend::Session->{payment_result};=20
delete $Vend::Session->{cybercash_result}; ### Deprecated
=20
+#::logDebug("Called charge at " . scalar(localtime));
+#::logDebug("Charge caller is " . join(':', caller));
+
+#::logDebug("mode=3D$pay_opt->{gateway}");
+#::logDebug("pay_opt=3D" . ::uneval($pay_opt));
# Default to the gateway same as charge type if no gateway specified,
# and set the gateway in the session for logging on completion
if(! $opt->{gateway}) {
$pay_opt->{gateway} =3D charge_param('gateway') || $charge_type;
}
+ #$charge_type ||=3D $pay_opt->{gateway};
$Vend::Session->{payment_mode} =3D $pay_opt->{gateway};
=20
# See if we are in test mode
@@ -346,6 +356,7 @@
my %result;
=20
if($sub) {
+#::logDebug("Charge sub");
# Calling a defined GlobalSub payment mode
# Arguments are the passed option hash (if any) and the route hash
eval {
@@ -363,6 +374,7 @@
}
}
elsif($charge_type =3D~ /^\s*custom\s+(\w+)(?:\s+(.*))?/si) {
+#::logDebug("Charge custom");
# MV4 and IC4.6.x methods
my (@args);
@args =3D Text::ParseWords::shellwords($2) if $2;
@@ -389,6 +401,7 @@
$charge_type =3D~ /^internal_test(?:[ _]+(.*))?/
)
{
+#::logDebug("Internal test");
=20
# Test mode....
=20
@@ -412,6 +425,7 @@
$result{MStatus} =3D $status if defined $status;
}
elsif ($Vend::CC3) {
+#::logDebug("Charge legacy cybercash");
### Deprecated
eval {
%result =3D cybercash($pay_opt);
@@ -423,6 +437,7 @@
}
}
else {
+#::logDebug("Unknown charge type");
my $msg =3D errmsg("Unknown charge type: %s", $charge_type);
::logError($msg);
$result{MStatus} =3D $msg;