line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## A Stripe WebHook Implementation - ~/lib/Net/API/Stripe/WebHook.pm |
3
|
|
|
|
|
|
|
## Version v0.100.1 |
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2019/11/02 |
7
|
|
|
|
|
|
|
## Modified 2020/05/27 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
package Net::API::Stripe::WebHook; |
11
|
|
|
|
|
|
|
BEGIN |
12
|
|
|
|
|
|
|
{ |
13
|
1
|
|
|
1
|
|
1021
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
15
|
1
|
|
|
1
|
|
5
|
use parent qw( Net::API::Stripe::Generic ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
16
|
1
|
|
|
1
|
|
69
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
51
|
|
17
|
1
|
|
|
1
|
|
36
|
our( $VERSION ) = 'v0.100.1'; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
21
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
35
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Creating a web hook |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
# NOTE: POD |
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=encoding utf8 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Net::API::Stripe::WebHook - An interface to manage and handle Stripe WebHooks |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 VERSION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
v0.100.1 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Create a webhook: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
curl https://api.stripe.com/v1/webhook_endpoints \ |
44
|
|
|
|
|
|
|
-u sk_test_khaffUjkDalUfkLhWD: \ |
45
|
|
|
|
|
|
|
-d url="https://example.com/my/webhook/endpoint" \ |
46
|
|
|
|
|
|
|
-d "enabled_events[]=charge.failed" \ |
47
|
|
|
|
|
|
|
-d "enabled_events[]=charge.succeeded" |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
See L<Net::API::Stripe::WebHook::Apache> for detail of implementation using Apache with mod_perl and L<Net::API::Stripe::WebHook::Object> for the Stripe WebHook object. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 API SAMPLE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
"id": "we_fake123456789", |
55
|
|
|
|
|
|
|
"object": "webhook_endpoint", |
56
|
|
|
|
|
|
|
"api_version": "2017-02-14", |
57
|
|
|
|
|
|
|
"application": null, |
58
|
|
|
|
|
|
|
"created": 1542006805, |
59
|
|
|
|
|
|
|
"enabled_events": [ |
60
|
|
|
|
|
|
|
"invoice.created", |
61
|
|
|
|
|
|
|
"invoice.payment_failed", |
62
|
|
|
|
|
|
|
"invoice.payment_succeeded" |
63
|
|
|
|
|
|
|
], |
64
|
|
|
|
|
|
|
"livemode": false, |
65
|
|
|
|
|
|
|
"status": "enabled", |
66
|
|
|
|
|
|
|
"url": "http://expugno.serveo.net/stripe/invoice" |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Stripe API documentation: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/webhook_endpoints>, |
78
|
|
|
|
|
|
|
L<https://stripe.com/docs/webhooks/configure>, |
79
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/events/types>, |
80
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/webhook_endpoints/list?lang=curl>, |
81
|
|
|
|
|
|
|
L<https://stripe.com/docs/webhooks/signatures>, |
82
|
|
|
|
|
|
|
L<https://stripe.com/docs/webhooks/best-practices#event-handling> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Copyright (c) 2019-2020 DEGUEST Pte. Ltd. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
89
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |