File Coverage

blib/lib/Net/API/Stripe/Error.pm
Criterion Covered Total %
statement 7 18 38.8
branch n/a
condition n/a
subroutine 3 14 21.4
pod 11 11 100.0
total 21 43 48.8


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Error.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             package Net::API::Stripe::Error;
11             BEGIN
12             {
13 1     1   834 use strict;
  1         2  
  1         29  
14 1     1   4 use parent qw( Net::API::Stripe::Generic );
  1         2  
  1         5  
15 1     1   234 our( $VERSION ) = 'v0.100.0';
16             };
17              
18 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
19              
20 0     0 1   sub charge { return( shift->_set_get_scalar( 'charge', @_ ) ); }
21              
22 0     0 1   sub code { return( shift->_set_get_scalar( 'code', @_ ) ); }
23              
24 0     0 1   sub decline_code { return( shift->_set_get_scalar( 'decline_code', @_ ) ); }
25              
26 0     0 1   sub doc_url { return( shift->_set_get_uri( 'doc_url', @_ ) ); }
27              
28 0     0 1   sub message { return( shift->_set_get_scalar( 'message', @_ ) ); }
29              
30 0     0 1   sub param { return( shift->_set_get_scalar( 'param', @_ ) ); }
31              
32 0     0 1   sub payment_intent { return( shift->_set_get_object( 'payment_intent', 'Net::API::Stripe::Payment::Intent', @_ ) ); }
33              
34 0     0 1   sub payment_method { return( shift->_set_get_object( 'payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); }
35              
36 0     0 1   sub setup_intent { return( shift->_set_get_object( 'setup_intent', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); }
37              
38 0     0 1   sub source { return( shift->_set_get_object( 'source', 'Net::API::Stripe::Payment::Source', @_ ) ); }
39              
40             1;
41              
42             __END__
43              
44             =encoding utf8
45              
46             =head1 NAME
47              
48             Net::API::Stripe::Error - A Stripe Error Object
49              
50             =head1 SYNOPSIS
51              
52             my $err = $stripe->payment_intent->last_payment_error({
53             type => 'card_error',
54             charge => 'ch_fake1234567890',
55             code => 402,
56             doc_url => 'https://stripe.com/docs/api/errors',
57             message => 'Some human readable message',
58             payment_intent => $payment_intent_object,
59             source => $source_object,
60             });
61              
62             =head1 VERSION
63              
64             v0.100.0
65              
66             =head1 DESCRIPTION
67              
68             This is a Stripe Error object instantiated by method B<last_setup_error> in module L<Net::API::Stripe::Payment::Intent::Setup>, and method B<last_payment_error> in module L<Net::API::Stripe::Payment::Intent>
69              
70             This is different from the error generated elsewhere in L<Net::API::Stripe>
71              
72             =head1 CONSTRUCTOR
73              
74             =over 4
75              
76             =item B<new>( %ARG )
77              
78             Creates a new L<Net::API::Stripe::Error> object.
79             It may also take an hash like arguments, that also are method of the same name.
80              
81             =back
82              
83             =head1 METHODS
84              
85             =over 4
86              
87             =item B<type> string
88              
89             The type of error returned. One of api_connection_error, api_error, authentication_error, card_error, idempotency_error, invalid_request_error, or rate_limit_error
90              
91             =item B<charge> string
92              
93             For card errors, the ID of the failed charge. Not always present. Exists in L<Net::API::Stripe::Payment::Intent>, but not in L<Net::API::Stripe::Payment::Intent::Setup>
94              
95             =item B<code> string
96              
97             For some errors that could be handled programmatically, a short string indicating the error code reported.
98              
99             =item B<decline_code> string
100              
101             For card errors resulting from a card issuer decline, a short string indicating the card issuer’s reason for the decline if they provide one.
102              
103             =item B<doc_url> string
104              
105             A URL to more information about the error code reported. This is a C<URI> object.
106              
107             =item B<message> string
108              
109             A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.
110              
111             =item B<param> string
112              
113             If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.
114              
115             =item B<payment_intent> hash
116              
117             The PaymentIntent object for errors returned on a request involving a PaymentIntent.
118              
119             When set, this is a L<Net::API::Stripe::Payment::Intent> object.
120              
121             =item B<payment_method> hash
122              
123             The PaymentMethod object for errors returned on a request involving a PaymentMethod.
124              
125             When set, this is a L<Net::API::Stripe::Payment::Method> object.
126              
127             =item B<setup_intent> hash
128              
129             The SetupIntent object for errors returned on a request involving a SetupIntent.
130              
131             When set, this is a L<Net::API::Stripe::Payment::Intent::Setup> object.
132              
133             =item B<source> hash
134              
135             The source object for errors returned on a request involving a source.
136              
137             When set this is a L<Net::API::Stripe::Payment::Source> object.
138              
139             =back
140              
141             =head1 HISTORY
142              
143             =head2 v0.100.0
144              
145             Initial version
146              
147             =head1 AUTHOR
148              
149             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
150              
151             =head1 SEE ALSO
152              
153             Stripe API documentation:
154              
155             L<https://stripe.com/docs/api/errors>
156              
157             =head1 COPYRIGHT & LICENSE
158              
159             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
160              
161             You can use, copy, modify and redistribute this package and associated
162             files under the same terms as Perl itself.
163              
164             =cut
165