Google-Checkout

 view release on metacpan or  search on metacpan

lib/Google/Checkout/General/MerchantCalculationResult.pm  view on Meta::CPAN

#--

use strict;
use warnings;

sub new
{
  my ($class, %args) = @_;

  my $self = {};

  my $_has_coupon_calculated_amount = exists $args{coupon_calculated_amount};
  my $_has_coupon_message           = exists $args{coupon_message} && 
                                      length($args{coupon_message});

  my $_has_certificate_calculated_amount = 
       exists $args{certificate_calculated_amount};

  my $_has_certificate_message = exists $args{certificate_message} &&
                                 length($args{certificate_message});

  my $_has_coupon_result = exists $args{valid_coupon}             ||
                           exists $args{coupon_calculated_amount} ||
                           exists $args{coupon_code}              ||
                           exists $args{coupon_message};

  my $_has_gift_certificate = exists $args{valid_certificate}             ||
                              exists $args{certificate_calculated_amount} ||
                              exists $args{certificate_code}              ||
                              exists $args{certificate_message};

  my $_has_merchant_code_results = $_has_coupon_result || 
                                   $_has_gift_certificate;

     $self = {_has_total_tax      => exists $args{total_tax},
              _has_shipping_rate  => exists $args{shipping_rate},
              _has_shippable      => exists $args{shippable},
              total_tax           => $args{total_tax}                     || 0,
              shipping_rate       => $args{shipping_rate}                 || 0,,
              shippable           => $args{shippable}                     || '',
              coupon_valid        => defined($args{valid_coupon}) ? $args{valid_coupon} : 0,
              coupon_amount       => $args{coupon_calculated_amount}      || 0,
              coupon_code         => $args{coupon_code}                   || '',
              coupon_message      => $args{coupon_message}                || '',
              certificate_valid   => $args{valid_certificate}             || 1,
              certificate_amount  => $args{certificate_calculated_amount} || 0,
              certificate_code    => $args{certificate_code}              || '',
              certificate_message => $args{certificate_message}           || '',
              shipping_name       => $args{shipping_name}, 
              address_id          => $args{address_id} };

  $self->{_has_coupon_calculated_amount}      = $_has_coupon_calculated_amount;
  $self->{_has_coupon_message}                = $_has_coupon_message;
  $self->{_has_certificate_message}           = $_has_certificate_message;
  $self->{_has_coupon_result}                 = $_has_coupon_result;
  $self->{_has_gift_certificate}              = $_has_gift_certificate;
  $self->{_has_merchant_code_results}         = $_has_merchant_code_results;
  $self->{_has_certificate_calculated_amount} = 
    $_has_certificate_calculated_amount;

  return bless $self => $class;
}

sub has_shipping_rate        
{ 
  my ($self) = @_;

  return $self->{_has_shipping_rate};
}

sub has_shippable            
{ 
  my ($self) = @_;

  return $self->{_has_shippable};
}

sub has_total_tax            
{ 
  my ($self) = @_;

  return $self->{_has_total_tax};
}

sub has_coupon_result        
{ 
  my ($self) = @_;

  return $self->{_has_coupon_result};
}

sub has_certificate_result   
{ 
  my ($self) = @_;

  return $self->{_has_gift_certificate};
}

sub has_merchant_code_result 
{ 
  my ($self) = @_;

  return $self->{_has_merchant_code_results}; 
}

sub has_coupon_calculated_amount 
{ 
  my ($self) = @_;

  return $self->{_has_coupon_calculated_amount}; 
}

sub has_coupon_message
{ 
  my ($self) = @_;

  return $self->{_has_coupon_message};
}

sub has_certificate_calculated_amount 
{ 

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.589 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )