line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Flotum; |
2
|
8
|
|
|
8
|
|
3039
|
use strict; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
166
|
|
3
|
8
|
|
|
8
|
|
127
|
use 5.008_005; |
|
8
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
26
|
use warnings; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
149
|
|
7
|
8
|
|
|
8
|
|
2672
|
use utf8; |
|
8
|
|
|
|
|
47
|
|
|
8
|
|
|
|
|
35
|
|
8
|
8
|
|
|
8
|
|
207
|
use Carp qw/croak confess/; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
337
|
|
9
|
8
|
|
|
8
|
|
3206
|
use Moo; |
|
8
|
|
|
|
|
70558
|
|
|
8
|
|
|
|
|
31
|
|
10
|
8
|
|
|
8
|
|
11107
|
use namespace::clean; |
|
8
|
|
|
|
|
65738
|
|
|
8
|
|
|
|
|
27
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
4063
|
use Net::Flotum::API::Charge; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
217
|
|
13
|
8
|
|
|
8
|
|
2723
|
use Net::Flotum::API::Customer; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
206
|
|
14
|
8
|
|
|
8
|
|
2756
|
use Net::Flotum::API::RequestHandler; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
216
|
|
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
8
|
|
3051
|
use Net::Flotum::Object::Customer; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
4644
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'logger' => ( is => 'ro', builder => '_build_logger', lazy => 1 ); |
19
|
|
|
|
|
|
|
has 'requester' => ( is => 'ro', builder => '_build_requester', lazy => 1 ); |
20
|
|
|
|
|
|
|
has 'merchant_api_key' => ( is => 'rw', required => 1 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'customer_api' => ( is => 'ro', builder => '_build_customer_api', lazy => 1 ); |
23
|
|
|
|
|
|
|
has 'charge_api' => ( is => 'ro', builder => '_build_charge_api', lazy => 1 ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_requester { |
26
|
7
|
|
|
7
|
|
2048
|
Net::Flotum::API::RequestHandler->new; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build_logger { |
30
|
7
|
|
|
7
|
|
4618
|
require Net::Flotum::Logger::Log4perl; |
31
|
7
|
|
|
|
|
29
|
Net::Flotum::Logger::Log4perl->new->logger; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _build_customer_api { |
35
|
7
|
|
|
7
|
|
2160
|
my ($self) = @_; |
36
|
7
|
|
|
|
|
41
|
Net::Flotum::API::Customer->new( flotum => $self, ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _build_charge_api { |
40
|
1
|
|
|
1
|
|
572
|
my ($self) = @_; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
9
|
Net::Flotum::API::Charge->new( flotum => $self ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub load_customer { |
46
|
4
|
|
|
4
|
0
|
7164
|
my ( $self, %opts ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
6
|
my $cus; |
49
|
4
|
100
|
|
|
|
19
|
if ( exists $opts{id} ) { |
|
|
50
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$cus = Net::Flotum::Object::Customer->new( |
51
|
|
|
|
|
|
|
flotum => $self, |
52
|
|
|
|
|
|
|
id => $opts{id} |
53
|
2
|
|
|
|
|
28
|
); |
54
|
2
|
|
|
|
|
1373
|
$cus->_load_from_id; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ( exists $opts{remote_id} ) { |
57
|
2
|
|
|
|
|
54
|
$cus = Net::Flotum::Object::Customer->new( |
58
|
|
|
|
|
|
|
flotum => $self, |
59
|
|
|
|
|
|
|
id => 'this workaround is embarrassed' |
60
|
|
|
|
|
|
|
); |
61
|
2
|
|
|
|
|
92
|
$cus->_load_from_remote_id( $opts{remote_id} ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
0
|
|
|
|
|
0
|
croak 'missing parameter: `remote_id` or `id` is required'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
11
|
return $cus; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new_customer { |
71
|
6
|
|
|
6
|
0
|
10769
|
my ( $self, %opts ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
6
|
|
|
|
|
20
|
my $customer_id = $self->customer_api->exec_new_customer(%opts); |
74
|
|
|
|
|
|
|
|
75
|
6
|
|
|
|
|
86
|
return Net::Flotum::Object::Customer->new( |
76
|
|
|
|
|
|
|
flotum => $self, |
77
|
|
|
|
|
|
|
%$customer_id |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _new_charge { |
82
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
7
|
return $self->charge_api->exec_new_charge(@_); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _payment_charge { |
88
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
25
|
return $self->charge_api->exec_payment_charge(@_); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _capture_charge { |
94
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
81
|
return $self->charge_api->exec_capture_charge(@_); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _refund_charge { |
100
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
25
|
return $self->charge_api->exec_refund_charge(@_); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _get_customer_data { |
106
|
5
|
|
|
5
|
|
13
|
my ( $self, %opts ) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
confess 'missing parameter: `remote_id` or `id` is required' |
109
|
|
|
|
|
|
|
unless ( exists $opts{remote_id} && defined $opts{remote_id} ) |
110
|
5
|
50
|
66
|
|
|
84
|
|| ( exists $opts{id} && defined $opts{id} ); |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
5
|
|
|
|
|
90
|
return $self->customer_api->exec_load_customer(%opts); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _get_customer_session_key { |
117
|
3
|
|
|
3
|
|
8
|
my ( $self, %opts ) = @_; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
confess 'missing parameter: `id` is required' |
120
|
3
|
50
|
33
|
|
|
28
|
unless ( exists $opts{id} && defined $opts{id} ); |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
66
|
return $self->customer_api->exec_get_customer_session(%opts)->{api_key}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _get_list_customer_credit_cards { |
126
|
1
|
|
|
1
|
|
4
|
my ( $self, %opts ) = @_; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
confess 'missing parameter: `id` is required' |
129
|
1
|
50
|
33
|
|
|
11
|
unless ( exists $opts{id} && defined $opts{id} ); |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
45
|
my $arr = $self->customer_api->exec_list_credit_cards(%opts)->{credit_cards}; |
132
|
1
|
50
|
|
|
|
10
|
return wantarray ? @$arr : $arr; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _remove_customer_credit_cards { |
136
|
1
|
|
|
1
|
|
6
|
my ( $self, %opts ) = @_; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
confess 'missing parameter: `id` is required' |
139
|
1
|
50
|
33
|
|
|
11
|
unless ( exists $opts{id} && defined $opts{id} ); |
140
|
|
|
|
|
|
|
confess 'missing parameter: `merchant_customer_id` is required' |
141
|
1
|
50
|
33
|
|
|
6
|
unless ( exists $opts{merchant_customer_id} && defined $opts{merchant_customer_id} ); |
142
|
|
|
|
|
|
|
|
143
|
1
|
|
|
|
|
23
|
my $bool = $self->customer_api->exec_remove_credit_card(%opts); |
144
|
1
|
|
|
|
|
6
|
return $bool; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |