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