File Coverage

blib/lib/Net/API/Stripe/Event.pm
Criterion Covered Total %
statement 7 16 43.7
branch n/a
condition n/a
subroutine 3 12 25.0
pod 9 9 100.0
total 19 37 51.3


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Event.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/events/object
11             package Net::API::Stripe::Event;
12             BEGIN
13             {
14 1     1   820 use strict;
  1         2  
  1         28  
15 1     1   5 use parent qw( Net::API::Stripe::Generic );
  1         1  
  1         5  
16 1     1   195 our( $VERSION ) = 'v0.100.0';
17             };
18              
19 0     0 1   sub id { shift->_set_get_scalar( 'id', @_ ); }
20              
21 0     0 1   sub object { shift->_set_get_scalar( 'object', @_ ); }
22              
23 0     0 1   sub api_version { shift->_set_get_scalar( 'api_version', @_ ); }
24              
25 0     0 1   sub created { shift->_set_get_datetime( 'created', @_ ); }
26              
27 0     0 1   sub data { shift->_set_get_object( 'data', 'Net::API::Stripe::Event::Data', @_ ); }
28              
29 0     0 1   sub livemode { shift->_set_get_boolean( 'livemode', @_ ); }
30              
31 0     0 1   sub pending_webhooks { shift->_set_get_scalar( 'pending_webhooks', @_ ); }
32              
33 0     0 1   sub request { shift->_set_get_object( 'request', 'Net::API::Stripe::Event::Request', @_ ); }
34              
35 0     0 1   sub type { shift->_set_get_scalar( 'type', @_ ); }
36              
37             1;
38              
39             __END__
40              
41             =encoding utf8
42              
43             =head1 NAME
44              
45             Net::API::Stripe::Event - A Stripe Event Object
46              
47             =head1 SYNOPSIS
48              
49             my $evt = $stripe->event({
50             api_version => '2020-03-02',
51             data =>
52             {
53             object => $invoice_object,
54             },
55             livemode => $stripe->false,
56             pending_webhooks => 2,
57             request =>
58             {
59             id => 'req_HwlkQJshckjIsj',
60             idempotency_key => '677A3112-FBAD-4804-BA61-CEF1CC13D155',
61             },
62             type => 'invoice.created',
63             });
64              
65             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
66              
67             =head1 VERSION
68              
69             v0.100.0
70              
71             =head1 DESCRIPTION
72              
73             Events are Stripe's way of letting you know when something interesting happens in your account. When an interesting event occurs, Stripe creates a new Event object. For example, when a charge succeeds, Stripe creates a charge.succeeded event; and when an invoice payment attempt fails, Stripe creates an invoice.payment_failed event. Note that many API requests may cause multiple events to be created. For example, if you create a new subscription for a customer, you will receive both a customer.subscription.created event and a charge.succeeded event.
74              
75             Events occur when the state of another API resource changes. The state of that resource at the time of the change is embedded in the event's data field. For example, a charge.succeeded event will contain a charge, and an invoice.payment_failed event will contain an invoice.
76              
77             As with other API resources, you can use endpoints to L<retrieve an individual event|https://stripe.com/docs/api/events#retrieve_event> or a L<list of events|https://stripe.com/docs/api/events#list_events> from the API. Stripe also have a L<separate webhooks system|http://en.wikipedia.org/wiki/Webhook> for sending the Event objects directly to an endpoint on your server. Webhooks are managed in your L<account settings|https://dashboard.stripe.com/account/webhooks>, and L<Stripe's Using Webhooks|https://stripe.com/docs/webhooks> guide will help you get set up.
78              
79             When using Connect, you can also receive notifications of events that occur in connected accounts. For these events, there will be an additional account attribute in the received Event object.
80              
81             =head1 CONSTRUCTOR
82              
83             =over 4
84              
85             =item B<new>( %ARG )
86              
87             Creates a new L<Net::API::Stripe::Event> object.
88             It may also take an hash like arguments, that also are method of the same name.
89              
90             =back
91              
92             =head1 METHODS
93              
94             =over 4
95              
96             =item B<id> string
97              
98             Unique identifier for the object.
99              
100             =item B<object> string, value is "event"
101              
102             String representing the object’s type. Objects of the same type share the same value.
103              
104             =item B<account> Connect only string
105              
106             The connected account that originated the event.
107              
108             =item B<api_version> string
109              
110             The Stripe API version used to render data. Note: This property is populated only for events on or after October 31, 2014.
111              
112             =item B<created> timestamp
113              
114             Time at which the object was created. Measured in seconds since the Unix epoch.
115              
116             =item B<data> hash
117              
118             Object containing data associated with the event. This is an L<Net::API::Stripe::Event::Data> object
119              
120             =item B<livemode> boolean
121              
122             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
123              
124             =item B<pending_webhooks> positive integer or zero
125              
126             Number of webhooks that have yet to be successfully delivered (i.e., to return a 20x response) to the URLs you’ve specified.
127              
128             =item B<request> hash
129              
130             Information on the API request that instigated the event. This is a L<Net::API::Stripe::Event::Request> object.
131              
132             =item B<type> string
133              
134             Description of the event (e.g., invoice.created or charge.refunded).
135              
136             =back
137              
138             =head1 API SAMPLE
139              
140             {
141             "id": "evt_fake123456789",
142             "object": "event",
143             "api_version": "2017-02-14",
144             "created": 1528914645,
145             "data": {
146             "object": {
147             "object": "balance",
148             "available": [
149             {
150             "currency": "jpy",
151             "amount": 1025751,
152             "source_types": {
153             "card": 1025751
154             }
155             }
156             ],
157             "connect_reserved": [
158             {
159             "currency": "jpy",
160             "amount": 0
161             }
162             ],
163             "livemode": false,
164             "pending": [
165             {
166             "currency": "jpy",
167             "amount": 0,
168             "source_types": {
169             "card": 0
170             }
171             }
172             ]
173             }
174             },
175             "livemode": false,
176             "pending_webhooks": 0,
177             "request": {
178             "id": null,
179             "idempotency_key": null
180             },
181             "type": "balance.available"
182             }
183              
184             =head1 HISTORY
185              
186             =head2 v0.1
187              
188             Initial version
189              
190             =head1 AUTHOR
191              
192             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
193              
194             =head1 SEE ALSO
195              
196             Stripe API documentation:
197              
198             L<https://stripe.com/docs/api/events#events>, L<https://stripe.com/docs/api/events/types>
199              
200             =head1 COPYRIGHT & LICENSE
201              
202             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
203              
204             You can use, copy, modify and redistribute this package and associated
205             files under the same terms as Perl itself.
206              
207             =cut