line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PagSeguro::API; |
2
|
6
|
|
|
6
|
|
178472
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
277
|
|
3
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
313
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
3752
|
use PagSeguro::API::Checkout; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use PagSeguro::API::Transaction; |
8
|
|
|
|
|
|
|
use PagSeguro::API::Notification; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# constructor |
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my %args = @_ if (@_ % 2) == 0; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# start resource |
16
|
|
|
|
|
|
|
PagSeguro::API::Resource->instance; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# check env vars |
19
|
|
|
|
|
|
|
$args{email} = $ENV{PAGSEGURO_API_EMAIL} || undef |
20
|
|
|
|
|
|
|
unless $args{email}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$args{token} = $ENV{PAGSEGURO_API_TOKEN} || undef |
23
|
|
|
|
|
|
|
unless $args{token}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# enable sandbox |
26
|
|
|
|
|
|
|
$ENV{PAGSEGURO_API_SANDBOX} = $args{sandbox} |
27
|
|
|
|
|
|
|
if $args{sandbox}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# enable debug |
30
|
|
|
|
|
|
|
$ENV{PAGSEGURO_API_DEBUG} = $args{debug} |
31
|
|
|
|
|
|
|
if $args{debug}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return bless { |
34
|
|
|
|
|
|
|
_email => $args{email} || undef, |
35
|
|
|
|
|
|
|
_token => $args{token} || undef, |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
_checkout => undef, |
38
|
|
|
|
|
|
|
_transaction => undef, |
39
|
|
|
|
|
|
|
_notification => undef, |
40
|
|
|
|
|
|
|
}, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# accessors |
44
|
|
|
|
|
|
|
sub email { |
45
|
|
|
|
|
|
|
$_[0]->{_email} = $_[1] if $_[1]; |
46
|
|
|
|
|
|
|
return shift->{_email}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub token { |
50
|
|
|
|
|
|
|
$_[0]->{_token} = $_[1] if $_[1]; |
51
|
|
|
|
|
|
|
return shift->{_token}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# methods |
55
|
|
|
|
|
|
|
sub transaction { |
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# error |
59
|
|
|
|
|
|
|
die "Exception: e-mail or token undef" |
60
|
|
|
|
|
|
|
unless $self->email && $self->token; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# manual instance |
63
|
|
|
|
|
|
|
$self->{_transaction} = $_[0] |
64
|
|
|
|
|
|
|
if $_[0] && $_[0]->isa('PagSeguro::API::Transaction'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$self->{_transaction} = PagSeguro::API::Transaction->new( |
68
|
|
|
|
|
|
|
email => $self->email, token => $self->token |
69
|
|
|
|
|
|
|
) unless $self->{_transaction}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $self->{_transaction}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub notification { |
75
|
|
|
|
|
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# error |
78
|
|
|
|
|
|
|
die "Exception: e-mail or token undef" |
79
|
|
|
|
|
|
|
unless $self->email && $self->token; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# manual instance |
82
|
|
|
|
|
|
|
$self->{_notification} = $_[0] |
83
|
|
|
|
|
|
|
if $_[0] && $_[0]->isa('PagSeguro::API::Notification'); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->{_notification} = PagSeguro::API::Notification->new( |
87
|
|
|
|
|
|
|
email => $self->email, token => $self->token |
88
|
|
|
|
|
|
|
) unless $self->{_notification}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
return $self->{_notification}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub checkout { |
94
|
|
|
|
|
|
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# error |
97
|
|
|
|
|
|
|
die "Exception: e-mail or token undef" |
98
|
|
|
|
|
|
|
unless $self->email && $self->token; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# manual instance |
101
|
|
|
|
|
|
|
$self->{_checkout} = $_[0] |
102
|
|
|
|
|
|
|
if $_[0] && $_[0]->isa('PagSeguro::API::Checkout'); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$self->{_checkout} = PagSeguro::API::Checkout->new( |
106
|
|
|
|
|
|
|
email => $self->email, token => $self->token |
107
|
|
|
|
|
|
|
) unless $self->{_checkout}; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return $self->{_checkout}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
__END__ |