| 1 | package WebService::PayPal::PaymentsAdvanced::Response::FromSilentPOST; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION = '0.000028'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Const::Fast qw( const ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use List::AllUtils qw( any ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use MooX::StrictConstructor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Net::Works::Address (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Net::Works::Network (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use Types::Common::String qw( NonEmptyStr ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Types::Standard qw( ArrayRef Bool ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use Type::Utils qw( class_type ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use WebService::PayPal::PaymentsAdvanced::Error::IPVerification (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | extends 'WebService::PayPal::PaymentsAdvanced::Response'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 34 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 34 | ▶ | my $ip_str = $self->_has_ip_address ? $self->_ip_address->as_string : q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | return | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 34 | ▶ | if !$self->_has_ip_address | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $self->_has_ip_address or $self->_has_ip_address and $self->_ip_address_is_verified
$self->_has_ip_address and $self->_ip_address_is_verified
MC/DC66%2/3
not $self->_has_ip_address or $self->_has_ip_address and $self->_ip_address_is_verified
not $self->_has_ip_address
$self->_has_ip_address
$self->_ip_address_is_verified
Truth table75%3/4
not(A) or B and C
A= not $self->_has_ip_addressB= $self->_has_ip_addressC= $self->_ip_address_is_verified
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | || $self->_has_ip_address && $self->_ip_address_is_verified; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | WebService::PayPal::PaymentsAdvanced::Error::IPVerification->throw( | |||||||||||||||||||||||||||||||||||||||||
| 31 | message => $ip_str . ' is not a verified PayPal address', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ip_address => $ip_str, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | params => $self->params, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | my $Address | |||||||||||||||||||||||||||||||||||||||||
| 39 | = class_type( { class => 'Net::Works::Address' } )->plus_coercions( | ||||||||||||||||||||||||||||||||||||||||||
| 40 | NonEmptyStr, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | sub { Net::Works::Address->new_from_string( string => $_ ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | has _ip_address => ( | |||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | isa => $Address, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | init_arg => 'ip_address', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | predicate => '_has_ip_address', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | has _ip_address_is_verified => ( | |||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | builder => '_build_ip_address_is_verified', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | with( | |||||||||||||||||||||||||||||||||||||||||
| 63 | 'WebService::PayPal::PaymentsAdvanced::Role::HasTender', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 'WebService::PayPal::PaymentsAdvanced::Role::HasTokens', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 'WebService::PayPal::PaymentsAdvanced::Role::HasTransactionTime', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | # Payments Advanced IPs listed at | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # https://www.paypal.com/us/selfhelp/article/what-are-the-ip-addresses-for-payflow-servers-ts1465/1 | ||||||||||||||||||||||||||||||||||||||||||
| 70 | const my @ALLOWED_NETWORKS => | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | map { Net::Works::Network->new_from_string( string => $_ ) } | |||||||||||||||||||||||||||||||||||||||||
| 72 | ( '66.211.170.66/32', '173.0.81.0/24' ); | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | sub _build_ip_address_is_verified { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_ip_address_is_verified: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | return any { $_->contains( $self->_ip_address ) } @ALLOWED_NETWORKS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | WebService::PayPal::PaymentsAdvanced::Response::FromSilentPOST - Response object generated via Silent POST params | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | version 0.000028 | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | This module provides an interface for extracting returned params from an | ||||||||||||||||||||||||||||||||||||||||||
| 97 | L<HTTP::Response> object. You won't need to this module directly if you are | ||||||||||||||||||||||||||||||||||||||||||
| 98 | using L<PayPal::PaymentsAdvanced/get_response_from_silent_post>. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | This module inherits from L<WebService::PayPal::PaymentsAdvanced::Response> and | ||||||||||||||||||||||||||||||||||||||||||
| 101 | includes the methods provided by | ||||||||||||||||||||||||||||||||||||||||||
| 102 | L<WebService::PayPal::PaymentsAdvanced::Role::HasTender>, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | L<WebService::PayPal::PaymentsAdvanced::Role::HasTokens> and | ||||||||||||||||||||||||||||||||||||||||||
| 104 | L<WebService::PayPal::PaymentsAdvanced::Role::HasTransactionTime>. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =head1 OBJECT INSTANTIATION | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | The following parameters can be supplied to C<new()> when creating a new object. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | =head2 Required Parameters | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =head3 params | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Returns a C<HashRef> of parameters which have been returned from PayPal via a | ||||||||||||||||||||||||||||||||||||||||||
| 115 | redirect or a silent POST. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =head2 Optional Parameters | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =head3 ip_address | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | This is the IP address from which the PayPal params have been returned. If | ||||||||||||||||||||||||||||||||||||||||||
| 122 | you provide an IP address, it will be validated against a list of known valid | ||||||||||||||||||||||||||||||||||||||||||
| 123 | IP addresses which have been provided by PayPal. You are encouraged to | ||||||||||||||||||||||||||||||||||||||||||
| 124 | provide an IP in order to prevent spoofing. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | This module will throw a | ||||||||||||||||||||||||||||||||||||||||||
| 127 | L<WebService::PayPal::PaymentsAdvanced::Error::IPVerification> exception if | ||||||||||||||||||||||||||||||||||||||||||
| 128 | the provided IP address cannot be validated. | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | Olaf Alders <olaf@wundercounter.com> | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | This software is copyright (c) 2022 by MaxMind, Inc. | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 143 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | __END__ | ||||||||||||||||||||||||||||||||||||||||||