File Coverage

blib/lib/Business/OnlinePayment/Litle/UpdaterResponse.pm
Criterion Covered Total %
statement 93 101 92.0
branch 24 44 54.5
condition 1 3 33.3
subroutine 19 20 95.0
pod 1 17 5.8
total 138 185 74.5


line stmt bran cond sub pod time code
1             package Business::OnlinePayment::Litle::UpdaterResponse;
2 1     1   4688 use strict;
  1         2  
  1         24  
3 1     1   4 use warnings;
  1         2  
  1         296  
4              
5             # ABSTRACT: Business::OnlinePayment::Litle::UpdaterResponse
6             our $VERSION = '0.957'; # VERSION
7              
8              
9             sub new{
10 1     1 1 350 my ($class, $args) = @_;
11 1         3 my $self = bless $args, $class;
12              
13 1         5 $self->_build_subs(
14             qw( cust_id order_number invoice_number batch_date result_code
15             new_card_token old_cardnum old_type old_expdate
16             error_message is_success type is_updated new_cardnum new_expdate new_type));
17              
18 1         37 $self->order_number( $args->{'litleTxnId'});
19 1         25 $self->invoice_number( $args->{'orderId'});
20 1         22 $self->batch_date( $args->{'responseTime'});
21 1         22 $self->result_code( $args->{'response'});
22 1         26 $self->error_message( $args->{'message'});
23 1         22 $self->cust_id( $args->{'customerId'});
24 1 50       24 $self->type( $args->{'originalCard'} ? 'confirm' : 'auth' );
25 1         22 $self->is_updated(0);
26 1 50       3 if ( $args->{'originalCard'} ) {
27 1         22 $self->old_cardnum( $args->{'originalCard'}->{'number'} );
28 1         25 $self->old_type( $args->{'originalCard'}->{'type'} );
29 1         27 $self->old_expdate( $args->{'originalCard'}->{'expDate'} );
30             }
31 1 50       22 if ( $self->type eq 'confirm' ){
32 1 50 33     12 if ( $args->{'updatedToken'} ) {
    50          
33 0         0 $self->new_card_token( $args->{'updatedToken'}->{'litleToken'} );
34 0         0 $self->new_type( $args->{'updatedToken'}->{'type'} );
35 0         0 $self->new_expdate( $args->{'updatedToken'}->{'expDate'} );
36 0         0 $self->is_updated(1);
37             } elsif ( $args->{'updatedCard'}->{'number'} && $args->{'updatedCard'}->{'number'} ne 'N/A' ) {
38 1         23 $self->new_cardnum( $args->{'updatedCard'}->{'number'} );
39 1         22 $self->new_type( $args->{'updatedCard'}->{'type'} );
40 1         24 $self->new_expdate( $args->{'updatedCard'}->{'expDate'} );
41 1         21 $self->is_updated(1);
42             }
43             }
44              
45 1         39 $self->is_success(1);
46 1         12 return $self;
47             }
48              
49             sub _build_subs {
50 1     1   2 my $self = shift;
51              
52 1         2 foreach(@_) {
53 16 50       99 next if($self->can($_));
54 16 50   1 0 729 eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }"; ## no critic
  1 50   1 0 3  
  1 50   1 0 3  
  1 50   1 0 2  
  1 50   1 0 3  
  1 50   2 0 2  
  1 0   0 0 3  
  1 100   2 0 2  
  1 50   1 0 3  
  1 50   1 0 3  
  1 100   2 0 3  
  1 50   1 0 2  
  1 50   1 0 3  
  1 50   1 0 3  
  1 50   1 0 3  
  1 100   2 0 2  
  1         3  
  1         5  
  1         5  
  1         3  
  1         4  
  2         5  
  2         5  
  2         5  
  2         5  
  0         0  
  0         0  
  0         0  
  0         0  
  2         433  
  2         5  
  1         2  
  2         8  
  1         3  
  1         3  
  1         2  
  1         2  
  1         2  
  1         4  
  1         2  
  1         2  
  2         5  
  2         6  
  1         2  
  2         7  
  1         2  
  1         3  
  1         2  
  1         3  
  1         10  
  1         4  
  1         2  
  1         2  
  1         3  
  1         4  
  1         4  
  1         2  
  1         7  
  1         5  
  1         2  
  1         2  
  2         4  
  2         5  
  1         4  
  2         6  
55             }
56             }
57              
58             1;
59              
60             __END__