File Coverage

lib/Net/API/Stripe/Event.pm
Criterion Covered Total %
statement 19 29 65.5
branch n/a
condition n/a
subroutine 7 17 41.1
pod 10 10 100.0
total 36 56 64.2


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Event.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/11/16
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             ## https://stripe.com/docs/api/events/object
14             BEGIN
15             {
16             use strict;
17 2     2   23861704 use warnings;
  2         14  
  2         61  
18 2     2   9 use parent qw( Net::API::Stripe::Generic );
  2         3  
  2         60  
19 2     2   9 use vars qw( $VERSION );
  2         3  
  2         10  
20 2     2   135 our( $VERSION ) = 'v0.101.0';
  2         4  
  2         105  
21 2     2   36 };
22              
23             use strict;
24 2     2   10 use warnings;
  2         6  
  2         35  
25 2     2   9  
  2         3  
  2         442  
26              
27 0     0 1    
28              
29 0     0 1    
30              
31 0     0 1    
32              
33 0     0 1    
34              
35 0     0 1    
36             1;
37 0     0 1    
38              
39 0     0 1   =encoding utf8
40              
41 0     0 1   =head1 NAME
42              
43 0     0 1   Net::API::Stripe::Event - A Stripe Event Object
44              
45 0     0 1   =head1 SYNOPSIS
46              
47             my $evt = $stripe->event({
48             api_version => '2020-03-02',
49             data =>
50             {
51             object => $invoice_object,
52             },
53             livemode => $stripe->false,
54             pending_webhooks => 2,
55             request =>
56             {
57             id => 'req_HwlkQJshckjIsj',
58             idempotency_key => '677A3112-FBAD-4804-BA61-CEF1CC13D155',
59             },
60             type => 'invoice.created',
61             });
62              
63             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
64              
65             =head1 VERSION
66              
67             v0.101.0
68              
69             =head1 DESCRIPTION
70              
71             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.
72              
73             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.
74              
75             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.
76              
77             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.
78              
79             =head1 CONSTRUCTOR
80              
81             =head2 new( %ARG )
82              
83             Creates a new L<Net::API::Stripe::Event> object.
84             It may also take an hash like arguments, that also are method of the same name.
85              
86             =head1 METHODS
87              
88             =head2 id string
89              
90             Unique identifier for the object.
91              
92             =head2 object string, value is "event"
93              
94             String representing the object’s type. Objects of the same type share the same value.
95              
96             =head2 account Connect only string
97              
98             The connected account that originated the event.
99              
100             =head2 api_version string
101              
102             The Stripe API version used to render data. Note: This property is populated only for events on or after October 31, 2014.
103              
104             =head2 created timestamp
105              
106             Time at which the object was created. Measured in seconds since the Unix epoch.
107              
108             =head2 data hash
109              
110             Object containing data associated with the event. This is an L<Net::API::Stripe::Event::Data> object
111              
112             =head2 livemode boolean
113              
114             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
115              
116             =head2 pending_webhooks positive integer or zero
117              
118             Number of webhooks that have yet to be successfully delivered (i.e., to return a 20x response) to the URLs you’ve specified.
119              
120             =head2 request hash
121              
122             Information on the API request that instigated the event. This is a L<Net::API::Stripe::Event::Request> object.
123              
124             =head2 type string
125              
126             Description of the event (e.g., invoice.created or charge.refunded).
127              
128             =head1 API SAMPLE
129              
130             {
131             "id": "evt_fake123456789",
132             "object": "event",
133             "api_version": "2017-02-14",
134             "created": 1528914645,
135             "data": {
136             "object": {
137             "object": "balance",
138             "available": [
139             {
140             "currency": "jpy",
141             "amount": 1025751,
142             "source_types": {
143             "card": 1025751
144             }
145             }
146             ],
147             "connect_reserved": [
148             {
149             "currency": "jpy",
150             "amount": 0
151             }
152             ],
153             "livemode": false,
154             "pending": [
155             {
156             "currency": "jpy",
157             "amount": 0,
158             "source_types": {
159             "card": 0
160             }
161             }
162             ]
163             }
164             },
165             "livemode": false,
166             "pending_webhooks": 0,
167             "request": {
168             "id": null,
169             "idempotency_key": null
170             },
171             "type": "balance.available"
172             }
173              
174             =head1 HISTORY
175              
176             =head2 v0.1
177              
178             Initial version
179              
180             =head1 AUTHOR
181              
182             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
183              
184             =head1 SEE ALSO
185              
186             Stripe API documentation:
187              
188             L<https://stripe.com/docs/api/events#events>, L<https://stripe.com/docs/api/events/types>
189              
190             =head1 COPYRIGHT & LICENSE
191              
192             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
193              
194             You can use, copy, modify and redistribute this package and associated
195             files under the same terms as Perl itself.
196              
197             =cut