File Coverage

lib/Net/API/Stripe/Mandate.pm
Criterion Covered Total %
statement 19 29 65.5
branch n/a
condition n/a
subroutine 7 17 41.1
pod 9 10 90.0
total 35 56 62.5


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/usr/local/src/perl/Net-API-Stripe/lib/Net/API/Stripe/Mandate.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/12/25
7             ## Modified 2020/11/28
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             package Net::API::Stripe::Mandate;
14             BEGIN
15             {
16 2     2   21155600 use strict;
  2         13  
  2         62  
17 2     2   12 use warnings;
  2         4  
  2         65  
18 2     2   11 use parent qw( Net::API::Stripe::Generic );
  2         5  
  2         12  
19 2     2   139 use vars qw( $VERSION );
  2         4  
  2         129  
20 2     2   43 our( $VERSION ) = 'v0.101.0';
21             };
22              
23 2     2   12 use strict;
  2         4  
  2         49  
24 2     2   11 use warnings;
  2         5  
  2         594  
25              
26 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
27              
28 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
29              
30 0     0 1   sub customer_acceptance { return( shift->_set_get_class( 'customer_acceptance',
31             {
32             accepted_at => { type => "datetime" },
33             offline => { type => "hash" },
34             online => {
35             definition => {
36             ip_address => { type => "scalar" },
37             user_agent => { type => "scalar" },
38             },
39             type => "class",
40             },
41             type => { type => "scalar" },
42             }, @_ ) ); }
43              
44 0     0 0   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
45              
46             # NOTE: multi_use needs to be an object, so we make it a dynamic class even though it has no properties as of 2022-08-10
47 0     0 1   sub multi_use { return( shift->_set_get_class( 'multi_use', {}, @_ ) ); }
48              
49 0     0 1   sub payment_method { return( shift->_set_get_scalar_or_object( 'payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); }
50              
51 0     0 1   sub payment_method_details { return( shift->_set_get_object( 'payment_method_details', 'Net::API::Stripe::Payment::Method', @_ ) ); }
52              
53             sub single_use
54             {
55 0     0 1   return( shift->_set_get_class( 'single_use',
56             {
57             amount => { type => 'number' },
58             currency => { type => 'scalar' },
59             }, @_ )
60             );
61             }
62              
63 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
64              
65 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
66              
67             1;
68              
69             __END__
70              
71             =encoding utf8
72              
73             =head1 NAME
74              
75             Net::API::Stripe::Mandate - A Stripe Mandate Object
76              
77             =head1 SYNOPSIS
78              
79             my $mandate = $stripe->mandate({
80             customer_acceptance =>
81             {
82             accepted_at => '2020-04-12T07:30:45',
83             offline => {},
84             online => {},
85             type => 'online',
86             },
87             payment_method => $payment_method_object,
88             single_use =>
89             {
90             amount => 2000,
91             currency => 'jpy',
92             },
93             status => 'active',
94             type => 'mandate',
95             });
96              
97             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
98              
99             =head1 VERSION
100              
101             v0.101.0
102              
103             =head1 DESCRIPTION
104              
105             A Mandate is a record of the permission a customer has given you to debit their payment method.
106              
107             =head1 CONSTRUCTOR
108              
109             =head2 new( %ARG )
110              
111             Creates a new L<Net::API::Stripe::Mandate> object.
112             It may also take an hash like arguments, that also are method of the same name.
113              
114             =head1 METHODS
115              
116             =head2 id string
117              
118             Unique identifier for the object.
119              
120             =head2 object string, value is "mandate"
121              
122             String representing the object’s type. Objects of the same type share the same value.
123              
124             =head2 customer_acceptance hash
125              
126             Details about the customer's acceptance of the mandate.
127              
128             It has the following properties:
129              
130             =over 4
131              
132             =item I<accepted_at> timestamp
133              
134             The time at which the customer accepted the Mandate.
135              
136             =item I<offline> hash
137              
138             If this is a Mandate accepted offline, this hash contains details about the offline acceptance.
139              
140             =over 8
141              
142             =item I<offline>
143              
144             This is an empty hash.
145              
146             =back
147              
148             =item I<online> hash
149              
150             If this is a Mandate accepted online, this hash contains details about the online acceptance.
151              
152             =over 8
153              
154             =item I<ip_address> string
155              
156             The IP address from which the Mandate was accepted by the customer.
157              
158             =item I<user_agent> string
159              
160             The user agent of the browser from which the Mandate was accepted by the customer.
161              
162             =back
163              
164             =item I<type> string
165              
166             The type of customer acceptance information included with the Mandate. One of C<online> or C<offline>.
167              
168             =back
169              
170             head2 livemode boolean
171              
172             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
173              
174             =head2 multi_use hash
175              
176             If this is a multi_use mandate, this hash contains details about the mandate.
177              
178             =head2 payment_method string expandable
179              
180             ID of the payment method associated with this mandate.
181              
182             =head2 payment_method_details object
183              
184             Additional mandate information specific to the payment method type.
185              
186             This is a L<Net::API::Stripe::Payment::Method> object.
187              
188             =head2 single_use hash
189              
190             If this is a single_use mandate, this hash contains details about the mandate.
191              
192             =over 4
193              
194             =item I<amount> integer
195              
196             On a single use mandate, the amount of the payment.
197              
198             =item I<currency> currency
199              
200             On a single use mandate, the currency of the payment.
201              
202             =back
203              
204             =head2 status string
205              
206             The status of the Mandate, one of active, inactive, or pending. The Mandate can be used to initiate a payment only if status=active.
207              
208             =head2 type string
209              
210             The type of the mandate, one of multi_use or single_use
211              
212             =head1 API SAMPLE
213              
214             {
215             "id": "mandate_123456789",
216             "object": "mandate",
217             "customer_acceptance": {
218             "accepted_at": 123456789,
219             "online": {
220             "ip_address": "127.0.0.0",
221             "user_agent": "device"
222             },
223             "type": "online"
224             },
225             "livemode": false,
226             "multi_use": {},
227             "payment_method": "pm_123456789",
228             "payment_method_details": {
229             "sepa_debit": {
230             "reference": "123456789",
231             "url": ""
232             },
233             "type": "sepa_debit"
234             },
235             "status": "active",
236             "type": "multi_use"
237             }
238              
239             =head1 HISTORY
240              
241             =head2 v0.1
242              
243             Initial version
244              
245             =head1 AUTHOR
246              
247             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
248              
249             =head1 SEE ALSO
250              
251             Stripe API documentation:
252              
253             L<https://stripe.com/docs/api>, L<https://stripe.com/docs/api/mandates/object>
254              
255             =head1 COPYRIGHT & LICENSE
256              
257             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
258              
259             You can use, copy, modify and redistribute this package and associated
260             files under the same terms as Perl itself.
261              
262             =cut