File Coverage

blib/lib/WebService/PayPal/PaymentsAdvanced/Error/IPVerification.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package WebService::PayPal::PaymentsAdvanced::Error::IPVerification;
2              
3 6     6   54 use Moo;
  6         20  
  6         65  
4              
5 6     6   2393 use namespace::autoclean;
  6         19  
  6         75  
6              
7             our $VERSION = '0.000028';
8              
9             extends 'Throwable::Error';
10              
11 6     6   702 use Types::Common::String qw( NonEmptyStr );
  6         20  
  6         52  
12              
13             has ip_address => (
14             is => 'ro',
15             isa => NonEmptyStr,
16             required => 1,
17             );
18              
19             with 'WebService::PayPal::PaymentsAdvanced::Role::HasParams';
20              
21             1;
22              
23             # ABSTRACT: A Payments Advanced IP verification error
24              
25             __END__
26              
27             =pod
28              
29             =encoding UTF-8
30              
31             =head1 NAME
32              
33             WebService::PayPal::PaymentsAdvanced::Error::IPVerification - A Payments Advanced IP verification error
34              
35             =head1 VERSION
36              
37             version 0.000028
38              
39             =head1 SYNOPSIS
40              
41             use Try::Tiny;
42             use WebService::PayPal::PaymentsAdvanced;
43              
44             my $payments = WebService::PayPal::PaymentsAdvanced->new(...);
45              
46             my $redirect_response;
47              
48             my $uri;
49             try {
50             $redirect_response = $payments->get_response_from_redirect(
51             ip_address => $ip,
52             params => $params,
53             );
54             }
55             catch {
56             die $_ unless blessed $_;
57             if (
58             $_->isa(
59             'WebService::PayPal::PaymentsAdvanced::Error::IPVerification')
60             ) {
61             log_fraud(
62             message => $_->message,
63             fraudster_ip_address => $_->ip_address,
64             );
65             }
66              
67             # handle other exceptions
68             };
69              
70             =head1 DESCRIPTION
71              
72             This class represents an error in validating the ip_address which has posted
73             back a PayPal return or silent POST url. It will only occur if you provide an
74             IP address to the
75             L<WebService::PayPal::PaymentsAdvanced/get_response_from_redirect> or
76             L<WebService::PayPal::PaymentsAdvanced/get_response_from_silent_post>
77              
78             It extends L<Throwable::Error> and adds two attributes of its own. The message
79             attribute (inherited from L<Throwable::Error>) will contain the error message
80             which was parsed out of the content of the HTML.
81              
82             =head1 METHODS
83              
84             The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are
85             inherited from L<Throwable::Error>.
86              
87             =head2 ip_address
88              
89             Returns the IP address of the request which was made to your application.
90              
91             =head2 params
92              
93             Returns a C<HashRef> of params which was received from to PayPal.
94              
95             =head1 SUPPORT
96              
97             Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.
98              
99             =head1 AUTHOR
100              
101             Olaf Alders <olaf@wundercounter.com>
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is copyright (c) 2022 by MaxMind, Inc.
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as the Perl 5 programming language system itself.
109              
110             =cut