dshahin has asked for the wisdom of the Perl Monks concerning the following question:

I want to integrate my existing shopping cart with Google's new checkout system. It requires a base64 encoded xml representation of a shopping cart object, and I was wondering what the best cpan modules to create such a string. Any advice would be appreciated.

Replies are listed 'Best First'.
Re: best modules for Google checkout
by samtregar (Abbot) on Jun 29, 2006 at 22:05 UTC
    MIME::Base64 is the obvious choice for doing base-64 encoding. You've got lots of choices for writing XML but my favorite is XML::Writer.

    -sam

      I ended up using MIME::Base64 and since I was using HTML::Template anyway, I used it to generate my XML.

      Here's what I ended up with:

      #!/usr/bin/perl use HTML::Template; use MIME::Base64; use Digest::HMAC_SHA1 qw(hmac_sha1); my $template = HTML::Template->new(filename => 'cart.tmpl'); my @items; my $key = '1234567899'; my $num; while ($num < 10){ my %item = (item_name => "Bone Volume $num", item_descrip +tion => "good stuff", quantity => "1", unit_price => "40.00"); push (@items, \%item); $num++; } $template->param(items => \@items); my $cart = $template->output; my $ecart = encode_base64($template->output,''); my $signature = encode_base64(hmac_sha1($cart, $key),$eol); print "cart:$cart\nencoded cart:$ecart\nsignature:$signature\n";

      It seems to do the job, thanks for the tip.