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   53 use Moo;
  6         17  
  6         52  
4              
5 6     6   2041 use namespace::autoclean;
  6         19  
  6         58  
6              
7             our $VERSION = '0.000026';
8              
9             extends 'Throwable::Error';
10              
11 6     6   614 use Types::Common::String qw( NonEmptyStr );
  6         21  
  6         44  
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             =head1 NAME
30              
31             WebService::PayPal::PaymentsAdvanced::Error::IPVerification - A Payments Advanced IP verification error
32              
33             =head1 VERSION
34              
35             version 0.000026
36              
37             =head1 SYNOPSIS
38              
39             use Try::Tiny;
40             use WebService::PayPal::PaymentsAdvanced;
41              
42             my $payments = WebService::PayPal::PaymentsAdvanced->new(...);
43              
44             my $redirect_response;
45              
46             my $uri;
47             try {
48             $redirect_response = $payments->get_response_from_redirect(
49             ip_address => $ip,
50             params => $params,
51             );
52             }
53             catch {
54             die $_ unless blessed $_;
55             if (
56             $_->isa(
57             'WebService::PayPal::PaymentsAdvanced::Error::IPVerification')
58             ) {
59             log_fraud(
60             message => $_->message,
61             fraudster_ip_address => $_->ip_address,
62             );
63             }
64              
65             # handle other exceptions
66             };
67              
68             =head1 DESCRIPTION
69              
70             This class represents an error in validating the ip_address which has posted
71             back a PayPal return or silent POST url. It will only occur if you provide an
72             IP address to the
73             L<WebService::PayPal::PaymentsAdvanced/get_response_from_redirect> or
74             L<WebService::PayPal::PaymentsAdvanced/get_response_from_silent_post>
75              
76             It extends L<Throwable::Error> and adds two attributes of its own. The message
77             attribute (inherited from L<Throwable::Error>) will contain the error message
78             which was parsed out of the content of the HTML.
79              
80             =head1 METHODS
81              
82             The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are
83             inherited from L<Throwable::Error>.
84              
85             =head2 ip_address
86              
87             Returns the IP address of the request which was made to your application.
88              
89             =head2 params
90              
91             Returns a C<HashRef> of params which was received from to PayPal.
92              
93             =head1 AUTHOR
94              
95             Olaf Alders <olaf@wundercounter.com>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2020 by MaxMind, Inc.
100              
101             This is free software; you can redistribute it and/or modify it under
102             the same terms as the Perl 5 programming language system itself.
103              
104             =cut