PayPal/API/Payments.pm

filter: Statementstmt 52.6% 20 / 38 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 100% 3 / 3 totaltotal 44.4% 28 / 63 CC 7 SCAR 24.4
CC
7
Cov
40%
refund
30.0
get_capture
6.0
get_refund
6.0
CRAP 11.4
« PayPal/API/Products.pm ↑ Summary PayPal/API/Plans.pm »
1 package WWW::PayPal::API::Payments;
2  
3 # ABSTRACT: PayPal Payments v2 API (captures, refunds, authorizations)
4  
5 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use WWW::PayPal::Capture;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use WWW::PayPal::Refund;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = '0.003';
12  
13  
14 3 has client => (
15 is => 'ro',
16 required => 1,
17 weak_ref => 1,
18 );
19  
20 has openapi_operations => (
21 is => 'lazy',
22 0 ▶ builder => sub {
Subroutine _build_openapi_operations: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 # Pre-computed from paypal-rest-api-specifications
24 # (openapi/payments_payment_v2.json).
25 return {
26 0 'captures.get' => { method => 'GET', path => '/v2/payments/captures/{capture_id}' },
27 'captures.refund' => { method => 'POST', path => '/v2/payments/captures/{capture_id}/refund' },
28 'refunds.get' => { method => 'GET', path => '/v2/payments/refunds/{refund_id}' },
29 'authorizations.get' => { method => 'GET', path => '/v2/payments/authorizations/{authorization_id}' },
30 'authorizations.capture' => { method => 'POST', path => '/v2/payments/authorizations/{authorization_id}/capture' },
31 'authorizations.void' => { method => 'POST', path => '/v2/payments/authorizations/{authorization_id}/void' },
32 };
33 },
34 3 );
35  
36 3 with 'WWW::PayPal::Role::OpenAPI';
37  
38 0 ▶sub get_capture {
Subroutine get_capture: not called CC=2 SCAR=17.9
Pod documented
39 0 my ($self, $id) = @_;
40 0 ▶ croak 'capture_id required' unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
41 0 my $data = $self->call_operation('captures.get', path => { capture_id => $id });
42 0 return WWW::PayPal::Capture->new(client => $self->client, data => $data);
43 }
44  
45  
46 0 ▶sub refund {
Subroutine refund: not called CC=5 SCAR=34.0
Pod documented
47 0 my ($self, $capture_id, %args) = @_;
48 0 ▶ croak 'capture_id required' unless $capture_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $capture_id 0 0 0
49  
50 0 my $body = {};
51 0 ▶ $body->{amount} = $args{amount} if $args{amount};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"amount"} 0 0 0
52 0 ▶ $body->{invoice_id} = $args{invoice_id} if $args{invoice_id};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"invoice_id"} 0 0 0
53 0 ▶ $body->{note_to_payer} = $args{note_to_payer} if $args{note_to_payer};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"note_to_payer"} 0 0 0
54  
55 0 my $data = $self->call_operation('captures.refund',
56 path => { capture_id => $capture_id },
57 body => $body,
58 );
59 0 return WWW::PayPal::Refund->new(client => $self->client, data => $data);
60 }
61  
62  
63 0 ▶sub get_refund {
Subroutine get_refund: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self, $id) = @_;
65 0 ▶ croak 'refund_id required' unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
66 0 my $data = $self->call_operation('refunds.get', path => { refund_id => $id });
67 0 return WWW::PayPal::Refund->new(client => $self->client, data => $data);
68 }
69  
70  
71 3 1;
72  
73 __END__
« PayPal/API/Products.pm ↑ Summary PayPal/API/Plans.pm »