line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PagSeguro::Status; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
32122
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use WWW::Mechanize; |
5
|
|
|
|
|
|
|
use DateTime; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'mechanize' => ( |
8
|
|
|
|
|
|
|
isa => 'Object', |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
default => sub { WWW::Mechanize->new( agent_alias => 'Windows IE 6' ) } |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PagSeguro::Status - To know informations about PagSeguro payments! |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.01 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use PagSeguro::Status; |
28
|
|
|
|
|
|
|
my $a = PagSeguro::Status->new( |
29
|
|
|
|
|
|
|
paglogin => 'youruser@...', |
30
|
|
|
|
|
|
|
pagpass => 'youpass...' |
31
|
|
|
|
|
|
|
from_date => dd/mm/yyyy |
32
|
|
|
|
|
|
|
to_date => dd/mm/yyyy |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
print $a->fetch_xml #returns a XML; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
If you do not give the argument "from_date" and "to_date" the default is 1 month. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has 'paglogin' => ( is => 'rw', required => 1, isa => 'Str' ); |
41
|
|
|
|
|
|
|
has 'pagpass' => ( is => 'rw', required => 1, isa => 'Str' ); |
42
|
|
|
|
|
|
|
has 'from_date' => ( |
43
|
|
|
|
|
|
|
is => 'rw', |
44
|
|
|
|
|
|
|
isa => 'Str', |
45
|
|
|
|
|
|
|
default => sub { DateTime->now->subtract( months => 1 )->dmy('/') } |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
has 'to_date' => ( |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
isa => 'Str', |
50
|
|
|
|
|
|
|
default => sub { DateTime->now->dmy('/') } |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 login |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Do the login |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub login { |
60
|
|
|
|
|
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
$self->mechanize->get('https://pagseguro.uol.com.br/'); |
62
|
|
|
|
|
|
|
$self->mechanize->submit_form( |
63
|
|
|
|
|
|
|
form_number => 1, |
64
|
|
|
|
|
|
|
fields => { |
65
|
|
|
|
|
|
|
userName => $self->paglogin, |
66
|
|
|
|
|
|
|
password => $self->pagpass, |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 get_days |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Get the information between from_date and to_date. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_days { |
78
|
|
|
|
|
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
$self->mechanize->get( |
80
|
|
|
|
|
|
|
'https://pagseguro.uol.com.br/transaction/search.jhtml'); |
81
|
|
|
|
|
|
|
$self->mechanize->submit_form( |
82
|
|
|
|
|
|
|
form_number => 1, |
83
|
|
|
|
|
|
|
fields => { |
84
|
|
|
|
|
|
|
dateFrom => $self->from_date, |
85
|
|
|
|
|
|
|
dateTo => $self->to_date |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
return 1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 xml_generate |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
To generate the XML |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub xml_generate { |
98
|
|
|
|
|
|
|
my $self = shift; |
99
|
|
|
|
|
|
|
$self->mechanize->get( |
100
|
|
|
|
|
|
|
'https://pagseguro.uol.com.br/transaction/createFile.jhtml?fileType=xml' |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
if ( $self->mechanize->content =~ /ok\|(.+?)\n/ ) { |
103
|
|
|
|
|
|
|
my $xml_name = $1; |
104
|
|
|
|
|
|
|
return $xml_name; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else { |
107
|
|
|
|
|
|
|
die "could not take the xml name"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
before 'fetch_xml' => sub { my $self = shift; $self->login; $self->get_days }; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 fetch_xml |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Fetch the xml, returns a XML :D |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub fetch_xml { |
120
|
|
|
|
|
|
|
my $self = shift; |
121
|
|
|
|
|
|
|
my $xml_name = $self->xml_generate; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# PagSeguro is really sux, maybe have to wait some seconds |
124
|
|
|
|
|
|
|
# to generate de XML |
125
|
|
|
|
|
|
|
sleep 5; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$self->mechanize->get( |
128
|
|
|
|
|
|
|
'https://pagseguro.uol.com.br/transaction/sendFile.jhtml?fileName=' |
129
|
|
|
|
|
|
|
. $xml_name ); |
130
|
|
|
|
|
|
|
return $self->mechanize->content; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Daniel de Oliveira Mantovani, C<< <daniel.oliveira.mantovani at gmail.com> >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 BUGS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-pagseguro-status at rt.cpan.org>, or through |
140
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PagSeguro-Status>. I will be notified, and then you'll |
141
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SUPPORT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
perldoc PagSeguro::Status |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
You can also look for information at: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=PagSeguro-Status> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<http://annocpan.org/dist/PagSeguro-Status> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * CPAN Ratings |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/PagSeguro-Status> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * Search CPAN |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/PagSeguro-Status/> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Copyright 2011 Daniel de Oliveira Mantovani. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
184
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
185
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
666; # PagSeguro is the devil! |