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