[ic] Minor patch for XML gateways in Payment.pm
Chris Keane
chris.keane at zzgi.com
Tue Oct 27 17:45:15 UTC 2009
I have a client in Canada using PsiGate, now only accepting payment
submissions via XML. Thinking that more and more gateways are going to
insist on this I ended up patching Payment.pm to optionally transform
$query into XML rather than & joined values. Quick and dirty but
potentially useful to someone.
In catalog.cfg,
# use_xml value is the XML root tag name, e.g. <Order>...xml...</Order>
Route psigate use_get /usr/bin/wget
Route psigate use_xml Order
--- Payment.pm 2009-10-27 17:40:07.000000000 +0000
+++ Payment.pm.new 2009-10-27 17:39:04.000000000 +0000
@@ -642,12 +642,22 @@
my $cmd = $opt->{use_wget} =~ m{/} ? $opt->{use_wget} :
'wget';
my @post;
- while( my ($k,$v) = each %$query ) {
- $k = hexify($k);
- $v = hexify($v);
- push @post, "$k=$v";
- }
- my $post = join "&", @post;
+ my $post;
+ if ($opt->{use_xml}) {
+ require XML::Simple;
+
+ my $xs = XML::Simple->new();
+ my $order;
+ $order->{$opt->{use_xml}} = $query;
+ $post = $xs->XMLout($order, NoAttr=>1,
KeepRoot=>1 );
+ } else {
+ while( my ($k,$v) = each %$query ) {
+ $k = hexify($k);
+ $v = hexify($v);
+ push @post, "$k=$v";
+ }
+ $post = join "&", @post;
+ }
open WIN, "> $infile"
or die errmsg("Cannot create wget post input
file %s: %s", $infile, $!) . "\n";
print WIN $post;
More information about the interchange-users
mailing list