line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::GoCardless::PreAuthorization; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::GoCardless::PreAuthorization |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A class for a gocardless pre_authorization, extends L |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
19
|
|
|
19
|
|
1027
|
use strict; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
485
|
|
14
|
19
|
|
|
19
|
|
86
|
use warnings; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
392
|
|
15
|
|
|
|
|
|
|
|
16
|
19
|
|
|
19
|
|
110
|
use Moo; |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
97
|
|
17
|
|
|
|
|
|
|
extends 'Business::GoCardless::Resource'; |
18
|
|
|
|
|
|
|
|
19
|
19
|
|
|
19
|
|
6843
|
use Business::GoCardless::Bill; |
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
6180
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
created_at |
24
|
|
|
|
|
|
|
currency |
25
|
|
|
|
|
|
|
description |
26
|
|
|
|
|
|
|
expires_at |
27
|
|
|
|
|
|
|
id |
28
|
|
|
|
|
|
|
interval_length |
29
|
|
|
|
|
|
|
interval_unit |
30
|
|
|
|
|
|
|
max_amount |
31
|
|
|
|
|
|
|
merchant_id |
32
|
|
|
|
|
|
|
name |
33
|
|
|
|
|
|
|
next_interval_start |
34
|
|
|
|
|
|
|
remaining_amount |
35
|
|
|
|
|
|
|
setup_fee |
36
|
|
|
|
|
|
|
status |
37
|
|
|
|
|
|
|
sub_resource_uris |
38
|
|
|
|
|
|
|
uri |
39
|
|
|
|
|
|
|
user_id |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has [ qw/ |
44
|
|
|
|
|
|
|
created_at |
45
|
|
|
|
|
|
|
currency |
46
|
|
|
|
|
|
|
description |
47
|
|
|
|
|
|
|
expires_at |
48
|
|
|
|
|
|
|
id |
49
|
|
|
|
|
|
|
interval_length |
50
|
|
|
|
|
|
|
interval_unit |
51
|
|
|
|
|
|
|
max_amount |
52
|
|
|
|
|
|
|
merchant_id |
53
|
|
|
|
|
|
|
name |
54
|
|
|
|
|
|
|
next_interval_start |
55
|
|
|
|
|
|
|
remaining_amount |
56
|
|
|
|
|
|
|
setup_fee |
57
|
|
|
|
|
|
|
status |
58
|
|
|
|
|
|
|
sub_resource_uris |
59
|
|
|
|
|
|
|
uri |
60
|
|
|
|
|
|
|
user_id |
61
|
|
|
|
|
|
|
/ ] => ( |
62
|
|
|
|
|
|
|
is => 'rw', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 Operations on a pre_authorization |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
bill |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $Bill = $PreAuthorization->bill; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Creates a new bill, returning a L object. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
cancel |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$PreAuthorization->cancel; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Cancels a pre_authorization. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub bill { |
82
|
2
|
|
|
2
|
0
|
6504
|
my ( $self,%params ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
2
|
100
|
|
|
|
54
|
if ( $self->client->api_version > 1 ) { |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $post_data = { |
87
|
|
|
|
|
|
|
payments => { |
88
|
|
|
|
|
|
|
%params, |
89
|
|
|
|
|
|
|
links => { |
90
|
|
|
|
|
|
|
# $self here will be a RedirectFlow |
91
|
|
|
|
|
|
|
mandate => $self->links->{mandate}, |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
}, |
94
|
1
|
|
|
|
|
18
|
}; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
7
|
my $data = $self->client->api_post( "/payments",$post_data ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return Business::GoCardless::Payment->new( |
99
|
|
|
|
|
|
|
client => $self->client, |
100
|
1
|
|
|
|
|
7
|
%{ $data->{payments} }, |
|
1
|
|
|
|
|
29
|
|
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
17
|
my $data = $self->client->api_post( |
105
|
|
|
|
|
|
|
"/bills", |
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
bill => { |
108
|
|
|
|
|
|
|
pre_authorization_id => $self->id, |
109
|
|
|
|
|
|
|
%params, |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
return Business::GoCardless::Bill->new( |
115
|
|
|
|
|
|
|
client => $self->client, |
116
|
1
|
|
|
|
|
6
|
%{ $data } |
|
1
|
|
|
|
|
23
|
|
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
1
|
0
|
2497
|
sub cancel { shift->_operation( 'cancel','api_put' ); } |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 Status checks on a pre_authorization |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
inactive |
125
|
|
|
|
|
|
|
active |
126
|
|
|
|
|
|
|
cancelled |
127
|
|
|
|
|
|
|
expired |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
if ( $PreAuthorization->active ) { |
130
|
|
|
|
|
|
|
... |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
2
|
|
|
2
|
0
|
4165
|
sub inactive { return shift->status eq 'inactive' } |
136
|
2
|
|
|
2
|
0
|
14
|
sub active { return shift->status eq 'active' } |
137
|
3
|
|
|
3
|
0
|
2519
|
sub cancelled { return shift->status eq 'cancelled' } |
138
|
2
|
|
|
2
|
0
|
13
|
sub expired { return shift->status eq 'expired' } |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Lee Johnson - C |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
145
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation, |
146
|
|
|
|
|
|
|
features, bug fixes, or anything else then please raise an issue / pull request: |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
https://github.com/Humanstate/business-gocardless |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |