File Coverage

blib/lib/WebService/PayPal/PaymentsAdvanced/Role/HasTender.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition 4 6 66.6
subroutine 5 5 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package WebService::PayPal::PaymentsAdvanced::Role::HasTender;
2              
3 6     6   4194 use Moo::Role;
  6         18  
  6         151  
4              
5 6     6   2210 use namespace::autoclean;
  6         16  
  6         99  
6              
7             our $VERSION = '0.000027';
8              
9 6     6   598 use Types::Standard qw( Bool StrictNum );
  6         19  
  6         47  
10              
11             has amount => (
12             is => 'lazy',
13             isa => StrictNum,
14             init_arg => undef,
15             default => sub { shift->params->{AMT} },
16             );
17              
18             has is_credit_card_transaction => (
19             is => 'lazy',
20             isa => Bool,
21             init_arg => undef,
22             );
23              
24             has is_paypal_transaction => (
25             is => 'lazy',
26             isa => Bool,
27             lazy => 1,
28             init_arg => undef,
29             );
30              
31             sub _build_is_credit_card_transaction {
32 33     33   3471 my $self = shift;
33             return ( exists $self->params->{TENDER}
34             && $self->params->{TENDER} eq 'CC' )
35 33   66     682 || exists $self->params->{CARDTYPE};
36             }
37              
38             sub _build_is_paypal_transaction {
39 12     12   4321 my $self = shift;
40             return ( exists $self->params->{TENDER}
41             && $self->params->{TENDER} eq 'P' )
42             || exists $self->params->{BAID}
43 12   66     340 || !$self->is_credit_card_transaction;
44             }
45              
46             1;
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             WebService::PayPal::PaymentsAdvanced::Role::HasTender - Role which provides some methods describing a transaction
55              
56             =head1 VERSION
57              
58             version 0.000027
59              
60             =head2 amount
61              
62             The C<AMT> param
63              
64             =head2 is_credit_card_transaction
65              
66             C<Boolean>. Returns true if this is a credit card transaction.
67              
68             =head2 is_paypal_transaction
69              
70             C<Boolean>. Returns true if this is a PayPal transaction.
71              
72             =head1 SUPPORT
73              
74             Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.
75              
76             =head1 AUTHOR
77              
78             Olaf Alders <olaf@wundercounter.com>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2021 by MaxMind, Inc.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut
88              
89             __END__
90              
91             # ABSTRACT: Role which provides some methods describing a transaction
92