File Coverage

lib/Net/API/Stripe/Error.pm
Criterion Covered Total %
statement 19 31 61.2
branch n/a
condition n/a
subroutine 7 19 36.8
pod 12 12 100.0
total 38 62 61.2


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