| 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
| |||||||||||
| 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
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | my $body = {}; | |||||||||
| 51 | 0 | ▶ | $body->{amount} = $args{amount} if $args{amount}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | ▶ | $body->{invoice_id} = $args{invoice_id} if $args{invoice_id}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | ▶ | $body->{note_to_payer} = $args{note_to_payer} if $args{note_to_payer}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||