Google-Checkout
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Google/Checkout/General/GCO.pm view on Meta::CPAN
use Google::Checkout::XML::CheckoutXmlWriter;
use Google::Checkout::General::MerchantCalculationResults;
use Google::Checkout::XML::NotificationResponseXmlWriter;
use Google::Checkout::General::Util qw/is_gco_error compute_hmac_sha1 compute_base64/;
#--
#-- Version. This is the version number of the whole sample
#-- code. Thus, everytime we make a bug fix or release a new
#-- version of any code, this number if increased.
#--
#-- NOTE: Please do NOT change this number! This is in fact
#-- a special variable that Perl tracks. It allows us
#-- to ask for a specify version of the sample code.
#-- For example, if we add a feature to the sample code
#-- which is only available to the newest version of GCO,
#-- the user can say "use GCO 2.0;' which will reject this
#-- version of the library.
#--
our $VERSION = "1.1.1";
sub new
{
my ($class, %args) = @_;
my $self = {_reader => undef};
if ($args{config_path}) {
#--
#-- have a configuration? if so, use it
#--
$self->{_reader} = Google::Checkout::General::ConfigReader->new(
{config_path => $args{config_path}});
} elsif ($args{merchant_id} && $args{merchant_key} && $args{gco_server}) {
#--
#-- config is passed in
#--
$self->{__merchant_id} = $args{merchant_id};
$self->{__merchant_key} = $args{merchant_key};
$self->{__base_gco_server} = $args{gco_server};
#--
#-- if user supply the following, use them. otherwise, use default
#--
$self->{__xml_schema} = $args{xml_schema} || 'http://checkout.google.com/schema/2';
$self->{__currency_supported} = $args{currency_supported} || 'USD';
$self->{__xml_version} = $args{xml_version} || '1.0';
$self->{__xml_encoding} = $args{xml_encoding} || 'UTF-8';
} else {
#--
#-- try a default configuration
#--
$self->{_reader} = Google::Checkout::General::ConfigReader->new;
}
return bless $self => $class;
}
sub reader
{
my ($self) = @_;
return $self->{_reader};
}
sub get_checkout_url
{
my ($self) = @_;
return $self->_get_url('merchantCheckout');
#--
#-- TODO: the following will go away on July 2007
#--
return $self->_get_url("checkout");
}
sub get_checkout_diagnose_url
{
my ($self) = @_;
return $self->_get_url('merchantCheckout');
#--
#-- TODO: the following will go away on July 2007
#--
return $self->_get_url("checkout", 1);
}
sub get_request_url
{
my ($self) = @_;
return $self->_get_url("request");
}
sub get_request_diagnose_url
{
my ($self) = @_;
return $self->_get_url("request", 1);
}
#--
#-- Return the HMAC-SHA1 / Base64 signature
#--
sub b64_signature
{
my ($self, $cart) = @_; #-- $cart = Shopping cart in XML
my $id = '';
if ($self->reader()) {
$id = $self->reader()->get(Google::Checkout::XML::Constants::MERCHANT_KEY);
} else {
$id = $self->{__merchant_key} || Google::Checkout::General::Error(-1, "Missing merchant key");
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.634 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )