File Coverage

blib/lib/WWW/PayPal/Capture.pm
Criterion Covered Total %
statement 6 16 37.5
branch 0 2 0.0
condition n/a
subroutine 2 9 22.2
pod 7 7 100.0
total 15 34 44.1


line stmt bran cond sub pod time code
1             package WWW::PayPal::Capture;
2              
3             # ABSTRACT: PayPal Payments v2 capture entity
4              
5 2     2   14 use Moo;
  2         4  
  2         16  
6 2     2   853 use namespace::clean;
  2         5  
  2         22  
7              
8             our $VERSION = '0.002';
9              
10              
11             has _client => (
12             is => 'ro',
13             required => 1,
14             weak_ref => 1,
15             init_arg => 'client',
16             );
17              
18             has data => ( is => 'rw', required => 1 );
19              
20              
21 0     0 1   sub id { $_[0]->data->{id} }
22 0     0 1   sub status { $_[0]->data->{status} }
23 0     0 1   sub amount { $_[0]->data->{amount}{value} }
24 0     0 1   sub currency { $_[0]->data->{amount}{currency_code} }
25 0     0 1   sub invoice_id { $_[0]->data->{invoice_id} }
26              
27              
28             sub fee_in_cent {
29 0     0 1   my ($self) = @_;
30 0 0         my $fee = $self->data->{seller_receivable_breakdown}{paypal_fee}{value} or return;
31 0           return int($fee * 100 + 0.5);
32             }
33              
34              
35             sub refund {
36 0     0 1   my ($self, %args) = @_;
37 0           return $self->_client->payments->refund($self->id, %args);
38             }
39              
40              
41              
42             1;
43              
44             __END__