| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::GoCardless::Webhook::Event; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::GoCardless::Webhook::Event |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A class for gocardless webhook events, extends L. |
|
10
|
|
|
|
|
|
|
For more details see the gocardless API documentation specific to webhooks: |
|
11
|
|
|
|
|
|
|
https://developer.gocardless.com/api-reference/#appendix-webhooks |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
584
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
102
|
|
|
16
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
86
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
19
|
use Moo; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
23
|
|
|
19
|
|
|
|
|
|
|
extends 'Business::GoCardless::Resource'; |
|
20
|
|
|
|
|
|
|
with 'Business::GoCardless::Utils'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
1336
|
use Business::GoCardless::Exception; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
112
|
|
|
23
|
4
|
|
|
4
|
|
691
|
use Business::GoCardless::Payment; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
100
|
|
|
24
|
4
|
|
|
4
|
|
22
|
use Business::GoCardless::Subscription; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
94
|
|
|
25
|
4
|
|
|
4
|
|
21
|
use Business::GoCardless::Mandate; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1513
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
id |
|
30
|
|
|
|
|
|
|
created_at |
|
31
|
|
|
|
|
|
|
action |
|
32
|
|
|
|
|
|
|
resource_type |
|
33
|
|
|
|
|
|
|
links |
|
34
|
|
|
|
|
|
|
details |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has [ qw/ |
|
39
|
|
|
|
|
|
|
id |
|
40
|
|
|
|
|
|
|
created_at |
|
41
|
|
|
|
|
|
|
action |
|
42
|
|
|
|
|
|
|
resource_type |
|
43
|
|
|
|
|
|
|
links |
|
44
|
|
|
|
|
|
|
/ ] => ( |
|
45
|
|
|
|
|
|
|
is => 'ro', |
|
46
|
|
|
|
|
|
|
required => 1, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has [ qw/ |
|
50
|
|
|
|
|
|
|
details |
|
51
|
|
|
|
|
|
|
/ ] => ( |
|
52
|
|
|
|
|
|
|
is => 'rw', |
|
53
|
|
|
|
|
|
|
required => 0, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 resources |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns an array of resource objects (Payment, Subscription, etc) that are present |
|
59
|
|
|
|
|
|
|
in the event allowing you to do things with them or update your own data: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
if ( $Event->is_payment ) { |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
foreach my $Payment ( $Event->resources ) { |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
if ( $Event->action eq 'paid_out' ) { |
|
66
|
|
|
|
|
|
|
... |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub resources { |
|
74
|
1
|
|
|
1
|
1
|
902
|
my ( $self ) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
5
|
return if ! $self->resource_type; |
|
77
|
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
3
|
my $mapping = { |
|
79
|
|
|
|
|
|
|
payments => 'payment', |
|
80
|
|
|
|
|
|
|
payouts => 'payout', |
|
81
|
|
|
|
|
|
|
subscriptions => 'subscription', |
|
82
|
|
|
|
|
|
|
mandates => 'mandate', |
|
83
|
|
|
|
|
|
|
}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
3
|
my $resource = $mapping->{ $self->resource_type }; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
50
|
|
|
|
2
|
$resource || Business::GoCardless::Exception->throw({ |
|
88
|
0
|
|
|
|
|
0
|
message => "Unknown resource_type (@{[$self->resource_type]}) in ->resources", |
|
89
|
|
|
|
|
|
|
}); |
|
90
|
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
4
|
my $class_suffix = ucfirst( $resource ); |
|
92
|
1
|
|
|
|
|
2
|
$class_suffix =~ s/_([A-z])/uc($1)/ge; |
|
|
0
|
|
|
|
|
0
|
|
|
93
|
1
|
|
|
|
|
3
|
my $class = "Business::GoCardless::$class_suffix"; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
return $class->new( |
|
96
|
|
|
|
|
|
|
client => $self->client, |
|
97
|
1
|
|
|
|
|
10
|
id => $self->links->{ $resource }, |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 is_payment |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 is_subscription |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 is_payout |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 is_mandate |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 is_refund |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Shortcut methods to get the type of data in the event, and thus the type of |
|
112
|
|
|
|
|
|
|
objects that will be returned by the call to ->resources |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
2
|
|
|
2
|
1
|
411
|
sub is_payment { return shift->resource_type eq 'payments' } |
|
117
|
1
|
|
|
1
|
1
|
5
|
sub is_subscription { return shift->resource_type eq 'subscriptions' } |
|
118
|
1
|
|
|
1
|
1
|
5
|
sub is_payout { return shift->resource_type eq 'payouts' } |
|
119
|
2
|
|
|
2
|
1
|
10
|
sub is_mandate { return shift->resource_type eq 'mandates' } |
|
120
|
1
|
|
|
1
|
1
|
7
|
sub is_refund { return shift->resource_type eq 'refunds' } |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# BACK COMPATIBILITY |
|
123
|
1
|
|
|
1
|
0
|
2
|
sub is_pre_authorization { return shift->is_mandate } |
|
124
|
1
|
|
|
1
|
0
|
3
|
sub is_bill { return shift->is_payment } |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |