Load XML::Simple at runtime to avoid breakage
authormark <mark>
Sat, 3 Oct 2009 20:22:19 +0000 (20:22 +0000)
committermark <mark>
Sat, 3 Oct 2009 20:22:19 +0000 (20:22 +0000)
FS/FS/pay_batch.pm
FS/FS/pay_batch/paymentech.pm

index ffa6e20..83bf7a3 100644 (file)
@@ -4,7 +4,6 @@ use strict;
 use vars qw( @ISA $DEBUG %import_info %export_info $conf );
 use Time::Local;
 use Text::CSV_XS;
-use XML::Simple qw(XMLin XMLout);
 use FS::Record qw( dbh qsearch qsearchs );
 use FS::cust_pay;
 use FS::Conf;
@@ -241,11 +240,13 @@ sub import_results {
   # process one line at a time.
 
   if ($filetype eq 'XML') {
+    eval "use XML::Simple";
+    die $@ if $@;
     my @xmlkeys = @{ $info->{'xmlkeys'} };  # for XML
     my $xmlrow  = $info->{'xmlrow'};        # also for XML
 
     # Do everything differently.
-    my $data = XMLin($fh, KeepRoot => 1);
+    my $data = XML::Simple::XMLin($fh, KeepRoot => 1);
     my $rows = $data;
     # $xmlrow = [ RootKey, FirstLevelKey, SecondLevelKey... ]
     $rows = $rows->{$_} foreach( @$xmlrow );
index 33a9fda..44fa78a 100644 (file)
@@ -6,7 +6,6 @@ use Time::Local;
 use Date::Format 'time2str';
 use Date::Parse 'str2time';
 use FS::Conf;
-use XML::Simple qw(XMLin XMLout);
 
 my $conf;
 my ($bin, $merchantID, $terminalID, $username);
@@ -49,6 +48,9 @@ my %paytype = (
 
 %export_info = (
   init  => sub {
+# Load this at run time
+    eval "use XML::Simple";
+    die $@ if $@;
     my $conf = shift;
     ($bin, $terminalID, $merchantID, $username) =
        $conf->config('batchconfig-paymentech');
@@ -58,7 +60,7 @@ my %paytype = (
     my $pay_batch = shift;
     my @cust_pay_batch = @{(shift)};
     my $count = 0;
-    XMLout( {
+    XML::Simple::XMLout( {
       transRequest => {
         RequestCount => scalar(@cust_pay_batch),
         batchFileID  => {