line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::CPI::Gateway::PayPal::IPN; |
2
|
|
|
|
|
|
|
# ABSTRACT: Instant Payment Notifications |
3
|
1
|
|
|
1
|
|
16851
|
use Moo; |
|
1
|
|
|
|
|
11391
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
1714
|
use LWP::UserAgent (); |
|
1
|
|
|
|
|
89113
|
|
|
1
|
|
|
|
|
361
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.905'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has is_valid => ( |
9
|
|
|
|
|
|
|
is => 'lazy', |
10
|
|
|
|
|
|
|
default => sub { |
11
|
|
|
|
|
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
for ($self->response->decoded_content) { |
14
|
|
|
|
|
|
|
return 0 if /^INVALID$/; |
15
|
|
|
|
|
|
|
return 1 if /^VERIFIED$/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
die "Vague response: " . $_; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has vars => ( |
23
|
|
|
|
|
|
|
is => 'lazy', |
24
|
|
|
|
|
|
|
default => sub { |
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
return { map { $_ => $self->query->param($_) } $self->query->param }; |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has gateway_url => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
default => sub { 'https://www.paypal.com/cgi-bin/webscr' }, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has query => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
default => sub { require CGI; CGI->new() }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has user_agent_name => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
default => sub { |
43
|
|
|
|
|
|
|
my $base = 'Business::CPI::Gateway::PayPal'; |
44
|
|
|
|
|
|
|
my $version = __PACKAGE__->VERSION; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $version ? "$base/$version" : $base; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has user_agent => ( |
51
|
|
|
|
|
|
|
is => 'lazy', |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(); |
56
|
|
|
|
|
|
|
$ua->agent( $self->user_agent_name ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return $ua; |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has response => ( |
63
|
|
|
|
|
|
|
is => 'lazy', |
64
|
|
|
|
|
|
|
default => sub { |
65
|
|
|
|
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $ua = $self->user_agent; |
68
|
|
|
|
|
|
|
my %vars = %{ $self->vars }; |
69
|
|
|
|
|
|
|
my $gtw = $self->gateway_url; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$vars{cmd} = "_notify-validate"; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $r = $ua->post( $gtw, \%vars ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
die "Couldn't connect to '$gtw': " . $r->status_line |
76
|
|
|
|
|
|
|
if $r->is_error; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $r; |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |