line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::GoCardless; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::GoCardless - Top level namespace for the Business::GoCardless |
6
|
|
|
|
|
|
|
set of modules |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=for html |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
0.37 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Business::GoCardless is a set of libraries for easy interface to the gocardless |
19
|
|
|
|
|
|
|
payment service, they implement most of the functionality currently found |
20
|
|
|
|
|
|
|
in the service's API documentation: https://developer.gocardless.com |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Current missing functionality is partner account handling, but all resource |
23
|
|
|
|
|
|
|
manipulation (Bill, Merchant, Payout etc) is handled along with webhooks and |
24
|
|
|
|
|
|
|
the checking/generation of signature, nonce, param normalisation, and other |
25
|
|
|
|
|
|
|
such lower level interface with the API. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 Do Not Use This Module Directly |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
You should go straight to L and start there. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
19
|
|
|
19
|
|
1812
|
use strict; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
536
|
|
34
|
19
|
|
|
19
|
|
91
|
use warnings; |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
428
|
|
35
|
|
|
|
|
|
|
|
36
|
19
|
|
|
19
|
|
494
|
use Moo; |
|
19
|
|
|
|
|
8922
|
|
|
19
|
|
|
|
|
105
|
|
37
|
19
|
|
|
19
|
|
7634
|
use Carp qw/ confess /; |
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
1097
|
|
38
|
|
|
|
|
|
|
|
39
|
19
|
|
|
19
|
|
475
|
use Business::GoCardless::Client; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
502
|
|
40
|
19
|
|
|
19
|
|
5677
|
use Business::GoCardless::Webhook; |
|
19
|
|
|
|
|
65
|
|
|
19
|
|
|
|
|
17460
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$Business::GoCardless::VERSION = '0.37'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has api_version => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
required => 0, |
47
|
|
|
|
|
|
|
lazy => 1, |
48
|
|
|
|
|
|
|
default => sub { $ENV{GOCARDLESS_API_VERSION} // 1 }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has token => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
required => 1, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has client_details => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => sub { |
59
|
|
|
|
|
|
|
confess( "$_[0] is not a hashref" ) |
60
|
|
|
|
|
|
|
if ref( $_[0] ) ne 'HASH'; |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
required => 0, |
63
|
|
|
|
|
|
|
lazy => 1, |
64
|
|
|
|
|
|
|
default => sub { |
65
|
|
|
|
|
|
|
my ( $self ) = @_; |
66
|
|
|
|
|
|
|
return { |
67
|
|
|
|
|
|
|
api_version => $self->api_version, |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has client => ( |
73
|
|
|
|
|
|
|
is => 'ro', |
74
|
|
|
|
|
|
|
isa => sub { |
75
|
|
|
|
|
|
|
confess( "$_[0] is not a Business::GoCardless::Client" ) |
76
|
|
|
|
|
|
|
if ref $_[0] ne 'Business::GoCardless::Client' |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
required => 0, |
79
|
|
|
|
|
|
|
lazy => 1, |
80
|
|
|
|
|
|
|
default => sub { |
81
|
|
|
|
|
|
|
my ( $self ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return Business::GoCardless::Client->new( |
84
|
|
|
|
|
|
|
%{ $self->client_details }, |
85
|
|
|
|
|
|
|
token => $self->token, |
86
|
|
|
|
|
|
|
api_version => $self->api_version, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
}, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub confirm_resource { |
93
|
4
|
|
|
4
|
0
|
51
|
my ( $self,%params ) = @_; |
94
|
4
|
|
|
|
|
81
|
return $self->client->_confirm_resource( \%params ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub new_bill_url { |
98
|
1
|
|
|
1
|
0
|
903
|
my ( $self,%params ) = @_; |
99
|
1
|
|
|
|
|
19
|
return $self->client->_new_bill_url( \%params ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub bill { |
103
|
2
|
|
|
2
|
0
|
7775
|
my ( $self,$id ) = @_; |
104
|
|
|
|
|
|
|
|
105
|
2
|
100
|
|
|
|
57
|
if ( $self->client->api_version > 1 ) { |
106
|
1
|
|
|
|
|
37
|
return $self->payment( $id ); |
107
|
|
|
|
|
|
|
} else { |
108
|
1
|
|
|
|
|
32
|
return $self->_generic_find_obj( $id,'Bill' ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub bills { |
113
|
4
|
|
|
4
|
0
|
29161
|
my ( $self,%filters ) = @_; |
114
|
|
|
|
|
|
|
|
115
|
4
|
100
|
|
|
|
117
|
if ( $self->client->api_version > 1 ) { |
116
|
2
|
|
|
|
|
76
|
return $self->payments( %filters ); |
117
|
|
|
|
|
|
|
} else { |
118
|
2
|
|
|
|
|
80
|
return $self->merchant( $self->client->merchant_id ) |
119
|
|
|
|
|
|
|
->bills( \%filters ); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub merchant { |
124
|
7
|
|
|
7
|
0
|
915
|
my ( $self,$merchant_id ) = @_; |
125
|
|
|
|
|
|
|
|
126
|
7
|
|
66
|
|
|
41
|
$merchant_id //= $self->client->merchant_id; |
127
|
7
|
|
|
|
|
119
|
return Business::GoCardless::Merchant->new( |
128
|
|
|
|
|
|
|
client => $self->client, |
129
|
|
|
|
|
|
|
id => $merchant_id |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub payouts { |
134
|
1
|
|
|
1
|
0
|
2598
|
my ( $self,%filters ) = @_; |
135
|
1
|
|
|
|
|
23
|
return $self->merchant( $self->client->merchant_id ) |
136
|
|
|
|
|
|
|
->payouts( \%filters ); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub payout { |
140
|
2
|
|
|
2
|
0
|
4331
|
my ( $self,$id ) = @_; |
141
|
2
|
|
|
|
|
10
|
return $self->_generic_find_obj( $id,'Payout' ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub new_pre_authorization_url { |
145
|
1
|
|
|
1
|
0
|
1751
|
my ( $self,%params ) = @_; |
146
|
1
|
|
|
|
|
22
|
return $self->client->_new_pre_authorization_url( \%params ); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub pre_authorization { |
150
|
1
|
|
|
1
|
0
|
5431
|
my ( $self,$id ) = @_; |
151
|
1
|
|
|
|
|
4
|
return $self->_generic_find_obj( $id,'PreAuthorization' ); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub pre_authorizations { |
155
|
1
|
|
|
1
|
0
|
1698
|
my ( $self,%filters ) = @_; |
156
|
1
|
|
|
|
|
21
|
return $self->merchant( $self->client->merchant_id ) |
157
|
|
|
|
|
|
|
->pre_authorizations( \%filters ); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub new_subscription_url { |
161
|
1
|
|
|
1
|
0
|
709
|
my ( $self,%params ) = @_; |
162
|
1
|
|
|
|
|
23
|
return $self->client->_new_subscription_url( \%params ); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub subscription { |
166
|
1
|
|
|
1
|
0
|
5424
|
my ( $self,$id ) = @_; |
167
|
1
|
|
|
|
|
4
|
return $self->_generic_find_obj( $id,'Subscription' ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub subscriptions { |
171
|
1
|
|
|
1
|
0
|
2536
|
my ( $self,%filters ) = @_; |
172
|
1
|
|
|
|
|
22
|
return $self->merchant( $self->client->merchant_id ) |
173
|
|
|
|
|
|
|
->subscriptions( \%filters ); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub users { |
177
|
1
|
|
|
1
|
0
|
726
|
my ( $self,%filters ) = @_; |
178
|
1
|
|
|
|
|
22
|
return $self->merchant( $self->client->merchant_id ) |
179
|
|
|
|
|
|
|
->users( \%filters ); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub webhook { |
183
|
2
|
|
|
2
|
0
|
4151
|
my ( $self,$data ) = @_; |
184
|
|
|
|
|
|
|
|
185
|
2
|
|
|
|
|
42
|
return Business::GoCardless::Webhook->new( |
186
|
|
|
|
|
|
|
client => $self->client, |
187
|
|
|
|
|
|
|
json => $data, |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub _generic_find_obj { |
192
|
9
|
|
|
9
|
|
34
|
my ( $self,$id,$class,$sub_key ) = @_; |
193
|
9
|
|
|
|
|
31
|
$class = "Business::GoCardless::$class"; |
194
|
9
|
|
|
|
|
248
|
my $obj = $class->new( |
195
|
|
|
|
|
|
|
id => $id, |
196
|
|
|
|
|
|
|
client => $self->client |
197
|
|
|
|
|
|
|
); |
198
|
9
|
|
|
|
|
141
|
return $obj->find_with_client( $sub_key ); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SEE ALSO |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Lee Johnson - C |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
grifferz - C |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 LICENSE |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
216
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation, |
217
|
|
|
|
|
|
|
features, bug fixes, or anything else then please raise an issue / pull request: |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
https://github.com/Humanstate/business-gocardless |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |