| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::PayPal::PaymentsAdvanced::Response; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 8 |  |  | 8 |  | 2058 | use Moo; | 
|  | 8 |  |  |  |  | 12662 |  | 
|  | 8 |  |  |  |  | 73 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 8 |  |  | 8 |  | 4326 | use namespace::autoclean; | 
|  | 8 |  |  |  |  | 13488 |  | 
|  | 8 |  |  |  |  | 79 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.000028'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 8 |  |  | 8 |  | 2119 | use List::AllUtils qw( any ); | 
|  | 8 |  |  |  |  | 22226 |  | 
|  | 8 |  |  |  |  | 611 |  | 
| 10 | 8 |  |  | 8 |  | 959 | use Types::Common::String qw( NonEmptyStr ); | 
|  | 8 |  |  |  |  | 161765 |  | 
|  | 8 |  |  |  |  | 83 |  | 
| 11 | 8 |  |  | 8 |  | 4462 | use Types::Standard qw( ArrayRef Int Maybe ); | 
|  | 8 |  |  |  |  | 21 |  | 
|  | 8 |  |  |  |  | 56 |  | 
| 12 | 8 |  |  | 8 |  | 11688 | use WebService::PayPal::PaymentsAdvanced::Error::Authentication (); | 
|  | 8 |  |  |  |  | 30 |  | 
|  | 8 |  |  |  |  | 295 |  | 
| 13 | 8 |  |  | 8 |  | 1333 | use WebService::PayPal::PaymentsAdvanced::Error::Generic        (); | 
|  | 8 |  |  |  |  | 23 |  | 
|  | 8 |  |  |  |  | 2368 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | default => sub { shift->params->{PNREF} }, | 
| 26 |  |  |  |  |  |  | ); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # PPREF is only returned if PayPal was the payment processor. | 
| 29 |  |  |  |  |  |  | has ppref => ( | 
| 30 |  |  |  |  |  |  | is      => 'lazy', | 
| 31 |  |  |  |  |  |  | isa     => Maybe [NonEmptyStr], | 
| 32 |  |  |  |  |  |  | default => sub { shift->params->{PPREF} }, | 
| 33 |  |  |  |  |  |  | ); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | with( | 
| 36 |  |  |  |  |  |  | 'WebService::PayPal::PaymentsAdvanced::Role::ClassFor', | 
| 37 |  |  |  |  |  |  | 'WebService::PayPal::PaymentsAdvanced::Role::HasParams', | 
| 38 |  |  |  |  |  |  | 'WebService::PayPal::PaymentsAdvanced::Role::HasMessage', | 
| 39 |  |  |  |  |  |  | ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub BUILD { | 
| 42 | 64 |  |  | 64 | 0 | 153012 | my $self = shift; | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 64 |  |  |  |  | 420 | my $result = $self->params->{RESULT}; | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | return | 
| 47 |  |  |  |  |  |  | if Int()->check($result) | 
| 48 | 64 | 100 | 66 | 65 |  | 363 | && ( any { $result == $_ } @{ $self->_nonfatal_result_codes } ); | 
|  | 65 |  |  |  |  | 897 |  | 
|  | 64 |  |  |  |  | 2861 |  | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 3 | 50 | 33 |  |  | 29 | if ( $result && $result == 1 ) { | 
| 51 | 3 |  |  |  |  | 20 | $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 |  |  |  |  |  |  | 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__ | 
| 132 |  |  |  |  |  |  | #ABSTRACT: Generic response object | 
| 133 |  |  |  |  |  |  |  |