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 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use WWW::PayPal::Capture;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use WWW::PayPal::Refund;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '0.002';
12  
13  
14 2 has client => (
15 is => 'ro',
16 required => 1,
17 weak_ref => 1,
18 );
19  
20 has openapi_operations => (
21 is => 'lazy',
22 builder => sub {
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}' },
Subroutine _build_openapi_operations: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 2 );
35  
36 2 with 'WWW::PayPal::Role::OpenAPI';
37  
38 sub get_capture {
39 0 ▶ my ($self, $id) = @_;
Subroutine get_capture: not called CC=2 SCAR=17.9
Pod documented
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 sub refund {
47 0 ▶ my ($self, $capture_id, %args) = @_;
Subroutine refund: not called CC=5 SCAR=34.0
Pod documented
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 sub get_refund {
64 0 ▶ my ($self, $id) = @_;
Subroutine get_refund: not called CC=2 SCAR=17.9
Pod documented
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 2 1;
72  
73 __END__
« PayPal/API/Products.pm ↑ Summary PayPal/API/Plans.pm »