| 1 | package WebService::PayPal::PaymentsAdvanced::Response; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '0.000028'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use List::AllUtils qw( any ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Types::Common::String qw( NonEmptyStr ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Types::Standard qw( ArrayRef Int Maybe ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use WebService::PayPal::PaymentsAdvanced::Error::Authentication (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use WebService::PayPal::PaymentsAdvanced::Error::Generic (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | has _nonfatal_result_codes => ( | |||||||||||||||||||||||||||
| 16 | init_arg => 'nonfatal_result_codes', | ||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||
| 18 | isa => ArrayRef [Int], | ||||||||||||||||||||||||||||
| 19 | required => 1, | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | has pnref => ( | ||||||||||||||||||||||||||||
| 23 | is => 'lazy', | ||||||||||||||||||||||||||||
| 24 | isa => NonEmptyStr, | ||||||||||||||||||||||||||||
| 25 | 16 | ▶ | default => sub { shift->params->{PNREF} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 8 | ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # PPREF is only returned if PayPal was the payment processor. | ||||||||||||||||||||||||||||
| 29 | has ppref => ( | ||||||||||||||||||||||||||||
| 30 | is => 'lazy', | ||||||||||||||||||||||||||||
| 31 | isa => Maybe [NonEmptyStr], | ||||||||||||||||||||||||||||
| 32 | 17 | ▶ | default => sub { shift->params->{PPREF} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 8 | ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 8 | with( | |||||||||||||||||||||||||||
| 36 | 'WebService::PayPal::PaymentsAdvanced::Role::ClassFor', | ||||||||||||||||||||||||||||
| 37 | 'WebService::PayPal::PaymentsAdvanced::Role::HasParams', | ||||||||||||||||||||||||||||
| 38 | 'WebService::PayPal::PaymentsAdvanced::Role::HasMessage', | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 64 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 64 | my $self = shift; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 64 | my $result = $self->params->{RESULT}; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | return | ||||||||||||||||||||||||||||
| 47 | if Int()->check($result) | ||||||||||||||||||||||||||||
| 48 | 64 | ▶ | && ( any { $result == $_ } @{ $self->_nonfatal_result_codes } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
&Int()->check($result) and &any(sub {
$result == $_;
}
, @{$self->_nonfatal_result_codes;})
MC/DC50%1/2
&Int()->check($result) and &any(sub {
$result == $_;
}
, @{$self->_nonfatal_result_codes;})
&Int()->check($result)
&any(sub {
$result == $_;
}
, @{$self->_nonfatal_result_codes;})
Truth table66%2/3
A and B
A= &Int()->check($result)B= &any(sub {
$result == $_;
}
, @{$self->_nonfatal_result_codes;})
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 3 | ▶ | if ( $result && $result == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$result and $result == 1
MC/DC0%0/2
$result and $result == 1
$result
$result == 1
Truth table33%1/3
A and B
A= $resultB= $result == 1
| |||||||||||||||||||||||||||||
| 51 | 3 | $self->_class_for('Error::Authentication')->throw( | |||||||||||||||||||||||||||
| 52 | message => 'Authentication error: ' . $self->message, | ||||||||||||||||||||||||||||
| 53 | params => $self->params, | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | $self->_class_for('Error::Generic')->throw( | |||||||||||||||||||||||||||
| 58 | message => $self->message, | ||||||||||||||||||||||||||||
| 59 | params => $self->params, | ||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 8 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =pod | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 NAME | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | WebService::PayPal::PaymentsAdvanced::Response - Generic response object | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head1 VERSION | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | version 0.000028 | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | use WebService::PayPal::PaymentsAdvanced::Response; | ||||||||||||||||||||||||||||
| 80 | my $response = WebService::PayPal::PaymentsAdvanced::Response->new( | ||||||||||||||||||||||||||||
| 81 | params => $params ); | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | This module provides a consistent interface for getting information from a | ||||||||||||||||||||||||||||
| 86 | PayPal response, regardless of whether it comes from token creation, a redirect | ||||||||||||||||||||||||||||
| 87 | or a silent POST. It will be used as a parent class for other response | ||||||||||||||||||||||||||||
| 88 | classes. You should never need to create this object yourself. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head1 METHODS | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head2 message | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | The contents of PayPal's RESPMSG parameter. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head2 params | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | A C<HashRef> of parameters which have been returned by PayPal. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 pnref | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | The contents of PayPal's PNREF parameter. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 ppref | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | The contents of PayPal's PPREF parameter. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | L<WebService::PayPal::PaymentsAdvanced::Response::FromHTTP>, | ||||||||||||||||||||||||||||
| 111 | L<WebService::PayPal::PaymentsAdvanced::Response::FromRedirect>, | ||||||||||||||||||||||||||||
| 112 | L<WebService::PayPal::PaymentsAdvanced::Response::FromSilentPost>, | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | Olaf Alders <olaf@wundercounter.com> | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | This software is copyright (c) 2022 by MaxMind, Inc. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 127 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | __END__ | ||||||||||||||||||||||||||||