File Coverage

lib/Net/API/Stripe/Refund.pm
Criterion Covered Total %
statement 19 38 50.0
branch n/a
condition n/a
subroutine 7 26 26.9
pod 19 19 100.0
total 45 83 54.2


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Refund.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2022/10/29
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/refunds
11             package Net::API::Stripe::Refund;
12             BEGIN
13             {
14 2     2   21273181 use strict;
  2         15  
  2         67  
15 2     2   10 use warnings;
  2         6  
  2         58  
16 2     2   21 use parent qw( Net::API::Stripe::Generic );
  2         6  
  2         10  
17 2     2   141 use vars qw( $VERSION );
  2         5  
  2         115  
18 2     2   40 our( $VERSION ) = 'v0.101.0';
19             };
20              
21 2     2   12 use strict;
  2         3  
  2         77  
22 2     2   11 use warnings;
  2         4  
  2         1022  
23              
24 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
25              
26 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
27              
28 0     0 1   sub amount { return( shift->_set_get_number( 'amount', @_ ) ); }
29              
30 0     0 1   sub balance_transaction { return( shift->_set_get_scalar_or_object( 'balance_transaction', 'Net::API::Stripe::Balance::Transaction', @_ ) ); }
31              
32 0     0 1   sub charge { return( shift->_set_get_scalar_or_object( 'charge', 'Net::API::Stripe::Charge', @_ ) ); }
33              
34 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
35              
36 0     0 1   sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
37              
38 0     0 1   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
39              
40 0     0 1   sub failure_balance_transaction { return( shift->_set_get_scalar_or_object( 'failure_balance_transaction', 'Net::API::Stripe::Balance::Transaction', @_ ) ); }
41              
42 0     0 1   sub failure_reason { return( shift->_set_get_scalar( 'failure_reason', @_ ) ); }
43              
44 0     0 1   sub instructions_email { return( shift->_set_get_scalar( 'instructions_email', @_ ) ); }
45              
46 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
47              
48 0     0 1   sub next_action { return( shift->_set_get_class( 'next_action',
49             {
50             display_details => {
51             definition => {
52             email_sent => {
53             definition => {
54             email_sent_at => { type => "datetime" },
55             email_sent_to => { type => "scalar" },
56             },
57             type => "class",
58             },
59             expires_at => { type => "datetime" },
60             },
61             type => "class",
62             },
63             type => { type => "scalar" },
64             }, @_ ) ); }
65              
66 0     0 1   sub payment_intent { return( shift->_set_get_scalar_or_object( 'payment_intent', 'Net::API::Stripe::PaymentIntent', @_ ) ); }
67              
68 0     0 1   sub reason { return( shift->_set_get_scalar( 'reason', @_ ) ); }
69              
70 0     0 1   sub receipt_number { return( shift->_set_get_scalar( 'receipt_number', @_ ) ); }
71              
72 0     0 1   sub source_transfer_reversal { return( shift->_set_get_scalar_or_object( 'source_transfer_reversal', 'Net::API::Stripe::Connect::Transfer::Reversal', @_ ) ); }
73              
74 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
75              
76 0     0 1   sub transfer_reversal { return( shift->_set_get_scalar_or_object( 'transfer_reversal', 'Net::API::Stripe::Connect::Transfer::Reversal', @_ ) ); }
77              
78             1;
79              
80             __END__
81              
82             =encoding utf8
83              
84             =head1 NAME
85              
86             Net::API::Stripe::Refund - A Stripe Refund Object
87              
88             =head1 SYNOPSIS
89              
90             my $refund = $stripe->refund({
91             amount => 2000,
92             charge => $charge_object,
93             currency => 'jpy',
94             description => 'Cancelled service order',
95             metadata => { transaction_id => 123, customer_id => 456 },
96             reason => 'requested_by_customer',
97             });
98              
99             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
100              
101             =head1 VERSION
102              
103             v0.101.0
104              
105             =head1 DESCRIPTION
106              
107             Refund objects allow you to refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.
108              
109             =head1 CONSTRUCTOR
110              
111             =head2 new( %ARG )
112              
113             Creates a new L<Net::API::Stripe::Refund> object.
114             It may also take an hash like arguments, that also are method of the same name.
115              
116             =head1 METHODS
117              
118             =head2 id string
119              
120             Unique identifier for the object.
121              
122             =head2 object string, value is "refund"
123              
124             String representing the object’s type. Objects of the same type share the same value.
125              
126             =head2 amount integer
127              
128             Amount, in JPY.
129              
130             =head2 balance_transaction string (expandable)
131              
132             Balance transaction that describes the impact on your account balance.
133              
134             When expanded, this is a L<Net::API::Stripe::Balance::Transaction> object.
135              
136             =head2 charge string (expandable)
137              
138             ID of the charge that was refunded. When expanded, this is a L<Net::API::Stripe::Charge> object.
139              
140             =head2 created timestamp
141              
142             Time at which the object was created. Measured in seconds since the Unix epoch. This is a C<DateTime> object.
143              
144             =head2 currency currency
145              
146             Three-letter ISO currency code, in lowercase. Must be a supported currency.
147              
148             =head2 description string
149              
150             An arbitrary string attached to the object. Often useful for displaying to users. (Available on non-card refunds only)
151              
152             =head2 failure_balance_transaction string (expandable)
153              
154             If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction. This is a L<Net::API::Stripe::Balance::Transaction>
155              
156             =head2 failure_reason string
157              
158             If the refund failed, the reason for refund failure if known. Possible values are lost_or_stolen_card, expired_or_canceled_card, or unknown.
159              
160             =head2 instructions_email string
161              
162             Email to which refund instructions, if required, are sent to.
163              
164             =head2 metadata hash
165              
166             Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
167              
168             =head2 next_action hash
169              
170             If the refund has a status of C<requires_action>, this property will describe what the refund needs in order to continue processing.
171              
172             It has the following properties:
173              
174             =over 4
175              
176             =item C<display_details> hash
177              
178             Contains the refund details.
179              
180             =over 8
181              
182             =item C<email_sent> hash
183              
184             Contains information about the email sent to the customer.
185              
186             =over 12
187              
188             =item C<email_sent_at> timestamp
189              
190             The timestamp when the email was sent.
191              
192             =item C<email_sent_to> string
193              
194             The recipient's email address.
195              
196              
197             =back
198              
199             =item C<expires_at> timestamp
200              
201             The expiry timestamp.
202              
203              
204             =back
205              
206             =item C<type> string
207              
208             Type of the next action to perform.
209              
210             =back
211              
212             =head2 payment_intent expandable
213              
214             ID of the PaymentIntent that was refunded.
215              
216             When expanded this is an L<Net::API::Stripe::PaymentIntent> object.
217              
218             =head2 reason string
219              
220             Reason for the refund. If set, possible values are duplicate, fraudulent, and requested_by_customer.
221              
222             =head2 receipt_number string
223              
224             This is the transaction number that appears on email receipts sent for this refund.
225              
226             =head2 source_transfer_reversal string (expandable)
227              
228             The transfer reversal that is associated with the refund. Only present if the charge came from another Stripe account. See the Connect documentation for details. This is a L<Net::API::Stripe::Connect::Transfer::Reversal>
229              
230             =head2 status string
231              
232             Status of the refund. For credit card refunds, this can be pending, succeeded, or failed. For other types of refunds, it can be pending, succeeded, failed, or canceled. Refer to L<Stripe refunds documentation|https://stripe.com/docs/refunds#failed-refunds> for more details.
233              
234             =head2 transfer_reversal string (expandable)
235              
236             If the accompanying transfer was reversed, the transfer reversal object. Only applicable if the charge was created using the destination parameter. This is a L<Net::API::Stripe::Connect::Transfer::Reversal> object.
237              
238             =head1 API SAMPLE
239              
240             {
241             "id": "re_fake123456789",
242             "object": "refund",
243             "amount": 30200,
244             "balance_transaction": "txn_fake123456789",
245             "charge": "ch_fake123456789",
246             "created": 1540736617,
247             "currency": "jpy",
248             "metadata": {},
249             "reason": null,
250             "receipt_number": null,
251             "source_transfer_reversal": null,
252             "status": "succeeded",
253             "transfer_reversal": null
254             }
255              
256             =head1 HISTORY
257              
258             =head2 v0.1
259              
260             Initial version
261              
262             =head1 AUTHOR
263              
264             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
265              
266             =head1 SEE ALSO
267              
268             Stripe API documentation:
269              
270             L<https://stripe.com/docs/api/refunds>, L<https://stripe.com/docs/refunds>
271              
272             =head1 COPYRIGHT & LICENSE
273              
274             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
275              
276             You can use, copy, modify and redistribute this package and associated
277             files under the same terms as Perl itself.
278              
279             =cut