File Coverage

blib/lib/Net/Stripe.pm
Criterion Covered Total %
statement 1820 4857 37.4
branch 38 2550 1.4
condition 12 547 2.1
subroutine 589 667 88.3
pod 1 2 50.0
total 2460 8623 28.5


line stmt bran cond sub pod time code
1             package Net::Stripe;
2             $Net::Stripe::VERSION = '0.43';
3 2     2   828543 use Moose;
  2         1191545  
  2         20  
4 2     2   16215 use Class::Load;
  2         5  
  2         132  
5 2     2   2256 use Type::Tiny 1.008004;
  2         73334  
  2         120  
6 2     2   1508 use Kavorka;
  2         26362  
  2         27  
7 2     2   536080 use LWP::UserAgent;
  2         147767  
  2         129  
8 2     2   1219 use HTTP::Request::Common qw/GET POST DELETE/;
  2         6663  
  2         214  
9 2     2   1016 use MIME::Base64 qw/encode_base64/;
  2         1834  
  2         161  
10 2     2   24 use URI::Escape qw/uri_escape/;
  2         4  
  2         147  
11 2     2   1694 use JSON qw/decode_json/;
  2         23495  
  2         12  
12 2     2   382 use URI 5.19 qw//;
  2         36  
  2         56  
13 2     2   1724 use DateTime qw//;
  2         674786  
  2         94  
14 2     2   1182 use Net::Stripe::TypeConstraints;
  2         12  
  2         118  
15 2     2   1260 use Net::Stripe::Constants;
  2         35  
  2         72  
16 2     2   1018 use Net::Stripe::Token;
  2         9  
  2         174  
17 2     2   1294 use Net::Stripe::Invoiceitem;
  2         13  
  2         111  
18 2     2   1256 use Net::Stripe::Invoice;
  2         14  
  2         157  
19 2     2   1506 use Net::Stripe::Card;
  2         8  
  2         131  
20 2     2   988 use Net::Stripe::Source;
  2         12  
  2         121  
21 2     2   1277 use Net::Stripe::Plan;
  2         13  
  2         111  
22 2     2   1293 use Net::Stripe::Product;
  2         17  
  2         143  
23 2     2   1379 use Net::Stripe::Coupon;
  2         12  
  2         116  
24 2     2   1319 use Net::Stripe::Charge;
  2         12  
  2         117  
25 2     2   1206 use Net::Stripe::Customer;
  2         14  
  2         136  
26 2     2   20 use Net::Stripe::Discount;
  2         4  
  2         61  
27 2     2   1383 use Net::Stripe::Subscription;
  2         9  
  2         94  
28 2     2   971 use Net::Stripe::Error;
  2         32  
  2         120  
29 2     2   1032 use Net::Stripe::BalanceTransaction;
  2         13  
  2         136  
30 2     2   22 use Net::Stripe::List;
  2         5  
  2         113  
31 2     2   1385 use Net::Stripe::LineItem;
  2         8  
  2         161  
32 2     2   930 use Net::Stripe::Refund;
  2         12  
  2         118  
33 2     2   1215 use Net::Stripe::PaymentMethod;
  2         10  
  2         121  
34 2     2   1310 use Net::Stripe::PaymentIntent;
  2         13  
  2         538  
35              
36             # ABSTRACT: API client for Stripe.com
37              
38              
39             has 'debug' => (is => 'rw', isa => 'Bool', default => 0, documentation => "The debug flag");
40             has 'debug_network' => (is => 'rw', isa => 'Bool', default => 0, documentation => "The debug network request flag");
41             has 'api_key' => (is => 'ro', isa => 'Str', required => 1, documentation => "You get this from your Stripe Account settings");
42             has 'api_base' => (is => 'ro', isa => 'Str', lazy_build => 1, documentation => "This is the base part of the URL for every request made");
43             has 'ua' => (is => 'ro', isa => 'Object', lazy_build => 1, documentation => "The LWP::UserAgent that is used for requests");
44             has 'api_version' => (is => 'ro', isa => 'StripeAPIVersion', documentation => "This is the value of the Stripe-Version header you wish to transmit for API calls");
45             has 'force_api_version' => (is => 'ro', isa => 'Bool', default => 0, documentation => "Set this to true to bypass the safety checks for API version compatibility.");
46              
47             sub BUILD {
48 1     1 0 4 my ( $self, $args ) = @_;
49 1         8 $self->_validate_api_version_range();
50 0         0 $self->_validate_api_version_value();
51             }
52              
53              
54             Charges: {
55             method post_charge(Int :$amount,
56             Str :$currency,
57             StripeCustomerId :$customer?,
58             StripeTokenId|StripeCardId :$card?,
59             StripeTokenId|StripeCardId|StripeSourceId :$source?,
60             Str :$description?,
61             HashRef :$metadata?,
62             Bool :$capture?,
63             Str :$statement_descriptor?,
64             Int :$application_fee?,
65             Str :$receipt_email?
66 2 0 0 2   70563 ) {
  2 0 0 2   4  
  2 0   2   298  
  2 0   2   15  
  2 0   2   3  
  2 0   2   211  
  2 0   2   19  
  2 0   2   6  
  2 0   2   25  
  2 0   2   416  
  2 0   2   4  
  2 0   2   859  
  2 0   0   15  
  2 0       3  
  2 0       331  
  2 0       12  
  2 0       4  
  2 0       566  
  2 0       15  
  2 0       4  
  2 0       269  
  2 0       13  
  2 0       4  
  2 0       417  
  2 0       14  
  2 0       16  
  2 0       247  
  2 0       30  
  2 0       3  
  2 0       265  
  2 0       13  
  2 0       3  
  2 0       267  
  2         12  
  2         3  
  2         1194  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
67              
68 0 0       0 if ( defined( $card ) ) {
69 0         0 my $card_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeCardId' );
70 0 0 0     0 if ( defined( $customer ) && ! $card_id_type->check( $card ) ) {
71 0         0 die Net::Stripe::Error->new(
72             type => "post_charge error",
73             message => sprintf(
74             "Invalid value '%s' passed for parameter 'card'. Charges for an existing customer can only accept a card id.",
75             $card,
76             ),
77             );
78             }
79              
80 0         0 my $token_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeTokenId' );
81 0 0 0     0 if ( ! defined( $customer ) && ! $token_id_type->check( $card ) ) {
82 0         0 die Net::Stripe::Error->new(
83             type => "post_charge error",
84             message => sprintf(
85             "Invalid value '%s' passed for parameter 'card'. Charges without an existing customer can only accept a token id.",
86             $card,
87             ),
88             );
89             }
90             }
91              
92 0 0       0 if ( defined( $source ) ) {
93 0         0 my $card_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeCardId' );
94 0 0 0     0 if ( defined( $customer ) && ! $card_id_type->check( $source ) ) {
95 0         0 die Net::Stripe::Error->new(
96             type => "post_charge error",
97             message => sprintf(
98             "Invalid value '%s' passed for parameter 'source'. Charges for an existing customer can only accept a card id.",
99             $source,
100             ),
101             );
102             }
103              
104 0         0 my $token_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeTokenId' );
105 0         0 my $source_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeSourceId' );
106 0 0 0     0 if ( ! defined( $customer ) && ! $token_id_type->check( $source ) && ! $source_id_type->check( $source ) ) {
      0        
107 0         0 die Net::Stripe::Error->new(
108             type => "post_charge error",
109             message => sprintf(
110             "Invalid value '%s' passed for parameter 'source'. Charges without an existing customer can only accept a token id or source id.",
111             $source,
112             ),
113             );
114             }
115             }
116              
117 0         0 my $charge = Net::Stripe::Charge->new(amount => $amount,
118             currency => $currency,
119             customer => $customer,
120             card => $card,
121             source => $source,
122             description => $description,
123             metadata => $metadata,
124             capture => $capture,
125             statement_descriptor => $statement_descriptor,
126             application_fee => $application_fee,
127             receipt_email => $receipt_email
128             );
129 0         0 return $self->_post('charges', $charge);
130             }
131              
132 2 0 0 2   8041 method get_charge(Str :$charge_id) {
  2 0 0 2   20  
  2 0   2   330  
  2 0   2   18  
  2 0   2   4  
  2 0   0   154  
  2         14  
  2         4  
  2         16  
  2         393  
  2         5  
  2         962  
  2         18  
  2         6  
  2         358  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
133 0         0 return $self->_get("charges/" . $charge_id);
134             }
135              
136 2 0 0 2   56566 method refund_charge(Net::Stripe::Charge|Str :$charge, Int :$amount?) {
  2 0 0 2   5  
  2 0   2   320  
  2 0   2   16  
  2 0   2   5  
  2 0   2   150  
  2 0   0   11  
  2 0       5  
  2 0       17  
  2         439  
  2         4  
  2         721  
  2         12  
  2         4  
  2         248  
  2         12  
  2         3  
  2         466  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
137 0 0       0 if (ref($charge)) {
138 0         0 $charge = $charge->id;
139             }
140              
141 0         0 my $refund = Net::Stripe::Refund->new(id => $charge,
142             amount => $amount
143             );
144 0         0 return $self->_post("charges/$charge/refunds", $refund);
145             }
146              
147             method get_charges(HashRef :$created?,
148             Net::Stripe::Customer|Str :$customer?,
149             Str :$ending_before?,
150             Int :$limit?,
151 2 0 0 2   53301 Str :$starting_after?) {
  2 0 0 2   4  
  2 0   2   227  
  2 0   2   11  
  2 0   2   6  
  2 0   2   138  
  2 0   2   11  
  2 0   2   4  
  2 0   2   14  
  2 0   0   452  
  2 0       5  
  2 0       743  
  2 0       13  
  2 0       6  
  2 0       321  
  2 0       12  
  2 0       4  
  2 0       273  
  2         12  
  2         5  
  2         225  
  2         17  
  2         4  
  2         244  
  2         15  
  2         4  
  2         418  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
152 0 0       0 if (ref($customer)) {
153 0         0 $customer = $customer->id;
154             }
155 0         0 my %args = (
156             path => 'charges',
157             created => $created,
158             customer => $customer,
159             ending_before => $ending_before,
160             limit => $limit,
161             starting_after => $starting_after,
162             );
163 0         0 $self->_get_all(%args);
164             }
165              
166             method capture_charge(
167             Net::Stripe::Charge|Str :$charge!,
168             Int :$amount?,
169 2 0 0 2   25071 ) {
  2 0 0 2   6  
  2 0   2   263  
  2 0   2   13  
  2 0   2   4  
  2 0   2   123  
  2 0   0   11  
  2 0       3  
  2 0       16  
  2         390  
  2         5  
  2         842  
  2         14  
  2         4  
  2         321  
  2         11  
  2         5  
  2         463  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
170 0 0       0 if (ref($charge)) {
171 0         0 $charge = $charge->id;
172             }
173              
174 0         0 my %args = (
175             amount => $amount,
176             );
177 0         0 return $self->_post("charges/$charge/capture", \%args);
178             }
179              
180             }
181              
182              
183             PaymentIntents: {
184             method create_payment_intent(
185             Int :$amount!,
186             Str :$currency!,
187             Int :$application_fee_amount?,
188             StripeCaptureMethod :$capture_method?,
189             Bool :$confirm?,
190             StripeConfirmationMethod :$confirmation_method?,
191             StripeCustomerId :$customer?,
192             Str :$description?,
193             Bool :$error_on_requires_action?,
194             Str :$mandate?,
195             HashRef :$mandate_data?,
196             HashRef[Str] :$metadata?,
197             Bool :$off_session?,
198             Str :$on_behalf_of?,
199             StripePaymentMethodId :$payment_method?,
200             HashRef :$payment_method_options?,
201             ArrayRef[StripePaymentMethodType] :$payment_method_types?,
202             Str :$receipt_email?,
203             Str :$return_url?,
204             Bool :$save_payment_method?,
205             Str :$setup_future_usage?,
206             HashRef :$shipping?,
207             Str :$statement_descriptor?,
208             Str :$statement_descriptor_suffix?,
209             HashRef :$transfer_data?,
210             Str :$transfer_group?,
211             Bool :$use_stripe_sdk?,
212 2 0 0 2   122411 ) {
  2 0 0 2   5  
  2 0   2   253  
  2 0   2   11  
  2 0   2   3  
  2 0   2   123  
  2 0   2   11  
  2 0   2   5  
  2 0   2   24  
  2 0   2   372  
  2 0   2   5  
  2 0   2   1013  
  2 0   2   15  
  2 0   2   13  
  2 0   2   321  
  2 0   2   13  
  2 0   2   5  
  2 0   2   291  
  2 0   2   14  
  2 0   2   3  
  2 0   2   252  
  2 0   2   12  
  2 0   2   6  
  2 0   2   230  
  2 0   2   11  
  2 0   2   5  
  2 0   2   311  
  2 0   2   19  
  2 0   2   4  
  2 0   0   364  
  2 0       12  
  2 0       3  
  2 0       234  
  2 0       11  
  2 0       4  
  2 0       272  
  2 0       12  
  2 0       4  
  2 0       263  
  2 0       13  
  2 0       3  
  2 0       289  
  2 0       12  
  2 0       3  
  2 0       230  
  2 0       30  
  2 0       3  
  2 0       206  
  2 0       10  
  2 0       5  
  2 0       415  
  2 0       15  
  2 0       4  
  2 0       300  
  2 0       12  
  2 0       5  
  2 0       297  
  2 0       12  
  2 0       13  
  2 0       272  
  2 0       12  
  2 0       3  
  2 0       227  
  2 0       11  
  2 0       3  
  2 0       208  
  2 0       9  
  2 0       3  
  2 0       310  
  2 0       11  
  2 0       4  
  2 0       272  
  2 0       11  
  2 0       5  
  2 0       219  
  2 0       9  
  2 0       5  
  2 0       273  
  2 0       11  
  2 0       3  
  2 0       258  
  2 0       13  
  2         5  
  2         299  
  2         12  
  2         5  
  2         854  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
213 0         0 my %args = (
214             amount => $amount,
215             currency => $currency,
216             application_fee_amount => $application_fee_amount,
217             capture_method => $capture_method,
218             confirm => $confirm,
219             confirmation_method => $confirmation_method,
220             customer => $customer,
221             description => $description,
222             error_on_requires_action => $error_on_requires_action,
223             mandate => $mandate,
224             mandate_data => $mandate_data,
225             metadata => $metadata,
226             off_session => $off_session,
227             on_behalf_of => $on_behalf_of,
228             payment_method => $payment_method,
229             payment_method_options => $payment_method_options,
230             payment_method_types => $payment_method_types,
231             receipt_email => $receipt_email,
232             return_url => $return_url,
233             save_payment_method => $save_payment_method,
234             setup_future_usage => $setup_future_usage,
235             shipping => $shipping,
236             statement_descriptor => $statement_descriptor,
237             statement_descriptor_suffix => $statement_descriptor_suffix,
238             transfer_data => $transfer_data,
239             transfer_group => $transfer_group,
240             use_stripe_sdk => $use_stripe_sdk,
241             );
242 0         0 my $payment_intent_obj = Net::Stripe::PaymentIntent->new( %args );
243 0         0 return $self->_post("payment_intents", $payment_intent_obj);
244             }
245              
246             method get_payment_intent(
247             StripePaymentIntentId :$payment_intent_id!,
248             Str :$client_secret?,
249 2 0 0 2   13733 ) {
  2 0 0 2   3  
  2 0   2   250  
  2 0   2   25  
  2 0   2   3  
  2 0   0   148  
  2 0       12  
  2 0       3  
  2         13  
  2         349  
  2         11  
  2         967  
  2         15  
  2         5  
  2         479  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
250 0         0 my %args = (
251             client_secret => $client_secret,
252             );
253 0         0 return $self->_get("payment_intents/$payment_intent_id", \%args);
254             }
255              
256             method update_payment_intent(
257             StripePaymentIntentId :$payment_intent_id!,
258             Int :$amount?,
259             Int :$application_fee_amount?,
260             Str :$currency?,
261             StripeCustomerId :$customer?,
262             Str :$description?,
263             HashRef[Str]|EmptyStr :$metadata?,
264             StripePaymentMethodId :$payment_method?,
265             HashRef :$payment_method_options?,
266             ArrayRef[StripePaymentMethodType] :$payment_method_types?,
267             Str :$receipt_email?,
268             Bool :$save_payment_method?,
269             Str :$setup_future_usage?,
270             HashRef :$shipping?,
271             Str :$statement_descriptor?,
272             Str :$statement_descriptor_suffix?,
273             HashRef :$transfer_data?,
274             Str :$transfer_group?,
275 2 0 0 2   66982 ) {
  2 0 0 2   3  
  2 0   2   247  
  2 0   2   13  
  2 0   2   6  
  2 0   2   175  
  2 0   2   16  
  2 0   2   4  
  2 0   2   18  
  2 0   2   427  
  2 0   2   5  
  2 0   2   1115  
  2 0   2   34  
  2 0   2   4  
  2 0   2   278  
  2 0   2   14  
  2 0   2   5  
  2 0   2   224  
  2 0   0   11  
  2 0       3  
  2 0       359  
  2 0       14  
  2 0       5  
  2 0       574  
  2 0       32  
  2 0       4  
  2 0       290  
  2 0       23  
  2 0       4  
  2 0       251  
  2 0       12  
  2 0       5  
  2 0       208  
  2 0       13  
  2 0       4  
  2 0       317  
  2 0       11  
  2 0       5  
  2 0       213  
  2 0       12  
  2 0       4  
  2 0       300  
  2 0       12  
  2 0       4  
  2 0       244  
  2 0       10  
  2 0       5  
  2 0       212  
  2 0       12  
  2 0       17  
  2 0       330  
  2 0       12  
  2 0       4  
  2         743  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
276 0         0 my %args = (
277             amount => $amount,
278             application_fee_amount => $application_fee_amount,
279             currency => $currency,
280             customer => $customer,
281             description => $description,
282             metadata => $metadata,
283             payment_method => $payment_method,
284             payment_method_options => $payment_method_options,
285             payment_method_types => $payment_method_types,
286             receipt_email => $receipt_email,
287             save_payment_method => $save_payment_method,
288             setup_future_usage => $setup_future_usage,
289             shipping => $shipping,
290             statement_descriptor => $statement_descriptor,
291             statement_descriptor_suffix => $statement_descriptor_suffix,
292             transfer_data => $transfer_data,
293             transfer_group => $transfer_group,
294             );
295 0         0 my $payment_intent_obj = Net::Stripe::PaymentIntent->new( %args );
296 0         0 return $self->_post("payment_intents/$payment_intent_id", $payment_intent_obj);
297             }
298              
299             method confirm_payment_intent(
300             StripePaymentIntentId :$payment_intent_id!,
301             Str :$client_secret?,
302             Bool :$error_on_requires_action?,
303             Str :$mandate?,
304             HashRef :$mandate_data?,
305             Bool :$off_session?,
306             StripePaymentMethodId :$payment_method?,
307             HashRef :$payment_method_options?,
308             ArrayRef[StripePaymentMethodType] :$payment_method_types?,
309             Str :$receipt_email?,
310             Str :$return_url?,
311             Bool :$save_payment_method?,
312             Str :$setup_future_usage?,
313             HashRef :$shipping?,
314             Bool :$use_stripe_sdk?,
315 2 0 0 2   55695 ) {
  2 0 0 2   6  
  2 0   2   318  
  2 0   2   19  
  2 0   2   5  
  2 0   2   239  
  2 0   2   17  
  2 0   2   4  
  2 0   2   38  
  2 0   2   475  
  2 0   2   5  
  2 0   2   1415  
  2 0   2   24  
  2 0   2   6  
  2 0   2   353  
  2 0   2   16  
  2 0   2   5  
  2 0   0   297  
  2 0       17  
  2 0       4  
  2 0       314  
  2 0       17  
  2 0       4  
  2 0       343  
  2 0       15  
  2 0       4  
  2 0       480  
  2 0       16  
  2 0       6  
  2 0       369  
  2 0       16  
  2 0       6  
  2 0       309  
  2 0       14  
  2 0       5  
  2 0       312  
  2 0       17  
  2 0       5  
  2 0       313  
  2 0       17  
  2 0       5  
  2 0       398  
  2 0       16  
  2 0       4  
  2 0       336  
  2 0       18  
  2         5  
  2         309  
  2         14  
  2         4  
  2         746  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
316 0         0 my %args = (
317             client_secret => $client_secret,
318             error_on_requires_action => $error_on_requires_action,
319             mandate => $mandate,
320             mandate_data => $mandate_data,
321             off_session => $off_session,
322             payment_method => $payment_method,
323             payment_method_options => $payment_method_options,
324             payment_method_types => $payment_method_types,
325             receipt_email => $receipt_email,
326             return_url => $return_url,
327             save_payment_method => $save_payment_method,
328             setup_future_usage => $setup_future_usage,
329             shipping => $shipping,
330             use_stripe_sdk => $use_stripe_sdk,
331             );
332 0         0 return $self->_post("payment_intents/$payment_intent_id/confirm", \%args);
333             }
334              
335             method capture_payment_intent(
336             StripePaymentIntentId :$payment_intent_id!,
337             Int :$amount_to_capture?,
338             Int :$application_fee_amount?,
339             Str :$statement_descriptor?,
340             Str :$statement_descriptor_suffix?,
341             HashRef :$transfer_data?,
342 2 0 0 2   28499 ) {
  2 0 0 2   7  
  2 0   2   305  
  2 0   2   18  
  2 0   2   5  
  2 0   2   164  
  2 0   2   16  
  2 0   2   3  
  2 0   2   18  
  2 0   0   506  
  2 0       5  
  2 0       1218  
  2 0       21  
  2 0       5  
  2 0       307  
  2 0       14  
  2 0       5  
  2 0       408  
  2 0       17  
  2 0       5  
  2         317  
  2         14  
  2         21  
  2         326  
  2         16  
  2         4  
  2         605  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
343 0         0 my %args = (
344             amount_to_capture => $amount_to_capture,
345             application_fee_amount => $application_fee_amount,
346             statement_descriptor => $statement_descriptor,
347             statement_descriptor_suffix => $statement_descriptor_suffix,
348             transfer_data => $transfer_data,
349             );
350 0         0 return $self->_post("payment_intents/$payment_intent_id/capture", \%args);
351             }
352              
353             method cancel_payment_intent(
354             StripePaymentIntentId :$payment_intent_id!,
355             StripeCancellationReason :$cancellation_reason?,
356 2 0 0 2   19350 ) {
  2 0 0 2   8  
  2 0   2   283  
  2 0   2   19  
  2 0   2   4  
  2 0   0   187  
  2 0       15  
  2 0       5  
  2         24  
  2         499  
  2         6  
  2         1104  
  2         20  
  2         6  
  2         563  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
357 0         0 my %args = (
358             cancellation_reason => $cancellation_reason,
359             );
360 0         0 return $self->_post("payment_intents/$payment_intent_id/cancel", \%args);
361             }
362              
363             method list_payment_intents(
364             StripeCustomerId :$customer?,
365             HashRef[Int] :$created?,
366             Str :$ending_before?,
367             Int :$limit?,
368             Str :$starting_after?,
369 2 0 0 2   25473 ) {
  2 0 0 2   6  
  2 0   2   266  
  2 0   2   14  
  2 0   2   4  
  2 0   2   126  
  2 0   2   13  
  2 0   2   3  
  2 0   0   15  
  2 0       424  
  2 0       3  
  2 0       945  
  2 0       16  
  2 0       3  
  2 0       366  
  2 0       14  
  2 0       4  
  2         247  
  2         12  
  2         4  
  2         234  
  2         14  
  2         5  
  2         459  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
370 0         0 my %args = (
371             customer => $customer,
372             created => $created,
373             ending_before => $ending_before,
374             limit => $limit,
375             starting_after => $starting_after,
376             );
377 0         0 return $self->_get("payment_intents", \%args);
378             }
379             }
380              
381              
382              
383             BalanceTransactions: {
384 2 0 0 2   6344 method get_balance_transaction(Str :$id) {
  2 0 0 2   3  
  2 0   2   266  
  2 0   2   28  
  2 0   2   3  
  2 0   0   134  
  2         12  
  2         3  
  2         12  
  2         316  
  2         5  
  2         759  
  2         14  
  2         5  
  2         367  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
385 0         0 return $self->_get("balance/history/$id");
386             }
387             }
388              
389              
390              
391             Customers: {
392             method post_customer(Net::Stripe::Customer|StripeCustomerId :$customer?,
393             Int :$account_balance?,
394             Int :$balance?,
395             Net::Stripe::Token|StripeTokenId :$card?,
396             Str :$coupon?,
397             Str :$default_card?,
398             StripeCardId|StripeSourceId :$default_source?,
399             Str :$description?,
400             Str :$email?,
401             HashRef :$metadata?,
402             Str :$plan?,
403             Int :$quantity?,
404             StripeTokenId|StripeSourceId :$source?,
405 2 0 0 2   78763 Int|Str :$trial_end?) {
  2 0 0 2   5  
  2 0   2   276  
  2 0   2   11  
  2 0   2   4  
  2 0   2   153  
  2 0   2   11  
  2 0   2   4  
  2 0   2   16  
  2 0   2   364  
  2 0   2   4  
  2 0   2   1078  
  2 0   2   13  
  2 0   2   4  
  2 0   0   238  
  2 0       10  
  2 0       5  
  2 0       315  
  2 0       11  
  2 0       3  
  2 0       209  
  2 0       28  
  2 0       6  
  2 0       431  
  2 0       12  
  2 0       5  
  2 0       268  
  2 0       11  
  2 0       4  
  2 0       208  
  2 0       9  
  2 0       3  
  2 0       241  
  2 0       16  
  2 0       5  
  2 0       218  
  2 0       13  
  2 0       4  
  2 0       400  
  2 0       12  
  2 0       4  
  2         851  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
406              
407 0         0 my $customer_obj;
408 0 0       0 if ( ref( $customer ) ) {
409 0         0 $customer_obj = $customer;
410             } else {
411 0         0 my %args = (
412             account_balance => $account_balance,
413             balance => $balance,
414             card => $card,
415             coupon => $coupon,
416             default_card => $default_card,
417             default_source => $default_source,
418             email => $email,
419             metadata => $metadata,
420             plan => $plan,
421             quantity => $quantity,
422             source => $source,
423             trial_end => $trial_end,
424             );
425 0 0       0 $args{id} = $customer if defined( $customer );
426              
427 0         0 $customer_obj = Net::Stripe::Customer->new( %args );
428             }
429              
430 0 0       0 if ( my $customer_id = $customer_obj->id ) {
431 0         0 return $self->_post("customers/$customer_id", $customer_obj);
432             } else {
433 0         0 return $self->_post('customers', $customer_obj);
434             }
435             }
436              
437             method list_subscriptions(Net::Stripe::Customer|Str :$customer,
438             Str :$ending_before?,
439             Int :$limit?,
440 2 0 0 2   32166 Str :$starting_after?) {
  2 0 0 2   8  
  2 0   2   280  
  2 0   2   13  
  2 0   2   4  
  2 0   2   132  
  2 0   2   11  
  2 0   2   3  
  2 0   0   16  
  2 0       397  
  2 0       3  
  2 0       753  
  2 0       14  
  2 0       5  
  2 0       336  
  2         13  
  2         5  
  2         219  
  2         11  
  2         3  
  2         250  
  2         11  
  2         4  
  2         436  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
441 0 0       0 if (ref($customer)) {
442 0         0 $customer = $customer->id;
443             }
444 0         0 my %args = (
445             path => "customers/$customer/subscriptions",
446             ending_before => $ending_before,
447             limit => $limit,
448             starting_after => $starting_after,
449             );
450 0         0 return $self->_get_all(%args);
451             }
452              
453 2 0 0 2   6123 method get_customer(Str :$customer_id) {
  2 0 0 2   5  
  2 0   2   269  
  2 0   2   12  
  2 0   2   4  
  2 0   0   108  
  2         11  
  2         10  
  2         11  
  2         295  
  2         5  
  2         777  
  2         15  
  2         4  
  2         323  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
454 0         0 return $self->_get("customers/$customer_id");
455             }
456              
457 2 0 0 2   23188 method delete_customer(Net::Stripe::Customer|Str :$customer) {
  2 0 0 2   6  
  2 0   2   235  
  2 0   2   13  
  2 0   2   6  
  2 0   0   147  
  2         12  
  2         4  
  2         11  
  2         350  
  2         5  
  2         791  
  2         15  
  2         4  
  2         388  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
458 0 0       0 if (ref($customer)) {
459 0         0 $customer = $customer->id;
460             }
461 0         0 $self->_delete("customers/$customer");
462             }
463              
464 2 0 0 2   18019 method get_customers(HashRef :$created?, Str :$ending_before?, Int :$limit?, Str :$starting_after?, Str :$email?) {
  2 0 0 2   5  
  2 0   2   223  
  2 0   2   11  
  2 0   2   5  
  2 0   2   138  
  2 0   2   12  
  2 0   2   4  
  2 0   2   40  
  2 0   0   386  
  2 0       5  
  2 0       773  
  2 0       13  
  2 0       5  
  2 0       347  
  2 0       14  
  2 0       4  
  2 0       324  
  2         13  
  2         3  
  2         234  
  2         14  
  2         3  
  2         265  
  2         13  
  2         3  
  2         408  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
465 0         0 my %args = (
466             path => 'customers',
467             created => $created,
468             ending_before => $ending_before,
469             limit => $limit,
470             starting_after => $starting_after,
471             email => $email,
472             );
473 0         0 $self->_get_all(%args);
474             }
475             }
476              
477              
478             Cards: {
479             method get_card(Net::Stripe::Customer|Str :$customer,
480 2 0 0 2   26369 Str :$card_id) {
  2 0 0 2   6  
  2 0   2   246  
  2 0   2   12  
  2 0   2   3  
  2 0   2   173  
  2 0   0   12  
  2 0       4  
  2 0       16  
  2         342  
  2         4  
  2         784  
  2         14  
  2         6  
  2         286  
  2         12  
  2         3  
  2         411  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
481 0 0       0 if (ref($customer)) {
482 0         0 $customer = $customer->id;
483             }
484 0         0 return $self->_get("customers/$customer/sources/$card_id");
485             }
486              
487             method get_cards(Net::Stripe::Customer|Str :$customer,
488             HashRef :$created?,
489             Str :$ending_before?,
490             Int :$limit?,
491 2 0 0 2   35443 Str :$starting_after?) {
  2 0 0 2   5  
  2 0   2   261  
  2 0   2   13  
  2 0   2   5  
  2 0   2   173  
  2 0   2   15  
  2 0   2   3  
  2 0   2   17  
  2 0   0   369  
  2 0       3  
  2 0       886  
  2 0       14  
  2 0       4  
  2 0       449  
  2 0       16  
  2 0       3  
  2 0       254  
  2         12  
  2         4  
  2         579  
  2         14  
  2         5  
  2         300  
  2         14  
  2         4  
  2         447  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
492 0 0       0 if (ref($customer)) {
493 0         0 $customer = $customer->id;
494             }
495              
496 0         0 my %args = (
497             path => "customers/$customer/sources",
498             object => "card",
499             created => $created,
500             ending_before => $ending_before,
501             limit => $limit,
502             starting_after => $starting_after,
503             );
504 0         0 $self->_get_all(%args);
505             }
506              
507             method post_card(
508             Net::Stripe::Customer|StripeCustomerId :$customer!,
509             Net::Stripe::Token|StripeTokenId :$card?,
510             StripeTokenId :$source?,
511 2 0 0 2   16748 ) {
  2 0 0 2   5  
  2 0   2   266  
  2 0   2   13  
  2 0   0   4  
  2 0       128  
  2 0       10  
  2 0       11  
  2 0       14  
  2         353  
  2         6  
  2         1619  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
512              
513 0 0 0     0 die Net::Stripe::Error->new(
514             type => "post_card error",
515             message => "One of parameters 'source' or 'card' is required.",
516             ) unless defined( $card ) || defined( $source );
517              
518 0 0       0 my $customer_id = ref( $customer ) ? $customer->id : $customer;
519              
520 0 0       0 if ( defined( $card ) ) {
521             # card here is either Net::Stripe::Token or StripeTokenId
522 0 0       0 my $token_id = ref( $card ) ? $card->id : $card;
523 0         0 return $self->_post("customers/$customer_id/cards", {card=> $token_id});
524             }
525              
526 0 0       0 if ( defined( $source ) ) {
527 0         0 return $self->_post("customers/$customer_id/cards", { source=> $source });
528             }
529             }
530              
531             method update_card(StripeCustomerId :$customer_id!,
532             StripeCardId :$card_id!,
533 2 0 0 2   10095 HashRef :$card!) {
  2 0 0 2   5  
  2 0   2   244  
  2 0   2   12  
  2 0   2   6  
  2 0   0   148  
  2 0       12  
  2 0       4  
  2 0       12  
  2 0       318  
  2         5  
  2         1217  
  2         16  
  2         31  
  2         383  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
534 0         0 return $self->_post("customers/$customer_id/cards/$card_id", $card);
535             }
536              
537 2 0 0 2   54728 method delete_card(Net::Stripe::Customer|Str :$customer, Net::Stripe::Card|Str :$card) {
  2 0 0 2   5  
  2 0   2   273  
  2 0   2   14  
  2 0   2   6  
  2 0   2   149  
  2 0   0   33  
  2 0       4  
  2 0       15  
  2         406  
  2         4  
  2         902  
  2         16  
  2         5  
  2         286  
  2         13  
  2         4  
  2         564  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
538 0 0       0 if (ref($customer)) {
539 0         0 $customer = $customer->id;
540             }
541              
542 0 0       0 if (ref($card)) {
543 0         0 $card = $card->id;
544             }
545              
546 0         0 return $self->_delete("customers/$customer/sources/$card");
547             }
548             }
549              
550              
551             Sources: {
552             method create_source(
553             StripeSourceType :$type!,
554             Int :$amount?,
555             Str :$currency?,
556             StripeSourceFlow :$flow?,
557             HashRef :$mandate?,
558             HashRef :$metadata?,
559             HashRef :$owner?,
560             HashRef :$receiver?,
561             HashRef :$redirect?,
562             HashRef :$source_order?,
563             Str :$statement_descriptor?,
564             StripeTokenId :$token?,
565             StripeSourceUsage :$usage?,
566 2 0 0 2   55729 ) {
  2 0 0 2   5  
  2 0   2   233  
  2 0   2   13  
  2 0   2   4  
  2 0   2   165  
  2 0   2   13  
  2 0   2   4  
  2 0   2   14  
  2 0   2   430  
  2 0   2   4  
  2 0   2   984  
  2 0   2   16  
  2 0   2   5  
  2 0   2   354  
  2 0   2   14  
  2 0   0   4  
  2 0       309  
  2 0       14  
  2 0       4  
  2 0       255  
  2 0       13  
  2 0       4  
  2 0       256  
  2 0       10  
  2 0       4  
  2 0       269  
  2 0       13  
  2 0       4  
  2 0       331  
  2 0       13  
  2 0       4  
  2 0       331  
  2 0       15  
  2 0       3  
  2 0       246  
  2 0       19  
  2 0       5  
  2 0       298  
  2 0       14  
  2 0       4  
  2         314  
  2         13  
  2         19  
  2         443  
  2         16  
  2         3  
  2         673  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
567              
568 0 0 0     0 die Net::Stripe::Error->new(
      0        
569             type => "create_source error",
570             message => "Parameter 'token' is required for source type 'card'",
571             param => 'token',
572             ) if defined( $type ) && $type eq 'card' && ! defined( $token );
573              
574 0         0 my %args = (
575             amount => $amount,
576             currency => $currency,
577             flow => $flow,
578             mandate => $mandate,
579             metadata => $metadata,
580             owner => $owner,
581             receiver => $receiver,
582             redirect => $redirect,
583             source_order => $source_order,
584             statement_descriptor => $statement_descriptor,
585             token => $token,
586             type => $type,
587             usage => $usage,
588             );
589 0         0 my $source_obj = Net::Stripe::Source->new( %args );
590 0         0 return $self->_post("sources", $source_obj);
591             }
592              
593             method get_source(
594             StripeSourceId :$source_id!,
595             Str :$client_secret?,
596 2 0 0 2   8976 ) {
  2 0 0 2   6  
  2 0   2   306  
  2 0   2   17  
  2 0   2   3  
  2 0   0   124  
  2 0       12  
  2 0       5  
  2         27  
  2         371  
  2         4  
  2         1005  
  2         16  
  2         3  
  2         416  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
597 0         0 my %args = (
598             client_secret => $client_secret,
599             );
600 0         0 return $self->_get("sources/$source_id", \%args);
601             }
602              
603             method update_source(
604             StripeSourceId :$source_id!,
605             Int :$amount?,
606             HashRef :$mandate?,
607             HashRef|EmptyStr :$metadata?,
608             HashRef :$owner?,
609             HashRef :$source_order?,
610 2 0 0 2   27881 ) {
  2 0 0 2   6  
  2 0   2   290  
  2 0   2   15  
  2 0   2   5  
  2 0   2   195  
  2 0   2   19  
  2 0   2   4  
  2 0   0   17  
  2 0       448  
  2 0       5  
  2 0       1377  
  2 0       20  
  2 0       7  
  2 0       394  
  2 0       19  
  2 0       5  
  2 0       511  
  2 0       17  
  2         6  
  2         354  
  2         17  
  2         4  
  2         925  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
611 0         0 my %args = (
612             amount => $amount,
613             mandate => $mandate,
614             metadata => $metadata,
615             owner => $owner,
616             source_order => $source_order,
617             );
618 0         0 my $source_obj = Net::Stripe::Source->new( %args );
619              
620 0         0 my @one_of = qw/ amount mandate metadata owner source_order /;
621 0         0 my @defined = grep { defined( $source_obj->$_ ) } @one_of;
  0         0  
622              
623 0 0       0 die Net::Stripe::Error->new(
624             type => "update_source error",
625             message => sprintf( "at least one of: %s is required to update a source",
626             join( ', ', @one_of ),
627             ),
628             ) if ! @defined;
629              
630 0         0 return $self->_post("sources/$source_id", $source_obj);
631             }
632              
633             method attach_source (
634             StripeCustomerId :$customer_id!,
635             StripeSourceId :$source_id!,
636 2 0 0 2   10123 ) {
  2 0 0 2   7  
  2 0   2   364  
  2 0   2   20  
  2 0   0   5  
  2 0       148  
  2 0       15  
  2         3  
  2         27  
  2         411  
  2         6  
  2         1550  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
637 0         0 my %args = (
638             source => $source_id,
639             );
640 0         0 return $self->_post("customers/$customer_id/sources", \%args);
641             }
642              
643             method detach_source(
644             StripeCustomerId :$customer_id!,
645             StripeSourceId :$source_id!,
646 2 0 0 2   9812 ) {
  2 0 0 2   6  
  2 0   2   308  
  2 0   2   17  
  2 0   0   5  
  2 0       168  
  2 0       14  
  2         5  
  2         14  
  2         401  
  2         31  
  2         1478  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
647 0         0 return $self->_delete("customers/$customer_id/sources/$source_id");
648             }
649              
650             # undocumented API endpoint
651             method list_sources(
652             StripeCustomerId :$customer_id!,
653             Str :$object!,
654             Str :$ending_before?,
655             Int :$limit?,
656             Str :$starting_after?,
657 2 0 0 2   21610 ) {
  2 0 0 2   6  
  2 0   2   291  
  2 0   2   16  
  2 0   2   20  
  2 0   2   183  
  2 0   2   15  
  2 0   2   5  
  2 0   0   15  
  2 0       413  
  2 0       5  
  2 0       1426  
  2 0       21  
  2 0       7  
  2 0       361  
  2 0       21  
  2 0       6  
  2         350  
  2         16  
  2         5  
  2         356  
  2         17  
  2         5  
  2         607  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
658 0         0 my %args = (
659             ending_before => $ending_before,
660             limit => $limit,
661             object => $object,
662             starting_after => $starting_after,
663             );
664 0         0 return $self->_get("customers/$customer_id/sources", \%args);
665             }
666             }
667              
668              
669             Subscriptions: {
670 2 0 0 2   46614 method get_subscription(Net::Stripe::Customer|Str :$customer) {
  2 0 0 2   8  
  2 0   2   371  
  2 0   2   17  
  2 0   2   5  
  2 0   0   204  
  2         19  
  2         5  
  2         17  
  2         513  
  2         5  
  2         956  
  2         17  
  2         6  
  2         540  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
671 0 0       0 if (ref($customer)) {
672 0         0 $customer = $customer->id;
673             }
674 0         0 return $self->_get("customers/$customer/subscription");
675             }
676              
677             # adds a subscription, keeping any existing subscriptions unmodified
678             method post_subscription(Net::Stripe::Customer|Str :$customer,
679             Net::Stripe::Subscription|Str :$subscription?,
680             Net::Stripe::Plan|Str :$plan?,
681             Str :$coupon?,
682             Int|Str :$trial_end?,
683             Net::Stripe::Card|Net::Stripe::Token|Str :$card?,
684             Net::Stripe::Card|Net::Stripe::Token|Str :$source?,
685             Int :$quantity? where { $_ >= 0 },
686             Num :$application_fee_percent?,
687             Bool :$prorate? = 1,
688             Bool :$cancel_at_period_end?,
689 2 0 0 2   260608 ) {
  2 0 0 2   6  
  2 0 0 2   344  
  2 0 0 2   17  
  2 0   2   6  
  2 0   2   181  
  2 0   2   16  
  2 0   2   6  
  2 0   2   20  
  2 0   2   543  
  2 0   2   5  
  2 0   2   1123  
  2 0   2   20  
  2 0   2   6  
  2 0   2   570  
  2 0   0   21  
  2 0       3  
  2 0       339  
  2 0       17  
  2 0       5  
  2 0       334  
  2 0       17  
  2 0       6  
  2 0       424  
  2 0       19  
  2 0       4  
  2 0       334  
  2 0       14  
  2 0       6  
  2 0       429  
  2 0       18  
  2 0       6  
  2 0       355  
  2 0       17  
  2 0       6  
  2 0       526  
  2         20  
  2         4  
  2         418  
  2         18  
  2         5  
  2         494  
  2         22  
  2         5  
  2         1128  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
690 0 0       0 if (ref($customer)) {
691 0         0 $customer = $customer->id;
692             }
693              
694 0 0       0 if (ref($plan)) {
695 0         0 $plan = $plan->id;
696             }
697              
698 0 0       0 if (ref($subscription) ne 'Net::Stripe::Subscription') {
699 0         0 my %args = (plan => $plan,
700             coupon => $coupon,
701             trial_end => $trial_end,
702             card => $card,
703             source => $source,
704             prorate => $prorate,
705             quantity => $quantity,
706             application_fee_percent => $application_fee_percent,
707             cancel_at_period_end => $cancel_at_period_end);
708 0 0       0 if (defined($subscription)) {
709 0         0 $args{id} = $subscription;
710             }
711 0         0 $subscription = Net::Stripe::Subscription->new( %args );
712             }
713              
714 0 0       0 if (defined($subscription->id)) {
715 0         0 return $self->_post("customers/$customer/subscriptions/" . $subscription->id, $subscription);
716             } else {
717 0         0 return $self->_post("customers/$customer/subscriptions", $subscription);
718             }
719             }
720              
721             method delete_subscription(Net::Stripe::Customer|Str :$customer,
722             Net::Stripe::Subscription|Str :$subscription,
723             Bool :$at_period_end?
724 2 0 0 2   62083 ) {
  2 0 0 2   5  
  2 0   2   352  
  2 0   2   27  
  2 0   2   6  
  2 0   2   206  
  2 0   2   15  
  2 0   0   6  
  2 0       20  
  2 0       492  
  2 0       5  
  2 0       1011  
  2         20  
  2         4  
  2         467  
  2         18  
  2         4  
  2         337  
  2         15  
  2         6  
  2         647  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
725 0 0       0 if (ref($customer)) {
726 0         0 $customer = $customer->id;
727             }
728 0 0       0 if (ref($subscription)) {
729 0         0 $subscription = $subscription->id;
730             }
731              
732 0         0 my %args;
733 0 0       0 $args{at_period_end} = 'true' if $at_period_end;
734 0         0 return $self->_delete("customers/$customer/subscriptions/$subscription", \%args);
735             }
736             }
737              
738              
739             PaymentMethods: {
740             method create_payment_method(
741             StripePaymentMethodType :$type!,
742             HashRef :$billing_details?,
743             StripeTokenId :$card?,
744             HashRef :$fpx?,
745             HashRef :$ideal?,
746             HashRef[Str] :$metadata?,
747             StripePaymentMethodId :$payment_method?,
748             HashRef :$sepa_debit?,
749 2 0 0 2   37236 ) {
  2 0 0 2   7  
  2 0   2   287  
  2 0   2   34  
  2 0   2   6  
  2 0   2   172  
  2 0   2   17  
  2 0   2   5  
  2 0   2   17  
  2 0   2   507  
  2 0   0   5  
  2 0       1089  
  2 0       20  
  2 0       5  
  2 0       423  
  2 0       26  
  2 0       6  
  2 0       517  
  2 0       16  
  2 0       5  
  2 0       298  
  2 0       15  
  2 0       4  
  2 0       286  
  2 0       13  
  2         5  
  2         481  
  2         16  
  2         4  
  2         576  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
750 0         0 my %args = (
751             type => $type,
752             billing_details => $billing_details,
753             card => $card,
754             fpx => $fpx,
755             ideal => $ideal,
756             metadata => $metadata,
757             payment_method => $payment_method,
758             sepa_debit => $sepa_debit,
759             );
760 0         0 my $payment_method_obj = Net::Stripe::PaymentMethod->new( %args );
761 0         0 return $self->_post("payment_methods", $payment_method_obj);
762             }
763              
764             method get_payment_method(
765             StripePaymentMethodId :$payment_method_id!,
766 2 0 0 2   7367 ) {
  2 0 0 2   7  
  2 0   2   324  
  2 0   2   17  
  2 0   0   4  
  2         189  
  2         15  
  2         4  
  2         14  
  2         445  
  2         5  
  2         1169  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
767 0         0 return $self->_get("payment_methods/$payment_method_id");
768             }
769              
770             method update_payment_method(
771             StripePaymentMethodId :$payment_method_id!,
772             HashRef :$billing_details?,
773             HashRef[Int] :$card?,
774             HashRef[Str]|EmptyStr :$metadata?,
775             HashRef :$sepa_debit?,
776 2 0 0 2   28722 ) {
  2 0 0 2   6  
  2 0   2   259  
  2 0   2   15  
  2 0   2   4  
  2 0   2   231  
  2 0   2   26  
  2 0   0   4  
  2 0       19  
  2 0       486  
  2 0       6  
  2 0       1232  
  2 0       20  
  2 0       7  
  2 0       432  
  2 0       19  
  2         6  
  2         516  
  2         18  
  2         4  
  2         601  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
777 0         0 my %args = (
778             billing_details => $billing_details,
779             card => $card,
780             metadata => $metadata,
781             sepa_debit => $sepa_debit,
782             );
783 0         0 my $payment_method_obj = Net::Stripe::PaymentMethod->new( %args );
784 0         0 return $self->_post("payment_methods/$payment_method_id", $payment_method_obj);
785             }
786              
787             method list_payment_methods(
788             StripeCustomerId :$customer!,
789             StripePaymentMethodType :$type!,
790             Str :$ending_before?,
791             Int :$limit?,
792             Str :$starting_after?,
793 2 0 0 2   22067 ) {
  2 0 0 2   6  
  2 0   2   302  
  2 0   2   17  
  2 0   2   5  
  2 0   2   160  
  2 0   2   14  
  2 0   2   5  
  2 0   0   14  
  2 0       474  
  2 0       4  
  2 0       1311  
  2 0       19  
  2 0       7  
  2 0       377  
  2 0       16  
  2 0       5  
  2         425  
  2         18  
  2         5  
  2         348  
  2         16  
  2         5  
  2         491  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
794 0         0 my %args = (
795             customer => $customer,
796             type => $type,
797             ending_before => $ending_before,
798             limit => $limit,
799             starting_after => $starting_after,
800             );
801 0         0 return $self->_get("payment_methods", \%args);
802             }
803              
804             method attach_payment_method(
805             StripeCustomerId :$customer!,
806             StripePaymentMethodId :$payment_method_id!,
807 2 0 0 2   10313 ) {
  2 0 0 2   5  
  2 0   2   311  
  2 0   2   20  
  2 0   0   6  
  2 0       175  
  2 0       16  
  2         5  
  2         14  
  2         400  
  2         5  
  2         1562  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
808 0         0 my %args = (
809             customer => $customer,
810             );
811 0         0 return $self->_post("payment_methods/$payment_method_id/attach", \%args);
812             }
813              
814             method detach_payment_method(
815             StripePaymentMethodId :$payment_method_id!,
816 2 0 0 2   7000 ) {
  2 0 0 2   4  
  2 0   2   310  
  2 0   2   16  
  2 0   0   6  
  2         160  
  2         16  
  2         5  
  2         22  
  2         407  
  2         5  
  2         1246  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
817 0         0 return $self->_post("payment_methods/$payment_method_id/detach");
818             }
819             }
820              
821              
822             Tokens: {
823 2 0 0 2   7524 method get_token(Str :$token_id) {
  2 0 0 2   7  
  2 0   2   291  
  2 0   2   18  
  2 0   2   4  
  2 0   0   139  
  2         27  
  2         5  
  2         13  
  2         467  
  2         4  
  2         955  
  2         21  
  2         8  
  2         399  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
824 0         0 return $self->_get("tokens/$token_id");
825             }
826             }
827              
828              
829             Products: {
830             method create_product(
831             Str :$name!,
832             Bool :$active?,
833             ArrayRef[Str] :$attributes?,
834             Str :$caption?,
835             ArrayRef[Str] :$deactivate_on?,
836             Str :$description?,
837             StripeProductId|Str :$id?,
838             ArrayRef[Str] :$images?,
839             HashRef[Str] :$metadata?,
840             HashRef[Num] :$package_dimensions?,
841             Bool :$shippable?,
842             Str :$statement_descriptor?,
843             StripeProductType :$type?,
844             Str :$unit_label?,
845             Str :$url?,
846 2 0 0 2   82129 ) {
  2 0 0 2   6  
  2 0 0 2   312  
  2 0 0 2   15  
  2 0   2   5  
  2 0   2   146  
  2 0   2   15  
  2 0   2   5  
  2 0   2   19  
  2 0   2   499  
  2 0   2   6  
  2 0   2   1201  
  2 0   2   18  
  2 0   2   4  
  2 0   2   431  
  2 0   2   18  
  2 0   2   5  
  2 0   2   356  
  2 0   0   17  
  2 0       5  
  2 0       423  
  2 0       17  
  2 0       5  
  2 0       318  
  2 0       34  
  2 0       5  
  2 0       375  
  2 0       18  
  2 0       4  
  2 0       533  
  2 0       18  
  2 0       5  
  2 0       376  
  2 0       16  
  2 0       6  
  2 0       348  
  2 0       15  
  2 0       5  
  2 0       775  
  2 0       18  
  2 0       5  
  2 0       315  
  2 0       17  
  2 0       18  
  2 0       384  
  2 0       20  
  2 0       4  
  2 0       387  
  2 0       16  
  2         5  
  2         361  
  2         16  
  2         3  
  2         841  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
847 0         0 my %args = (
848             name => $name,
849             active => $active,
850             attributes => $attributes,
851             caption => $caption,
852             deactivate_on => $deactivate_on,
853             description => $description,
854             id => $id,
855             images => $images,
856             metadata => $metadata,
857             package_dimensions => $package_dimensions,
858             shippable => $shippable,
859             statement_descriptor => $statement_descriptor,
860             type => $type,
861             unit_label => $unit_label,
862             url => $url,
863             );
864 0         0 my $product_obj = Net::Stripe::Product->new( %args );
865 0         0 return $self->_post('products', $product_obj);
866             }
867              
868             method get_product(
869             StripeProductId|Str :$product_id!,
870 2 0 0 2   10404 ) {
  2 0 0 2   6  
  2 0   2   322  
  2 0   2   18  
  2 0   0   5  
  2         232  
  2         37  
  2         6  
  2         18  
  2         453  
  2         7  
  2         1225  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
871 0         0 return $self->_get("products/$product_id");
872             }
873              
874             method update_product(
875             StripeProductId|Str :$product_id!,
876             Bool :$active?,
877             ArrayRef[Str] :$attributes?,
878             Str :$caption?,
879             ArrayRef[Str] :$deactivate_on?,
880             Str :$description?,
881             ArrayRef[Str] :$images?,
882             HashRef[Str]|EmptyStr :$metadata?,
883             Str :$name?,
884             HashRef[Num] :$package_dimensions?,
885             Bool :$shippable?,
886             Str :$statement_descriptor?,
887             StripeProductType :$type?,
888             Str :$unit_label?,
889             Str :$url?,
890 2 0 0 2   73818 ) {
  2 0 0 2   6  
  2 0 0 2   307  
  2 0 0 2   16  
  2 0   2   5  
  2 0   2   231  
  2 0   2   20  
  2 0   2   6  
  2 0   2   21  
  2 0   2   483  
  2 0   2   5  
  2 0   2   1606  
  2 0   2   19  
  2 0   2   6  
  2 0   2   421  
  2 0   2   18  
  2 0   2   4  
  2 0   0   409  
  2 0       17  
  2 0       4  
  2 0       347  
  2 0       18  
  2 0       5  
  2 0       292  
  2 0       14  
  2 0       6  
  2 0       417  
  2 0       16  
  2 0       5  
  2 0       447  
  2 0       16  
  2 0       6  
  2 0       348  
  2 0       15  
  2 0       6  
  2 0       691  
  2 0       16  
  2 0       7  
  2 0       373  
  2 0       16  
  2 0       6  
  2 0       309  
  2 0       16  
  2 0       5  
  2 0       399  
  2 0       15  
  2 0       5  
  2 0       311  
  2         16  
  2         5  
  2         886  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
891 0         0 my %args = (
892             active => $active,
893             attributes => $attributes,
894             caption => $caption,
895             deactivate_on => $deactivate_on,
896             description => $description,
897             images => $images,
898             metadata => $metadata,
899             name => $name,
900             package_dimensions => $package_dimensions,
901             shippable => $shippable,
902             statement_descriptor => $statement_descriptor,
903             type => $type,
904             unit_label => $unit_label,
905             url => $url,
906             );
907 0         0 my $product_obj = Net::Stripe::Product->new( %args );
908 0         0 return $self->_post("products/$product_id", $product_obj);
909             }
910              
911             method list_products(
912             Bool :$active?,
913             ArrayRef[StripeProductId|Str] :$ids,
914             Bool :$shippable?,
915             StripeProductType :$type?,
916             Str :$url?,
917             HashRef[Str] :$created?,
918             Str :$ending_before?,
919             Int :$limit?,
920             Str :$starting_after?,
921 2 0 0 2   52822 ) {
  2 0 0 2   6  
  2 0   2   332  
  2 0   2   19  
  2 0   2   18  
  2 0   2   269  
  2 0   2   21  
  2 0   2   4  
  2 0   2   19  
  2 0   2   503  
  2 0   2   6  
  2 0   2   1059  
  2 0   0   18  
  2 0       4  
  2 0       557  
  2 0       26  
  2 0       7  
  2 0       317  
  2 0       16  
  2 0       5  
  2 0       335  
  2 0       15  
  2 0       4  
  2 0       357  
  2 0       34  
  2 0       6  
  2 0       367  
  2 0       27  
  2 0       13  
  2         314  
  2         14  
  2         6  
  2         307  
  2         14  
  2         4  
  2         669  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
922 0         0 my %args = (
923             path => "products",
924             active => _encode_boolean( $active ),
925             ids => $ids,
926             shippable => _encode_boolean( $shippable ),
927             type => $type,
928             url => $url,
929             created => $created,
930             ending_before => $ending_before,
931             limit => $limit,
932             starting_after => $starting_after,
933             );
934 0         0 return $self->_get_all( %args );
935             }
936              
937             method delete_product(
938             StripeProductId|Str :$product_id!,
939 2 0 0 2   9862 ) {
  2 0 0 2   5  
  2 0   2   339  
  2 0   2   36  
  2 0   0   7  
  2         176  
  2         14  
  2         6  
  2         12  
  2         457  
  2         5  
  2         1318  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
940 0         0 $self->_delete("products/$product_id");
941             }
942             }
943              
944              
945             Plans: {
946             method post_plan(Str :$id,
947             Int :$amount,
948             Str :$currency,
949             Str :$interval,
950             Int :$interval_count?,
951             Str :$name,
952             StripeProductId|Str :$product,
953             Int :$trial_period_days?,
954             HashRef :$metadata?,
955 2 0 0 2   44700 Str :$statement_descriptor?) {
  2 0 0 2   7  
  2 0   2   264  
  2 0   2   16  
  2 0   2   5  
  2 0   2   188  
  2 0   2   17  
  2 0   2   4  
  2 0   2   21  
  2 0   2   555  
  2 0   2   5  
  2 0   2   1091  
  2 0   2   19  
  2 0   0   6  
  2 0       414  
  2 0       18  
  2 0       5  
  2 0       384  
  2 0       19  
  2 0       4  
  2 0       322  
  2 0       37  
  2 0       25  
  2 0       299  
  2 0       17  
  2 0       3  
  2 0       324  
  2 0       17  
  2 0       5  
  2 0       562  
  2 0       19  
  2 0       5  
  2         339  
  2         15  
  2         5  
  2         402  
  2         16  
  2         6  
  2         650  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
956 0         0 my $plan = Net::Stripe::Plan->new(id => $id,
957             amount => $amount,
958             currency => $currency,
959             interval => $interval,
960             interval_count => $interval_count,
961             name => $name,
962             product => $product,
963             trial_period_days => $trial_period_days,
964             metadata => $metadata,
965             statement_descriptor => $statement_descriptor);
966 0         0 return $self->_post('plans', $plan);
967             }
968              
969 2 0 0 2   7691 method get_plan(Str :$plan_id) {
  2 0 0 2   7  
  2 0   2   335  
  2 0   2   15  
  2 0   2   6  
  2 0   0   175  
  2         18  
  2         4  
  2         13  
  2         378  
  2         5  
  2         936  
  2         19  
  2         7  
  2         350  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
970 0         0 return $self->_get("plans/" . uri_escape($plan_id));
971             }
972              
973 2 0   2   23741 method delete_plan(Str|Net::Stripe::Plan $plan) {
  2 0   2   6  
  2 0   0   453  
  2 0       18  
  2 0       6  
  2         416  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
974 0 0       0 if (ref($plan)) {
975 0         0 $plan = $plan->id;
976             }
977 0         0 $self->_delete("plans/$plan");
978             }
979              
980             method get_plans(
981             StripeProductId|Str :$product?,
982             Str :$ending_before?,
983             Int :$limit?,
984             Str :$starting_after?,
985 2 0 0 2   21730 ) {
  2 0 0 2   5  
  2 0   2   288  
  2 0   2   19  
  2 0   2   8  
  2 0   2   205  
  2 0   2   16  
  2 0   0   6  
  2 0       18  
  2 0       512  
  2 0       28  
  2 0       1158  
  2 0       19  
  2 0       6  
  2         501  
  2         22  
  2         5  
  2         357  
  2         17  
  2         7  
  2         524  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
986 0         0 my %args = (
987             path => 'plans',
988             product => $product,
989             ending_before => $ending_before,
990             limit => $limit,
991             starting_after => $starting_after,
992             );
993 0         0 $self->_get_all(%args);
994             }
995             }
996              
997              
998              
999             Coupons: {
1000             method post_coupon(Str :$id?,
1001             Str :$duration,
1002             Int :$amount_off?,
1003             Str :$currency?,
1004             Int :$duration_in_months?,
1005             Int :$max_redemptions?,
1006             HashRef :$metadata?,
1007             Int :$percent_off?,
1008 2 0 0 2   38493 Int :$redeem_by?) {
  2 0 0 2   8  
  2 0   2   373  
  2 0   2   18  
  2 0   2   6  
  2 0   2   162  
  2 0   2   14  
  2 0   2   5  
  2 0   2   19  
  2 0   2   485  
  2 0   2   14  
  2 0   2   1064  
  2 0   2   19  
  2 0   0   5  
  2 0       465  
  2 0       32  
  2 0       5  
  2 0       327  
  2 0       17  
  2 0       4  
  2 0       338  
  2 0       15  
  2 0       6  
  2 0       277  
  2 0       15  
  2 0       5  
  2 0       358  
  2 0       15  
  2 0       5  
  2 0       399  
  2         19  
  2         4  
  2         456  
  2         17  
  2         5  
  2         481  
  2         18  
  2         7  
  2         599  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1009 0         0 my $coupon = Net::Stripe::Coupon->new(id => $id,
1010             duration => $duration,
1011             amount_off => $amount_off,
1012             currency => $currency,
1013             duration_in_months => $duration_in_months,
1014             max_redemptions => $max_redemptions,
1015             metadata => $metadata,
1016             percent_off => $percent_off,
1017             redeem_by => $redeem_by
1018             );
1019 0         0 return $self->_post('coupons', $coupon);
1020             }
1021              
1022 2 0 0 2   7853 method get_coupon(Str :$coupon_id) {
  2 0 0 2   7  
  2 0   2   325  
  2 0   2   18  
  2 0   2   5  
  2 0   0   146  
  2         24  
  2         5  
  2         14  
  2         450  
  2         5  
  2         962  
  2         18  
  2         6  
  2         427  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1023 0         0 return $self->_get("coupons/" . uri_escape($coupon_id));
1024             }
1025              
1026 2 0   2   4948 method delete_coupon($id) {
  2 0   0   6  
  2 0       442  
  0         0  
  0         0  
  0         0  
  0         0  
1027 0 0       0 $id = $id->id if ref($id);
1028 0         0 $self->_delete("coupons/$id");
1029             }
1030              
1031 2 0 0 2   15130 method get_coupons(Str :$ending_before?, Int :$limit?, Str :$starting_after?) {
  2 0 0 2   7  
  2 0   2   309  
  2 0   2   18  
  2 0   2   4  
  2 0   2   164  
  2 0   2   17  
  2 0   0   4  
  2 0       17  
  2 0       400  
  2 0       5  
  2 0       1119  
  2         656  
  2         8  
  2         409  
  2         18  
  2         5  
  2         328  
  2         707  
  2         10  
  2         489  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1032 0         0 my %args = (
1033             path => 'coupons',
1034             ending_before => $ending_before,
1035             limit => $limit,
1036             starting_after => $starting_after,
1037             );
1038 0         0 $self->_get_all(%args);
1039             }
1040             }
1041              
1042              
1043             Discounts: {
1044 2 0 0 2   30932 method delete_customer_discount(Net::Stripe::Customer|Str :$customer) {
  2 0 0 2   568  
  2 0   2   920  
  2 0   2   25  
  2 0   2   6  
  2 0   0   230  
  2         19  
  2         4  
  2         17  
  2         404  
  2         4  
  2         872  
  2         17  
  2         5  
  2         595  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1045 0 0       0 if (ref($customer)) {
1046 0         0 $customer = $customer->id;
1047             }
1048 0         0 $self->_delete("customers/$customer/discount");
1049             }
1050             }
1051              
1052              
1053              
1054             Invoices: {
1055              
1056             method create_invoice(Net::Stripe::Customer|Str :$customer,
1057             Int :$application_fee?,
1058             Str :$description?,
1059             HashRef :$metadata?,
1060             Net::Stripe::Subscription|Str :$subscription?,
1061 2 0 0 2   72857 Bool :$auto_advance?) {
  2 0 0 2   7  
  2 0   2   292  
  2 0   2   16  
  2 0   2   4  
  2 0   2   201  
  2 0   2   15  
  2 0   2   5  
  2 0   2   18  
  2 0   2   490  
  2 0   0   5  
  2 0       1064  
  2 0       18  
  2 0       5  
  2 0       467  
  2 0       17  
  2 0       5  
  2 0       365  
  2 0       17  
  2 0       6  
  2 0       333  
  2         16  
  2         5  
  2         357  
  2         16  
  2         5  
  2         356  
  2         17  
  2         5  
  2         739  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1062 0 0       0 if (ref($customer)) {
1063 0         0 $customer = $customer->id;
1064             }
1065              
1066 0 0       0 if (ref($subscription)) {
1067 0         0 $subscription = $subscription->id;
1068             }
1069              
1070 0         0 return $self->_post("invoices",
1071             {
1072             customer => $customer,
1073             application_fee => $application_fee,
1074             description => $description,
1075             metadata => $metadata,
1076             subscription => $subscription,
1077             auto_advance => $auto_advance,
1078             });
1079             }
1080              
1081              
1082             method post_invoice(Net::Stripe::Invoice|Str :$invoice,
1083             Int :$application_fee?,
1084             Bool :$closed?,
1085             Bool :$auto_advance?,
1086             Str :$description?,
1087 2 0 0 2   76568 HashRef :$metadata?) {
  2 0 0 2   7  
  2 0   2   289  
  2 0   2   16  
  2 0   2   6  
  2 0   2   207  
  2 0   2   16  
  2 0   2   5  
  2 0   2   48  
  2 0   2   496  
  2 0   0   5  
  2 0       1063  
  2 0       19  
  2 0       5  
  2 0       456  
  2 0       18  
  2 0       4  
  2 0       359  
  2 0       16  
  2 0       5  
  2 0       315  
  2         16  
  2         4  
  2         293  
  2         48  
  2         6  
  2         320  
  2         16  
  2         5  
  2         653  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1088 0 0       0 if (ref($invoice)) {
1089 0         0 $invoice = $invoice->id;
1090             }
1091              
1092 0         0 return $self->_post("invoices/$invoice",
1093             {
1094             application_fee => $application_fee,
1095             closed => $closed,
1096             auto_advance => $auto_advance,
1097             description => $description,
1098             metadata => $metadata
1099             });
1100             }
1101              
1102 2 0 0 2   7972 method get_invoice(Str :$invoice_id) {
  2 0 0 2   6  
  2 0   2   259  
  2 0   2   15  
  2 0   2   5  
  2 0   0   207  
  2         18  
  2         5  
  2         13  
  2         356  
  2         4  
  2         980  
  2         17  
  2         6  
  2         347  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1103 0         0 return $self->_get("invoices/$invoice_id");
1104             }
1105              
1106 2 0 0 2   7308 method pay_invoice(Str :$invoice_id) {
  2 0 0 2   6  
  2 0   2   301  
  2 0   2   17  
  2 0   2   4  
  2 0   0   153  
  2         13  
  2         4  
  2         13  
  2         407  
  2         4  
  2         931  
  2         19  
  2         6  
  2         398  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1107 0         0 return $self->_post("invoices/$invoice_id/pay");
1108             }
1109              
1110             method get_invoices(Net::Stripe::Customer|Str :$customer?,
1111             Int|HashRef :$date?,
1112             Str :$ending_before?,
1113             Int :$limit?,
1114 2 0 0 2   69710 Str :$starting_after?) {
  2 0 0 2   7  
  2 0   2   324  
  2 0   2   16  
  2 0   2   5  
  2 0   2   156  
  2 0   2   14  
  2 0   2   5  
  2 0   2   20  
  2 0   0   545  
  2 0       5  
  2 0       1047  
  2 0       24  
  2 0       6  
  2 0       432  
  2 0       16  
  2 0       5  
  2 0       421  
  2         18  
  2         5  
  2         326  
  2         18  
  2         6  
  2         342  
  2         16  
  2         4  
  2         567  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1115 0 0       0 if (ref($customer)) {
1116 0         0 $customer = $customer->id
1117             }
1118              
1119 0         0 my %args = (
1120             customer => $customer,
1121             date => $date,
1122             ending_before => $ending_before,
1123             limit => $limit,
1124             starting_after => $starting_after,
1125             );
1126 0         0 $self->_get('invoices', \%args);
1127             }
1128              
1129 2 0   2   29976 method get_upcominginvoice(Net::Stripe::Customer|Str $customer) {
  2 0   2   24  
  2 0   0   446  
  2 0       18  
  2 0       6  
  2         562  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1130 0 0       0 if (ref($customer)) {
1131 0         0 $customer = $customer->id;
1132             }
1133 0         0 my %args = (
1134             path => 'invoices/upcoming',
1135             customer => $customer,
1136             );
1137 0         0 return $self->_get_all(%args);
1138             }
1139             }
1140              
1141              
1142             InvoiceItems: {
1143             method create_invoiceitem(Net::Stripe::Customer|Str :$customer,
1144             Int :$amount,
1145             Str :$currency,
1146             Net::Stripe::Invoice|Str :$invoice?,
1147             Net::Stripe::Subscription|Str :$subscription?,
1148             Str :$description?,
1149 2 0 0 2   99100 HashRef :$metadata?) {
  2 0 0 2   6  
  2 0   2   348  
  2 0   2   19  
  2 0   2   4  
  2 0   2   197  
  2 0   2   16  
  2 0   2   5  
  2 0   2   19  
  2 0   2   516  
  2 0   2   6  
  2 0   0   1147  
  2 0       19  
  2 0       5  
  2 0       454  
  2 0       19  
  2 0       5  
  2 0       366  
  2 0       17  
  2 0       5  
  2 0       366  
  2 0       29  
  2 0       6  
  2 0       328  
  2         17  
  2         5  
  2         357  
  2         28  
  2         5  
  2         417  
  2         26  
  2         4  
  2         759  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1150 0 0       0 if (ref($customer)) {
1151 0         0 $customer = $customer->id;
1152             }
1153              
1154 0 0       0 if (ref($invoice)) {
1155 0         0 $invoice = $invoice->id;
1156             }
1157              
1158 0 0       0 if (ref($subscription)) {
1159 0         0 $subscription = $subscription->id;
1160             }
1161              
1162 0         0 my $invoiceitem = Net::Stripe::Invoiceitem->new(customer => $customer,
1163             amount => $amount,
1164             currency => $currency,
1165             invoice => $invoice,
1166             subscription => $subscription,
1167             description => $description,
1168             metadata => $metadata);
1169 0         0 return $self->_post('invoiceitems', $invoiceitem);
1170             }
1171              
1172              
1173             method post_invoiceitem(Net::Stripe::Invoiceitem|Str :$invoice_item,
1174             Int :$amount?,
1175             Str :$description?,
1176 2 0 0 2   68705 HashRef :$metadata?) {
  2 0 0 2   6  
  2 0   2   285  
  2 0   2   52  
  2 0   2   7  
  2 0   2   181  
  2 0   2   34  
  2 0   2   6  
  2 0   0   20  
  2 0       471  
  2 0       5  
  2 0       1105  
  2 0       17  
  2 0       6  
  2 0       437  
  2         18  
  2         5  
  2         333  
  2         15  
  2         6  
  2         353  
  2         16  
  2         6  
  2         797  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1177 0 0 0     0 if (!defined($amount) && !defined($description) && !defined($metadata)) {
      0        
1178 0         0 my $item = $invoice_item->clone; $item->clear_currency;
  0         0  
1179 0         0 return $self->_post("invoiceitems/" . $item->id, $item);
1180             }
1181              
1182 0 0       0 if (ref($invoice_item)) {
1183 0         0 $invoice_item = $invoice_item->id;
1184             }
1185              
1186 0         0 return $self->_post("invoiceitems/" . $invoice_item,
1187             {
1188             amount => $amount,
1189             description => $description,
1190             metadata => $metadata
1191             });
1192             }
1193              
1194 2 0 0 2   8245 method get_invoiceitem(Str :$invoice_item) {
  2 0 0 2   5  
  2 0   2   330  
  2 0   2   18  
  2 0   2   4  
  2 0   0   167  
  2         14  
  2         5  
  2         14  
  2         450  
  2         5  
  2         952  
  2         18  
  2         5  
  2         399  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1195 0         0 return $self->_get("invoiceitems/$invoice_item");
1196             }
1197              
1198 2 0 0 2   30941 method delete_invoiceitem(Net::Stripe::Invoiceitem|Str :$invoice_item) {
  2 0 0 2   7  
  2 0   2   319  
  2 0   2   19  
  2 0   2   5  
  2 0   0   183  
  2         17  
  2         5  
  2         29  
  2         474  
  2         4  
  2         1005  
  2         20  
  2         5  
  2         485  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1199 0 0       0 if (ref($invoice_item)) {
1200 0         0 $invoice_item = $invoice_item->id;
1201             }
1202 0         0 $self->_delete("invoiceitems/$invoice_item");
1203             }
1204              
1205             method get_invoiceitems(HashRef :$created?,
1206             Net::Stripe::Customer|Str :$customer?,
1207             Str :$ending_before?,
1208             Int :$limit?,
1209 2 0 0 2   46120 Str :$starting_after?) {
  2 0 0 2   6  
  2 0   2   346  
  2 0   2   17  
  2 0   2   5  
  2 0   2   207  
  2 0   2   16  
  2 0   2   5  
  2 0   2   18  
  2 0   0   549  
  2 0       7  
  2 0       1070  
  2 0       20  
  2 0       7  
  2 0       457  
  2 0       19  
  2 0       6  
  2 0       384  
  2         18  
  2         6  
  2         355  
  2         36  
  2         6  
  2         303  
  2         15  
  2         4  
  2         590  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1210 0 0       0 if (ref($customer)) {
1211 0         0 $customer = $customer->id;
1212             }
1213 0         0 my %args = (
1214             path => 'invoiceitems',
1215             customer => $customer,
1216             created => $created,
1217             ending_before => $ending_before,
1218             limit => $limit,
1219             starting_after => $starting_after,
1220             );
1221 0         0 $self->_get_all(%args);
1222             }
1223             }
1224              
1225             # Helper methods
1226              
1227 2 0   2   15397 method _get(Str $path!, HashRef|StripeResourceObject $obj?) {
  2 0   2   5  
  2 0   0   442  
  2 0       18  
  2 0       6  
  2 0       783  
  0 0       0  
  0 0       0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1228 0         0 my $uri_obj = URI->new( $self->api_base . '/' . $path );
1229              
1230 0 0       0 if ( $obj ) {
1231 0         0 my %form_fields = %{ convert_to_form_fields( $obj ) };
  0         0  
1232 0 0       0 $uri_obj->query_form( \%form_fields ) if %form_fields;
1233             }
1234              
1235 0         0 my $req = GET $uri_obj->as_string;
1236 0         0 return $self->_make_request($req);
1237             }
1238              
1239 2 0   2   13519 method _delete(Str $path!, HashRef|StripeResourceObject $obj?) {
  2 0   2   33  
  2 0   0   482  
  2 0       18  
  2 0       4  
  2 0       1839  
  0 0       0  
  0 0       0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1240 0         0 my $uri_obj = URI->new( $self->api_base . '/' . $path );
1241              
1242 0 0       0 if ( $obj ) {
1243 0         0 my %form_fields = %{ convert_to_form_fields( $obj ) };
  0         0  
1244 0 0       0 $uri_obj->query_form( \%form_fields ) if %form_fields;
1245             }
1246              
1247 0         0 my $req = DELETE $uri_obj->as_string;
1248 0         0 return $self->_make_request($req);
1249             }
1250              
1251             sub convert_to_form_fields {
1252 4     4 1 1148 my $hash = shift;
1253 4         24 my $stripe_resource_object_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeResourceObject' );
1254 4 100       627 if (ref($hash) eq 'HASH') {
    50          
1255 2         7 my $r = {};
1256 2         11 foreach my $key (grep { defined($hash->{$_}) }keys %$hash) {
  4         17  
1257 4 100       28 if ( $stripe_resource_object_type->check( $hash->{$key} ) ) {
    50          
    100          
1258 2         22 %{$r} = ( %{$r}, %{ convert_to_form_fields($hash->{$key}) } );
  2         16  
  2         6  
  2         12  
1259             } elsif (ref($hash->{$key}) eq 'HASH') {
1260 0         0 foreach my $fn (keys %{$hash->{$key}}) {
  0         0  
1261 0         0 $r->{$key . '[' . $fn . ']'} = $hash->{$key}->{$fn};
1262             }
1263             } elsif (ref($hash->{$key}) eq 'ARRAY') {
1264 1         148 $r->{$key . '[]'} = $hash->{$key};
1265             } else {
1266 1         103 $r->{$key} = $hash->{$key};
1267             }
1268             }
1269 2         9 return $r;
1270             } elsif ($stripe_resource_object_type->check($hash)) {
1271 2         25 return { $hash->form_fields };
1272             }
1273 0         0 return $hash;
1274             }
1275              
1276 2 0   2   12632 method _post(Str $path!, HashRef|StripeResourceObject $obj?) {
  2 0   2   6  
  2 0   0   430  
  2 0       16  
  2 0       4  
  2 0       804  
  0 0       0  
  0 0       0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1277 0         0 my %headers;
1278 0 0       0 if ( $obj ) {
1279 0         0 my %form_fields = %{ convert_to_form_fields( $obj ) };
  0         0  
1280 0         0 push @{$headers{Content}}, ( $_, $form_fields{$_} ) for sort( keys( %form_fields ) );
  0         0  
1281             }
1282              
1283 0         0 my $req = POST $self->api_base . '/' . $path, %headers;
1284 0         0 return $self->_make_request($req);
1285             }
1286              
1287             method _get_response(
1288             HTTP::Request :$req!,
1289             Bool :$suppress_api_version? = 0,
1290 2 0 0 2   23320 ) {
  2 0 0 2   6  
  2 0   2   336  
  2 0   2   16  
  2 0   2   5  
  2 0   2   196  
  2 0   0   16  
  2 0       5  
  2         19  
  2         512  
  2         7  
  2         1090  
  2         19  
  2         5  
  2         398  
  2         17  
  2         7  
  2         1376  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1291 0         0 $req->header( Authorization =>
1292             "Basic " . encode_base64($self->api_key . ':'));
1293              
1294 0 0 0     0 if ($self->api_version && ! $suppress_api_version) {
1295 0         0 $req->header( 'Stripe-Version' => $self->api_version );
1296             }
1297              
1298 0 0       0 if ($self->debug_network) {
1299 0         0 print STDERR "Sending to Stripe:\n------\n" . $req->as_string() . "------\n";
1300              
1301             }
1302 0         0 my $resp = $self->ua->request($req);
1303              
1304 0 0       0 if ($self->debug_network) {
1305 0         0 print STDERR "Received from Stripe:\n------\n" . $resp->as_string() . "------\n";
1306             }
1307              
1308 0 0       0 if ($resp->code == 200) {
    0          
1309 0         0 return $resp;
1310             } elsif ($resp->code == 500) {
1311 0         0 die Net::Stripe::Error->new(
1312             type => "HTTP request error",
1313             code => $resp->code,
1314             message => $resp->status_line . " - " . $resp->content,
1315             );
1316             }
1317              
1318 0         0 my $e = eval {
1319 0         0 my $hash = decode_json($resp->content);
1320             Net::Stripe::Error->new($hash->{error})
1321 0         0 };
1322 0 0       0 if ($@) {
1323 0         0 Net::Stripe::Error->new(
1324             type => "Could not decode HTTP response: $@",
1325             message => $resp->status_line . " - " . $resp->content,
1326             );
1327             };
1328              
1329 0 0       0 warn "$e\n" if $self->debug;
1330 0         0 die $e;
1331             }
1332              
1333 2 0   2   9815 method _make_request(HTTP::Request $req!) {
  2 0   2   5  
  2 0   0   364  
  2 0       15  
  2 0       5  
  2         5403  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1334 0         0 my $resp = $self->_get_response(
1335             req => $req,
1336             );
1337 0         0 my $ref = decode_json( $resp->content );
1338 0 0       0 if ( ref( $ref ) eq 'ARRAY' ) {
    0          
1339             # some list-type data structures are arrayrefs in API versions 2012-09-24 and earlier.
1340             # if those data structures are at the top level, such as when
1341             # we request 'GET /charges/cus_.../', we need to coerce that
1342             # arrayref into the form that Net::Stripe::List expects.
1343 0         0 return _array_to_object( $ref, $req->uri );
1344             } elsif ( ref( $ref ) eq 'HASH' ) {
1345             # all top-level data structures are hashes in API versions 2012-10-26 and later
1346 0         0 return _hash_to_object( $ref );
1347             } else {
1348 0   0     0 die Net::Stripe::Error->new(
1349             type => "HTTP request error",
1350             message => sprintf(
1351             "Invalid object type returned: '%s'",
1352             ref( $ref ) || 'NONREF',
1353             ),
1354             );
1355             }
1356             }
1357              
1358             sub _hash_to_object {
1359 3     3   1023 my $hash = shift;
1360              
1361 3 0 33     13 if ( exists( $hash->{deleted} ) && exists( $hash->{object} ) && $hash->{object} ne 'customer' ) {
      0        
1362 0         0 delete( $hash->{object} );
1363             }
1364              
1365             # coerce pre-2011-08-01 API arrayref list format into a hashref
1366             # compatible with Net::Stripe::List
1367 3         13 $hash = _pre_2011_08_01_processing( $hash );
1368              
1369             # coerce pre-2012-10-26 API invoice lines format into a hashref
1370             # compatible with Net::Stripe::List
1371 3         12 $hash = _pre_2012_10_26_processing( $hash );
1372              
1373             # coerce post-2015-02-18 source-type args to to card-type args
1374 3         8 $hash = _post_2015_02_18_processing( $hash );
1375              
1376             # coerce post-2019-10-17 balance to account_balance
1377 3         8 $hash = _post_2019_10_17_processing( $hash );
1378              
1379 3         21 foreach my $k (grep { ref($hash->{$_}) } keys %$hash) {
  36         72  
1380 5         31 my $v = $hash->{$k};
1381 5 100 100     40 if (ref($v) eq 'HASH' && defined($v->{object})) {
    100          
1382 2         23 $hash->{$k} = _hash_to_object($v);
1383             } elsif (ref($v) =~ /^(JSON::XS::Boolean|JSON::PP::Boolean)$/) {
1384 2 50       58 $hash->{$k} = $v ? 1 : 0;
1385             }
1386             }
1387              
1388 3 50       12 if (defined($hash->{object})) {
1389 3 50       9 if ($hash->{object} eq 'list') {
1390 0         0 $hash->{data} = [map { _hash_to_object($_) } @{$hash->{data}}];
  0         0  
  0         0  
1391 0         0 return Net::Stripe::List->new($hash);
1392             }
1393 3         12 my @words = map { ucfirst($_) } split('_', $hash->{object});
  4         16  
1394 3         10 my $object = join('', @words);
1395 3         7 my $class = 'Net::Stripe::' . $object;
1396 3 100       46 if (Class::Load::is_class_loaded($class)) {
1397 2         113 return $class->new($hash);
1398             }
1399             }
1400 1         4 return $hash;
1401             }
1402              
1403             sub _array_to_object {
1404 0     0   0 my ( $array, $uri ) = @_;
1405 0         0 my $list = _array_to_list( $array );
1406             # strip the protocol, domain and query args in order to mimic the
1407             # url returned with Stripe lists in API versions 2012-10-26 and later
1408 0         0 $uri =~ s#\?.*$##;
1409 0         0 $uri =~ s#^https://[^/]+##;
1410 0         0 $list->{url} = $uri;
1411 0         0 return _hash_to_object( $list );
1412             }
1413              
1414             sub _array_to_list {
1415 0     0   0 my $array = shift;
1416 0         0 my $count = scalar( @$array );
1417 0         0 my $list = {
1418             object => 'list',
1419             count => $count,
1420             has_more => 0,
1421             data => $array,
1422             total_count => $count,
1423             };
1424 0         0 return $list;
1425             }
1426              
1427             # coerce pre-2011-08-01 API arrayref list format into a hashref
1428             # compatible with Net::Stripe::List
1429             sub _pre_2011_08_01_processing {
1430 3     3   6 my $hash = shift;
1431 3         8 foreach my $type ( qw/ cards sources subscriptions / ) {
1432 9 50 33     53 if ( exists( $hash->{$type} ) && ref( $hash->{$type} ) eq 'ARRAY' ) {
1433 0         0 $hash->{$type} = _array_to_list( delete( $hash->{$type} ) );
1434 0         0 my $customer_id;
1435 0 0 0     0 if ( exists( $hash->{object} ) && $hash->{object} eq 'customer' && exists( $hash->{id} ) ) {
    0 0        
1436 0         0 $customer_id = $hash->{id};
1437             } elsif ( exists( $hash->{customer} ) ) {
1438 0         0 $customer_id = $hash->{customer};
1439             }
1440             # Net::Stripe::List->new() will fail without url, but we
1441             # can make debugging easier by providing a message here
1442 0 0       0 die Net::Stripe::Error->new(
1443             type => "object coercion error",
1444             message => sprintf(
1445             "Could not determine customer id while coercing %s list into Net::Stripe::List.",
1446             $type,
1447             ),
1448             ) unless $customer_id;
1449              
1450             # mimic the url sent with standard Stripe lists
1451 0         0 $hash->{$type}->{url} = "/v1/customers/$customer_id/$type";
1452             }
1453             }
1454              
1455 3         7 foreach my $type ( qw/ refunds / ) {
1456 3 50 33     13 if ( exists( $hash->{$type} ) && ref( $hash->{$type} ) eq 'ARRAY' ) {
1457 0         0 $hash->{$type} = _array_to_list( delete( $hash->{$type} ) );
1458 0         0 my $charge_id;
1459 0 0 0     0 if ( exists( $hash->{object} ) && $hash->{object} eq 'charge' && exists( $hash->{id} ) ) {
      0        
1460 0         0 $charge_id = $hash->{id};
1461             }
1462             # Net::Stripe::List->new() will fail without url, but we
1463             # can make debugging easier by providing a message here
1464 0 0       0 die Net::Stripe::Error->new(
1465             type => "object coercion error",
1466             message => sprintf(
1467             "Could not determine charge id while coercing %s list into Net::Stripe::List.",
1468             $type,
1469             ),
1470             ) unless $charge_id;
1471             # mimic the url sent with standard Stripe lists
1472 0         0 $hash->{$type}->{url} = "/v1/charges/$charge_id/$type";
1473             }
1474             }
1475              
1476 3         6 foreach my $type ( qw/ charges / ) {
1477 3 50 33     11 if ( exists( $hash->{$type} ) && ref( $hash->{$type} ) eq 'ARRAY' ) {
1478 0         0 $hash->{$type} = _array_to_list( delete( $hash->{$type} ) );
1479 0         0 my $payment_intent_id;
1480 0 0 0     0 if ( exists( $hash->{object} ) && $hash->{object} eq 'payment_intent' && exists( $hash->{id} ) ) {
    0 0        
1481 0         0 $payment_intent_id = $hash->{id};
1482             } elsif ( exists( $hash->{payment_intent} ) ) {
1483 0         0 $payment_intent_id = $hash->{payment_intent};
1484             }
1485             # Net::Stripe::List->new() will fail without url, but we
1486             # can make debugging easier by providing a message here
1487 0 0       0 die Net::Stripe::Error->new(
1488             type => "object coercion error",
1489             message => sprintf(
1490             "Could not determine payment_intent id while coercing %s list into Net::Stripe::List.",
1491             $type,
1492             ),
1493             ) unless $payment_intent_id;
1494              
1495             # mimic the url sent with standard Stripe lists
1496 0         0 $hash->{$type}->{url} = "/v1/charges?payment_intent=$payment_intent_id";
1497             }
1498             }
1499              
1500 3         6 return $hash;
1501             }
1502              
1503             # coerce pre-2012-10-26 API invoice lines format into a hashref
1504             # compatible with Net::Stripe::List
1505             sub _pre_2012_10_26_processing {
1506 3     3   8 my $hash = shift;
1507 3 0 33     48 if (
      33        
      0        
      0        
1508             exists( $hash->{object} ) && $hash->{object} eq 'invoice' &&
1509             exists( $hash->{lines} ) && ref( $hash->{lines} ) eq 'HASH' &&
1510             ! exists( $hash->{lines}->{object} )
1511             ) {
1512 0         0 my $data = [];
1513 0         0 my $lines = delete( $hash->{lines} );
1514 0         0 foreach my $key ( sort( keys( %$lines ) ) ) {
1515 0         0 my $ref = $lines->{$key};
1516 0 0       0 unless ( ref( $ref ) eq 'ARRAY' ) {
1517 0         0 die Net::Stripe::Error->new(
1518             type => "object coercion error",
1519             message => sprintf(
1520             "Found invalid subkey type '%s' while coercing invoice lines into a Net::Stripe::List.",
1521             ref( $ref ),
1522             ),
1523             );
1524             }
1525 0         0 foreach my $item ( @$ref ) {
1526 0         0 push @$data, $item;
1527             }
1528             }
1529 0         0 $hash->{lines} = _array_to_list( $data );
1530              
1531 0         0 my $customer_id;
1532 0 0       0 if ( exists( $hash->{customer} ) ) {
1533 0         0 $customer_id = $hash->{customer};
1534             }
1535             # Net::Stripe::List->new() will fail without url, but we
1536             # can make debugging easier by providing a message here
1537 0 0       0 die Net::Stripe::Error->new(
1538             type => "object coercion error",
1539             message => "Could not determine customer id while coercing invoice lines into Net::Stripe::List.",
1540             ) unless $customer_id;
1541              
1542             # mimic the url sent with standard Stripe lists
1543 0         0 $hash->{lines}->{url} = "/v1/invoices/upcoming/lines?customer=$customer_id";
1544             }
1545 3         8 return $hash;
1546             }
1547              
1548             # coerce post-2015-02-18 source-type args to to card-type args
1549             sub _post_2015_02_18_processing {
1550 3     3   6 my $hash = shift;
1551              
1552 3 50 33     22 if (
      33        
1553             exists( $hash->{object} ) &&
1554             ( $hash->{object} eq 'charge' || $hash->{object} eq 'customer' )
1555             ) {
1556 0 0 0     0 if (
      0        
      0        
      0        
1557             ! exists( $hash->{card} ) &&
1558             exists( $hash->{source} ) && ref( $hash->{source} ) eq 'HASH' &&
1559             exists( $hash->{source}->{object} ) && $hash->{source}->{object} eq 'card'
1560             ) {
1561 0         0 $hash->{card} = Storable::dclone( $hash->{source} );
1562             }
1563              
1564 0 0 0     0 if (
      0        
      0        
      0        
1565             ! exists( $hash->{cards} ) &&
1566             exists( $hash->{sources} ) && ref( $hash->{sources} ) eq 'HASH' &&
1567             exists( $hash->{sources}->{object} ) && $hash->{sources}->{object} eq 'list'
1568             ) {
1569 0         0 $hash->{cards} = Storable::dclone( $hash->{sources} );
1570             }
1571              
1572 0         0 my $card_id_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeCardId' );
1573 0 0 0     0 if (
      0        
1574             ! exists( $hash->{default_card} ) &&
1575             exists( $hash->{default_source} ) &&
1576             $card_id_type->check( $hash->{default_source} )
1577             ) {
1578 0         0 $hash->{default_card} = $hash->{default_source};
1579             }
1580             }
1581 3         7 return $hash;
1582             }
1583              
1584             # coerce post-2019-10-17 balance to account_balance
1585             fun _post_2019_10_17_processing(
1586             HashRef $hash,
1587 2 50   2   4909 ) {
  2 50   2   4  
  2 50   3   245  
  2 50       12  
  2         5  
  2         446  
  3         11  
  3         10  
  3         10  
  3         4  
  3         10  
  3         5  
  3         5  
1588 3 50 33     16 if ( exists( $hash->{object} ) && $hash->{object} eq 'customer' ) {
1589 0 0 0     0 if ( ! exists( $hash->{account_balance} ) && exists( $hash->{balance} ) ) {
1590 0         0 $hash->{account_balance} = $hash->{balance};
1591             }
1592             }
1593 3         7 return $hash;
1594             }
1595              
1596             method _get_all(
1597             Str :$path!,
1598             Maybe[Str] :$ending_before?,
1599             Maybe[Int] :$limit?,
1600             Maybe[Str] :$starting_after?,
1601             %object_filters,
1602 2 0 0 2   22315 ) {
  2 0 0 2   43  
  2 0   2   256  
  2 0   2   13  
  2 0   2   3  
  2 0   2   149  
  2 0   2   13  
  2 0   2   5  
  2 0   2   18  
  2 0   0   386  
  2 0       5  
  2 0       666  
  2 0       48  
  2 0       6  
  2 0       263  
  2 0       13  
  2 0       4  
  2         350  
  2         13  
  2         14  
  2         236  
  2         11  
  2         4  
  2         211  
  2         12  
  2         4  
  2         1140  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1603              
1604             # minimize the number of API calls by retrieving as many results as
1605             # possible per call. the API currently returns a maximum of 100 results.
1606 0         0 my $API_PAGE_SIZE = 100;
1607 0         0 my $PAGE_SIZE = $limit;
1608 0         0 my $GET_MORE;
1609 0 0 0     0 if ( defined( $limit ) && ( $limit eq '0' || $limit > $API_PAGE_SIZE ) ) {
      0        
1610 0         0 $PAGE_SIZE = $API_PAGE_SIZE;
1611 0         0 $GET_MORE = 1;
1612             }
1613              
1614 0         0 my %args = (
1615             %object_filters,
1616             ending_before => $ending_before,
1617             limit => $PAGE_SIZE,
1618             starting_after => $starting_after,
1619             );
1620 0         0 my $list = $self->_get($path, \%args);
1621              
1622 0 0 0     0 if ( $GET_MORE && $list->elements() > 0 ) {
1623             # passing 'ending_before' causes the API to start with the oldest
1624             # records. so in order to always provide records in reverse-chronological
1625             # order, we must prepend these to the existing records.
1626 0   0     0 my $REVERSE = defined( $ending_before ) && ! defined( $starting_after );
1627 0 0       0 my $MAX_COUNT = $limit eq '0' ? undef : $limit;
1628 0         0 while ( 1 ) {
1629 0         0 my $PAGE_SIZE = $API_PAGE_SIZE;
1630 0 0       0 if ( defined( $MAX_COUNT ) ) {
1631 0         0 my $TO_FETCH = $MAX_COUNT - scalar( $list->elements );
1632 0 0       0 last if $TO_FETCH <= 0;
1633 0 0       0 $PAGE_SIZE = $TO_FETCH if $TO_FETCH < $PAGE_SIZE;
1634             }
1635              
1636 0 0       0 my %args = (
1637             %object_filters,
1638             limit => $PAGE_SIZE,
1639             ( $REVERSE ? $list->_previous_page_args() : $list->_next_page_args() ),
1640             );
1641 0         0 my $page = $self->_get($path, \%args);
1642              
1643 0 0       0 last if $page->is_empty;
1644              
1645 0 0       0 $list = Net::Stripe::List::_merge_lists(
1646             lists => [ $REVERSE ?
1647             ( $page, $list ) :
1648             ( $list, $page )
1649             ],
1650             );
1651              
1652 0 0       0 last unless $page->has_more;
1653              
1654             }
1655             }
1656 0         0 return $list;
1657             }
1658              
1659             fun _encode_boolean(
1660             Bool $value!,
1661 2 50   2   4635 ) {
  2 50   2   5  
  2 50   3   289  
  2 50       15  
  2         4  
  2         354  
  3         1126  
  3         11  
  3         11  
  3         5  
  3         15  
  3         5  
  3         7  
1662             # a bare `return` with no arguemnts evaluates to an empty list, resulting
1663             # in 'odd number of elements in hash assignment, so we must return undef
1664 3 100       14 return undef unless defined( $value );
1665 2 100       15 return $value ? 'true' : 'false';
1666             }
1667              
1668 2 0   2   2608 method _build_api_base { 'https://api.stripe.com/v1' }
  2     0   5  
  2         195  
  0         0  
  0         0  
  0         0  
1669              
1670 2 0   2   2519 method _build_ua {
  2     0   4  
  2         288  
  0         0  
  0         0  
1671 0         0 my $ua = LWP::UserAgent->new(keep_alive => 4);
1672 0   0     0 $ua->agent("Net::Stripe/" . ($Net::Stripe::VERSION || 'dev'));
1673 0         0 return $ua;
1674             }
1675              
1676             # since the Stripe API does not have a ping-like method, we have to perform
1677             # an extraneous request in order to retrieve the Stripe-Version header with
1678             # the response. for now, we will use the 'balance' endpoint because it one of
1679             # the simplest and least-privileged.
1680             method _get_stripe_verison_header(
1681             Bool :$suppress_api_version? = 0,
1682 2 0 0 2   6376 ) {
  2 0 0 2   4  
  2 0   2   255  
  2 0   2   15  
  2 0   2   3  
  2     0   146  
  2         12  
  2         4  
  2         14  
  2         393  
  2         6  
  2         737  
  2         14  
  2         5  
  2         732  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
1683 0         0 my $path = 'balance';
1684 0         0 my $req = GET $self->api_base . '/' . $path;
1685              
1686             # swallow the possible invalid API version warning
1687 0     0   0 local $SIG{__WARN__} = sub {};
1688 0         0 my $resp = $self->_get_response(
1689             req => $req,
1690             suppress_api_version => $suppress_api_version,
1691             );
1692              
1693 0         0 my $stripe_version = $resp->header( 'Stripe-Version' );
1694 0         0 my $stripe_api_version_type = Moose::Util::TypeConstraints::find_type_constraint( 'StripeAPIVersion' );
1695 0 0 0     0 die Net::Stripe::Error->new(
    0          
1696             type => "API version validation error",
1697             message => sprintf( "Failed to retrieve the Stripe-Version header: '%s'",
1698             defined( $stripe_version ) ? $stripe_version : 'undefined',
1699             ),
1700             ) unless defined( $stripe_version ) && $stripe_api_version_type->check( $stripe_version );
1701              
1702 0         0 return $stripe_version;
1703             }
1704              
1705 2 0   2   2739 method _get_account_api_version {
  2     0   5  
  2         264  
  0         0  
  0         0  
1706 0         0 my $stripe_version = $self->_get_stripe_verison_header(
1707             suppress_api_version => 1,
1708             );
1709 0         0 return $stripe_version;
1710             }
1711              
1712             # if we have set an explicit API version, confirm that it is valid. if
1713             # it is invalid, _get_response() dies with an invalid_request_error.
1714 2 0   2   2729 method _validate_api_version_value {
  2     0   6  
  2         412  
  0         0  
  0         0  
1715 0 0       0 return unless defined( $self->api_version );
1716              
1717 0         0 my $stripe_version = $self->_get_stripe_verison_header();
1718 0 0       0 die Net::Stripe::Error->new(
1719             type => "API version validation error",
1720             message => sprintf( "Stripe API version mismatch. Sent: '%s'. Received: '%s'.",
1721             $self->api_version,
1722             $stripe_version,
1723             ),
1724             ) unless $stripe_version eq $self->api_version;
1725              
1726 0         0 return 1;
1727             }
1728              
1729             # if we have set an explicit API version, confirm that it is within the
1730             # appropriate range. otherwise, retrieve the default value for this
1731             # account and confirm that it is within the appropriate range.
1732 2 50   2   2867 method _validate_api_version_range {
  2     1   5  
  2         1393  
  1         5  
  1         4  
1733 1 50       47 if ( $self->force_api_version ) {
1734 0 0       0 warn "bypassing API version range safety check" if $self->debug;
1735 0         0 return 1;
1736             }
1737              
1738 1 50       40 my $api_version = defined( $self->api_version ) ? $self->api_version : $self->_get_account_api_version();
1739              
1740 1         7 my @api_version = split( '-', $api_version );
1741 1         2 my $api_version_dt;
1742 1         4 eval {
1743 1         43 $api_version_dt = DateTime->new(
1744             year => $api_version[0],
1745             month => $api_version[1],
1746             day => $api_version[2],
1747             time_zone => 'UTC',
1748             );
1749             };
1750 1 50       1528 if ( my $error = $@ ) {
1751 1         3146 die Net::Stripe::Error->new(
1752             type => "API version validation error",
1753             message => sprintf( "Invalid date string '%s' provided for api_version: %s",
1754             $api_version,
1755             $error,
1756             ),
1757             );
1758             }
1759              
1760 0           my @min_api_version = split( '-', Net::Stripe::Constants::MIN_API_VERSION );
1761 0           my $min_api_version_dt = DateTime->new(
1762             year => $min_api_version[0],
1763             month => $min_api_version[1],
1764             day => $min_api_version[2],
1765             time_zone => 'UTC',
1766             );
1767              
1768 0           my @max_api_version = split( '-', Net::Stripe::Constants::MAX_API_VERSION );
1769 0           my $max_api_version_dt = DateTime->new(
1770             year => $max_api_version[0],
1771             month => $max_api_version[1],
1772             day => $max_api_version[2],
1773             time_zone => 'UTC',
1774             );
1775              
1776 0           my $format = "Stripe API version %s is not supported by this version of Net::Stripe. " .
1777             "This version of Net::Stripe only supports Stripe API versions from %s to %s. " .
1778             "Please check for a version-appropriate branch at https://github.com/lukec/stripe-perl/branches.";
1779 0           my $message = sprintf( $format,
1780             $api_version,
1781             Net::Stripe::Constants::MIN_API_VERSION,
1782             Net::Stripe::Constants::MAX_API_VERSION,
1783             );
1784 0 0 0       die Net::Stripe::Error->new(
1785             type => "API version validation error",
1786             message => $message,
1787             ) unless $min_api_version_dt <= $api_version_dt && $api_version_dt <= $max_api_version_dt;
1788              
1789 0           return 1;
1790             }
1791              
1792              
1793             __PACKAGE__->meta->make_immutable;
1794             1;
1795              
1796             __END__
1797              
1798             =pod
1799              
1800             =head1 NAME
1801              
1802             Net::Stripe - API client for Stripe.com
1803              
1804             =head1 VERSION
1805              
1806             version 0.43
1807              
1808             =head1 SYNOPSIS
1809              
1810             my $stripe = Net::Stripe->new(api_key => $API_KEY);
1811             my $card_token = 'a token';
1812             my $charge = $stripe->post_charge( # Net::Stripe::Charge
1813             amount => 12500,
1814             currency => 'usd',
1815             source => $card_token,
1816             description => 'YAPC Registration',
1817             );
1818             print "Charge was not paid!\n" unless $charge->paid;
1819             my $card = $charge->card; # Net::Stripe::Card
1820              
1821             # look up a charge by id
1822             my $same_charge = $stripe->get_charge(charge_id => $charge->id);
1823              
1824             # ... and the API mirrors https://stripe.com/docs/api
1825             # Charges: post_charge() get_charge() refund_charge() get_charges()
1826             # Customer: post_customer()
1827              
1828             =head1 DESCRIPTION
1829              
1830             This module is a wrapper around the Stripe.com HTTP API. Methods are
1831             generally named after the HTTP method and the object name.
1832              
1833             This method returns Moose objects for responses from the API.
1834              
1835             =head2 VERSIONING
1836              
1837             Because of occasional non-backward-compatible changes in the Stripe API, a
1838             given version of the SDK is only guaranteed to support Stripe API versions
1839             within the range defined by C<Net::Stripe::Constants::MIN_API_VERSION> and
1840             C<Net::Stripe::Constants::MAX_API_VERSION>.
1841              
1842             If you need a version of the SDK supporting a specific older Stripe API
1843             version, you can check for available versions at
1844             L<https://github.com/lukec/stripe-perl/branches>, or by cloning this
1845             repository, located at <https://github.com/lukec/stripe-perl> and using
1846             <git branch> to view available version-specific branches.
1847              
1848             =head3 DEFAULT VERSIONING
1849              
1850             If you do not set the Stripe API version on object instantiation, API
1851             calls will default to the API version setting for your Stripe account.
1852              
1853             =head3 SPECIFIC VERSIONING
1854              
1855             If you set the Stripe API version on object instantiation you are telling
1856             Stripe to use that version of the API instead of the default for your account,
1857             and therefore the available API request and response parameters, the names of
1858             those parameters and the structure of the format of the returned data will all
1859             be dictated by the version that you specify. You can read more about the
1860             details of specific API versions at
1861             <https://stripe.com/docs/upgrades#api-changelog>.
1862              
1863             =head3 OUT OF SCOPE VERSIONING
1864              
1865             If you are wearing a cowboy hat and think - although your specified account
1866             version is outside the range defined in C<Net::Stripe::Constants> - that your
1867             use case is simple enough that it should "just work", you can create your
1868             object instance with C<force_api_version =E<gt> 1>, but don't say we didn't
1869             warn you!
1870              
1871             =head1 METHODS
1872              
1873             =head2 new PARAMHASH
1874              
1875             This creates a new stripe API object. The following parameters are accepted:
1876              
1877             =over
1878              
1879             =item api_key
1880              
1881             This is required. You get this from your Stripe Account settings.
1882              
1883             =item api_version
1884              
1885             This is the value of the Stripe-Version header <https://stripe.com/docs/api/versioning>
1886             you wish to transmit for API calls.
1887              
1888             =item force_api_version
1889              
1890             Set this to true to bypass the safety checks for API version compatibility with
1891             a given version of the SDK. Please see the warnings above, and remember that
1892             you are handling the financial data of your users. Use with extreme caution!
1893              
1894             =item debug
1895              
1896             You can set this to true to see extra debug info.
1897              
1898             =item debug_network
1899              
1900             You can set this to true to see the actual network requests.
1901              
1902             =back
1903              
1904             =head1 ATTRIBUTES
1905              
1906             =head2 api_base
1907              
1908             Reader: api_base
1909              
1910             Type: Str
1911              
1912             Additional documentation: This is the base part of the URL for every request made
1913              
1914             =head2 api_key
1915              
1916             Reader: api_key
1917              
1918             Type: Str
1919              
1920             This attribute is required.
1921              
1922             Additional documentation: You get this from your Stripe Account settings
1923              
1924             =head2 api_version
1925              
1926             Reader: api_version
1927              
1928             Type: StripeAPIVersion
1929              
1930             Additional documentation: This is the value of the Stripe-Version header you wish to transmit for API calls
1931              
1932             =head2 debug
1933              
1934             Reader: debug
1935              
1936             Writer: debug
1937              
1938             Type: Bool
1939              
1940             Additional documentation: The debug flag
1941              
1942             =head2 debug_network
1943              
1944             Reader: debug_network
1945              
1946             Writer: debug_network
1947              
1948             Type: Bool
1949              
1950             Additional documentation: The debug network request flag
1951              
1952             =head2 force_api_version
1953              
1954             Reader: force_api_version
1955              
1956             Type: Bool
1957              
1958             Additional documentation: Set this to true to bypass the safety checks for API version compatibility.
1959              
1960             =head2 ua
1961              
1962             Reader: ua
1963              
1964             Type: Object
1965              
1966             Additional documentation: The LWP::UserAgent that is used for requests
1967              
1968             =head1 Balance Transaction Methods
1969              
1970             =head2 get_balance_transaction
1971              
1972             Retrieve a balance transaction.
1973              
1974             L<https://stripe.com/docs/api#retrieve_balance_transaction>
1975              
1976             =over
1977              
1978             =item * id - Str - balance transaction ID to retrieve.
1979              
1980             =back
1981              
1982             Returns a L<Net::Stripe::BalanceTransaction>.
1983              
1984             $stripe->get_balance_transaction(id => 'id');
1985              
1986             =head1 Charge Methods
1987              
1988             =head2 post_charge
1989              
1990             Create a new charge.
1991              
1992             L<https://stripe.com/docs/api/charges/create#create_charge>
1993              
1994             =over
1995              
1996             =item * amount - Int - amount to charge
1997              
1998             =item * currency - Str - currency for charge
1999              
2000             =item * customer - StripeCustomerId - customer to charge - optional
2001              
2002             =item * card - StripeTokenId or StripeCardId - card to use - optional
2003              
2004             =item * source - StripeTokenId or StripeCardId - source to use - optional
2005              
2006             =item * description - Str - description for the charge - optional
2007              
2008             =item * metadata - HashRef - metadata for the charge - optional
2009              
2010             =item * capture - Bool - optional
2011              
2012             =item * statement_descriptor - Str - descriptor for statement - optional
2013              
2014             =item * application_fee - Int - optional
2015              
2016             =item * receipt_email - Str - The email address to send this charge's receipt to - optional
2017              
2018             =back
2019              
2020             Returns L<Net::Stripe::Charge>.
2021              
2022             $stripe->post_charge(currency => 'USD', amount => 500, customer => 'testcustomer');
2023              
2024             =head2 get_charge
2025              
2026             Retrieve a charge.
2027              
2028             L<https://stripe.com/docs/api#retrieve_charge>
2029              
2030             =over
2031              
2032             =item * charge_id - Str - charge id to retrieve
2033              
2034             =back
2035              
2036             Returns L<Net::Stripe::Charge>.
2037              
2038             $stripe->get_charge(charge_id => 'chargeid');
2039              
2040             =head2 refund_charge
2041              
2042             Refunds a charge.
2043              
2044             L<https://stripe.com/docs/api#create_refund>
2045              
2046             =over
2047              
2048             =item * charge - L<Net::Stripe::Charge> or Str - charge or charge_id to refund
2049              
2050             =item * amount - Int - amount to refund in cents, optional
2051              
2052             =back
2053              
2054             Returns a new L<Net::Stripe::Refund>.
2055              
2056             $stripe->refund_charge(charge => $charge, amount => 500);
2057              
2058             =head2 get_charges
2059              
2060             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Charge> objects.
2061              
2062             L<https://stripe.com/docs/api#list_charges>
2063              
2064             =over
2065              
2066             =item * created - HashRef - created conditions to match, optional
2067              
2068             =item * customer - L<Net::Stripe::Customer> or Str - customer to match
2069              
2070             =item * ending_before - Str - ending before condition, optional
2071              
2072             =item * limit - Int - maximum number of charges to return, optional
2073              
2074             =item * starting_after - Str - starting after condition, optional
2075              
2076             =back
2077              
2078             Returns a list of L<Net::Stripe::Charge> objects.
2079              
2080             $stripe->get_charges(customer => $customer, limit => 5);
2081              
2082             =head2 capture_charge
2083              
2084             L<https://stripe.com/docs/api/charges/capture#capture_charge>
2085              
2086             =over
2087              
2088             =item * charge - L<Net::Stripe::Charge> or Str - charge to capture
2089              
2090             =item * amount - Int - amount to capture
2091              
2092             =back
2093              
2094             Returns a L<Net::Stripe::Charge>.
2095              
2096             $stripe->capture_charge(charge => $charge_id);
2097              
2098             =head1 Customer Methods
2099              
2100             =head2 post_customer
2101              
2102             Create or update a customer.
2103              
2104             L<https://stripe.com/docs/api/customers/create#create_customer>
2105             L<https://stripe.com/docs/api/customers/update#update_customer>
2106              
2107             =over
2108              
2109             =item * customer - L<Net::Stripe::Customer> or StripeCustomerId - existing customer to update, optional
2110              
2111             =item * account_balance - Int, optional
2112              
2113             =item * balance - Int, optional
2114              
2115             =item * card - L<Net::Stripe::Token> or StripeTokenId, default card for the customer, optional
2116              
2117             =item * source - StripeTokenId or StripeSourceId, source for the customer, optional
2118              
2119             =item * coupon - Str, optional
2120              
2121             =item * default_card - L<Net::Stripe::Token>, L<Net::Stripe::Card>, Str or HashRef, default card for the customer, optional
2122              
2123             =item * default_source - StripeCardId or StripeSourceId, default source for the customer, optional
2124              
2125             =item * description - Str, optional
2126              
2127             =item * email - Str, optional
2128              
2129             =item * metadata - HashRef, optional
2130              
2131             =item * plan - Str, optional
2132              
2133             =item * quantity - Int, optional
2134              
2135             =item * trial_end - Int or Str, optional
2136              
2137             =back
2138              
2139             Returns a L<Net::Stripe::Customer> object.
2140              
2141             my $customer = $stripe->post_customer(
2142             source => $token_id,
2143             email => 'stripe@example.com',
2144             description => 'Test for Net::Stripe',
2145             );
2146              
2147             =head2 list_subscriptions
2148              
2149             Returns the subscriptions for a customer.
2150              
2151             L<https://stripe.com/docs/api#list_subscriptions>
2152              
2153             =over
2154              
2155             =item * customer - L<Net::Stripe::Customer> or Str
2156              
2157             =item * ending_before - Str, optional
2158              
2159             =item * limit - Int, optional
2160              
2161             =item * starting_after - Str, optional
2162              
2163             =back
2164              
2165             Returns a list of L<Net::Stripe::Subscription> objects.
2166              
2167             =head2 get_customer
2168              
2169             Retrieve a customer.
2170              
2171             L<https://stripe.com/docs/api#retrieve_customer>
2172              
2173             =over
2174              
2175             =item * customer_id - Str - the customer id to retrieve
2176              
2177             =back
2178              
2179             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Customer> objects.
2180              
2181             $stripe->get_customer(customer_id => $id);
2182              
2183             =head2 delete_customer
2184              
2185             Delete a customer.
2186              
2187             L<https://stripe.com/docs/api#delete_customer>
2188              
2189             =over
2190              
2191             =item * customer - L<Net::Stripe::Customer> or Str - the customer to delete
2192              
2193             =back
2194              
2195             Returns a L<Net::Stripe::Customer> object.
2196              
2197             $stripe->delete_customer(customer => $customer);
2198              
2199             =head2 get_customers
2200              
2201             Returns a list of customers.
2202              
2203             L<https://stripe.com/docs/api#list_customers>
2204              
2205             =over
2206              
2207             =item * created - HashRef - created conditions, optional
2208              
2209             =item * ending_before - Str, optional
2210              
2211             =item * limit - Int, optional
2212              
2213             =item * starting_after - Str, optional
2214              
2215             =back
2216              
2217             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Customer> objects.
2218              
2219             $stripe->get_customers(limit => 7);
2220              
2221             =head1 Card Methods
2222              
2223             =head2 get_card
2224              
2225             Retrieve information about a customer's card.
2226              
2227             L<https://stripe.com/docs/api#retrieve_card>
2228              
2229             =over
2230              
2231             =item * customer - L<Net::Stripe::Customer> or Str - the customer
2232              
2233             =item * card_id - Str - the card ID to retrieve
2234              
2235             =back
2236              
2237             Returns a L<Net::Stripe::Card>.
2238              
2239             $stripe->get_card(customer => 'customer_id', card_id => 'abcdef');
2240              
2241             =head2 post_card
2242              
2243             Create a card.
2244              
2245             L<https://stripe.com/docs/api/cards/create#create_card>
2246              
2247             =over
2248              
2249             =item * customer - L<Net::Stripe::Customer> or StripeCustomerId
2250              
2251             =item * card - L<Net::Stripe::Token> or StripeTokenId
2252              
2253             =item * source - StripeTokenId
2254              
2255             =back
2256              
2257             Returns a L<Net::Stripe::Card>.
2258              
2259             $stripe->post_card(customer => $customer, source => $token_id);
2260              
2261             =head2 update_card
2262              
2263             Update a card.
2264              
2265             L<https://stripe.com/docs/api/cards/update#update_card>
2266              
2267             =over
2268              
2269             =item * customer_id - StripeCustomerId
2270              
2271             =item * card_id - StripeCardId
2272              
2273             =item * card - HashRef
2274              
2275             =back
2276              
2277             Returns a L<Net::Stripe::Card>.
2278              
2279             $stripe->update_card(
2280             customer_id => $customer_id,
2281             card_id => $card_id,
2282             card => {
2283             name => $new_name,
2284             metadata => {
2285             'account-number' => $new_account_nunmber,
2286             },
2287             },
2288             );
2289              
2290             =head2 get_cards
2291              
2292             Returns a list of cards.
2293              
2294             L<https://stripe.com/docs/api#list_cards>
2295              
2296             =over
2297              
2298             =item * customer - L<Net::Stripe::Customer> or Str
2299              
2300             =item * ending_before - Str, optional
2301              
2302             =item * limit - Int, optional
2303              
2304             =item * starting_after - Str, optional
2305              
2306             =back
2307              
2308             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Card> objects.
2309              
2310             $stripe->list_cards(customer => 'abcdec', limit => 10);
2311              
2312             =head2 delete_card
2313              
2314             Delete a card.
2315              
2316             L<https://stripe.com/docs/api#delete_card>
2317              
2318             =over
2319              
2320             =item * customer - L<Net::Stripe::Customer> or Str
2321              
2322             =item * card - L<Net::Stripe::Card> or Str
2323              
2324             =back
2325              
2326             Returns a L<Net::Stripe::Card>.
2327              
2328             $stripe->delete_card(customer => $customer, card => $card);
2329              
2330             =head1 Source Methods
2331              
2332             =head2 create_source
2333              
2334             Create a new source object
2335              
2336             L<https://stripe.com/docs/api/sources/create#create_source>
2337              
2338             =over
2339              
2340             =item * amount - Int - amount associated with the source
2341              
2342             =item * currency - Str - currency associated with the source
2343              
2344             =item * flow - StripeSourceFlow - authentication flow for the source
2345              
2346             =item * mandate - HashRef - information about a mandate attached to the source
2347              
2348             =item * metadata - HashRef - metadata for the source
2349              
2350             =item * owner - HashRef - information about the owner of the payment instrument
2351              
2352             =item * receiver - HashRef - parameters for the receiver flow
2353              
2354             =item * redirect - HashRef - parameters required for the redirect flow
2355              
2356             =item * source_order - HashRef - information about the items and shipping associated with the source
2357              
2358             =item * statement_descriptor - Str - descriptor for statement
2359              
2360             =item * token - StripeTokenId - token used to create the source
2361              
2362             =item * type - StripeSourceType - type of source to create - required
2363              
2364             =item * usage - StripeSourceUsage - whether the source should be reusable or not
2365              
2366             =back
2367              
2368             Returns a L<Net::Stripe::Source>
2369              
2370             $stripe->create_source(
2371             type => 'card',
2372             token => $token_id,
2373             );
2374              
2375             =head2 get_source
2376              
2377             Retrieve an existing source object
2378              
2379             L<https://stripe.com/docs/api/sources/retrieve#retrieve_source>
2380              
2381             =over
2382              
2383             =item * source_id - StripeSourceId - id of source to retrieve - required
2384              
2385             =item * client_secret - Str - client secret of the source
2386              
2387             =back
2388              
2389             Returns a L<Net::Stripe::Source>
2390              
2391             $stripe->get_source(
2392             source_id => $source_id,
2393             );
2394              
2395             =head2 update_source
2396              
2397             Update the specified source by setting the values of the parameters passed
2398              
2399             L<https://stripe.com/docs/api/sources/update#update_source>
2400              
2401             =over
2402              
2403             =item * source_id - StripeSourceId - id of source to update - required
2404              
2405             =item * amount - Int - amount associated with the source
2406              
2407             =item * metadata - HashRef - metadata for the source
2408              
2409             =item * mandate - HashRef - information about a mandate attached to the source
2410              
2411             =item * owner - HashRef - information about the owner of the payment instrument
2412              
2413             =item * source_order - HashRef - information about the items and shipping associated with the source
2414              
2415             =back
2416              
2417             Returns a L<Net::Stripe::Source>
2418              
2419             $stripe->update_source(
2420             source_id => $source_id,
2421             owner => {
2422             email => $new_email,
2423             phone => $new_phone,
2424             },
2425             );
2426              
2427             =head2 attach_source
2428              
2429             Attaches a Source object to a Customer
2430              
2431             L<https://stripe.com/docs/api/sources/attach#attach_source>
2432              
2433             =over
2434              
2435             =item * source_id - StripeSourceId - id of source to be attached - required
2436              
2437             =item * customer_id - StripeCustomerId - id of customer to which source should be attached - required
2438              
2439             =back
2440              
2441             Returns a L<Net::Stripe::Source>
2442              
2443             $stripe->attach_source(
2444             customer_id => $customer_id,
2445             source_id => $source->id,
2446             );
2447              
2448             =head2 detach_source
2449              
2450             Detaches a Source object from a Customer
2451              
2452             L<https://stripe.com/docs/api/sources/detach#detach_source>
2453              
2454             =over
2455              
2456             =item * source_id - StripeSourceId - id of source to be detached - required
2457              
2458             =item * customer_id - StripeCustomerId - id of customer from which source should be detached - required
2459              
2460             =back
2461              
2462             Returns a L<Net::Stripe::Source>
2463              
2464             $stripe->detach_source(
2465             customer_id => $customer_id,
2466             source_id => $source->id,
2467             );
2468              
2469             =head2 list_sources
2470              
2471             List all sources belonging to a Customer
2472              
2473             =over
2474              
2475             =item * customer_id - StripeCustomerId - id of customer for which source to list sources - required
2476              
2477             =item * object - Str - object type - required
2478              
2479             =item * ending_before - Str - ending before condition
2480              
2481             =item * limit - Int - maximum number of charges to return
2482              
2483             =item * starting_after - Str - starting after condition
2484              
2485             =back
2486              
2487             Returns a L<Net::Stripe::List> object containing objects of the requested type
2488              
2489             $stripe->list_sources(
2490             customer_id => $customer_id,
2491             object => 'card',
2492             limit => 10,
2493             );
2494              
2495             =head1 Subscription Methods
2496              
2497             =head2 post_subscription
2498              
2499             Adds or updates a subscription for a customer.
2500              
2501             L<https://stripe.com/docs/api#create_subscription>
2502              
2503             =over
2504              
2505             =item * customer - L<Net::Stripe::Customer>
2506              
2507             =item * subscription - L<Net::Stripe::Subscription> or Str
2508              
2509             =item * card - L<Net::Stripe::Card>, L<Net::Stripe::Token> or Str, default card for the customer, optional
2510              
2511             =item * coupon - Str, optional
2512              
2513             =item * description - Str, optional
2514              
2515             =item * plan - Str, optional
2516              
2517             =item * quantity - Int, optional
2518              
2519             =item * trial_end - Int, or Str optional
2520              
2521             =item * application_fee_percent - Int, optional
2522              
2523             =item * prorate - Bool, optional
2524              
2525             =item * cancel_at_period_end - Bool, optional
2526              
2527             =back
2528              
2529             Returns a L<Net::Stripe::Subscription> object.
2530              
2531             $stripe->post_subscription(customer => $customer, plan => 'testplan');
2532              
2533             =head2 get_subscription
2534              
2535             Returns a customer's subscription.
2536              
2537             =over
2538              
2539             =item * customer - L<Net::Stripe::Customer> or Str
2540              
2541             =back
2542              
2543             Returns a L<Net::Stripe::Subscription>.
2544              
2545             $stripe->get_subscription(customer => 'test123');
2546              
2547             =head2 delete_subscription
2548              
2549             Cancel a customer's subscription.
2550              
2551             L<https://stripe.com/docs/api#cancel_subscription>
2552              
2553             =over
2554              
2555             =item * customer - L<Net::Stripe::Customer> or Str
2556              
2557             =item * subscription - L<Net::Stripe::Subscription> or Str
2558              
2559             =item * at_period_end - Bool, optional
2560              
2561             =back
2562              
2563             Returns a L<Net::Stripe::Subscription> object.
2564              
2565             $stripe->delete_subscription(customer => $customer, subscription => $subscription);
2566              
2567             =head1 Token Methods
2568              
2569             =head2 get_token
2570              
2571             Retrieves an existing token.
2572              
2573             L<https://stripe.com/docs/api#retrieve_token>
2574              
2575             =over
2576              
2577             =item * token_id - Str
2578              
2579             =back
2580              
2581             Returns a L<Net::Stripe::Token>.
2582              
2583             $stripe->get_token(token_id => 'testtokenid');
2584              
2585             =head1 Product Methods
2586              
2587             =head2 create_product
2588              
2589             Create a new Product
2590              
2591             L<https://stripe.com/docs/api/products/create#create_product>
2592             L<https://stripe.com/docs/api/service_products/create#create_service_product>
2593              
2594             =over
2595              
2596             =item * name - Str - name of the product - required
2597              
2598             =item * active - Bool - whether the product is currently available for purchase
2599              
2600             =item * attributes - ArrayRef[Str] - a list of attributes that each sku can provide values for
2601              
2602             =item * caption - Str - a short description
2603              
2604             =item * deactivate_on - ArrayRef[Str] - an list of connect application identifiers that cannot purchase this product
2605              
2606             =item * description - Str - description
2607              
2608             =item * id - Str - unique identifier
2609              
2610             =item * images - ArrayRef[Str] - a list of image URLs
2611              
2612             =item * metadata - HashRef[Str] - metadata
2613              
2614             =item * package_dimensions - HashRef - package dimensions for shipping
2615              
2616             =item * shippable - Bool - whether the product is a shipped good
2617              
2618             =item * statement_descriptor - Str - descriptor for statement
2619              
2620             =item * type - StripeProductType - the type of the product
2621              
2622             =item * unit_label - Str - label that represents units of the product
2623              
2624             =item * url - Str - URL of a publicly-accessible web page for the product
2625              
2626             =back
2627              
2628             Returns a L<Net::Stripe::Product>
2629              
2630             $stripe->create_product(
2631             name => $product_name,
2632             type => 'good',
2633             );
2634              
2635             =head2 get_product
2636              
2637             Retrieve an existing Product
2638              
2639             L<https://stripe.com/docs/api/products/retrieve#retrieve_product>
2640             L<https://stripe.com/docs/api/service_products/retrieve#retrieve_service_product>
2641              
2642             =over
2643              
2644             =item * product_id - StripeProductId|Str - id of product to retrieve - required
2645              
2646             =back
2647              
2648             Returns a L<Net::Stripe::Product>
2649              
2650             $stripe->get_product(
2651             product_id => $product_id,
2652             );
2653              
2654             =head2 update_product
2655              
2656             Update an existing Product
2657              
2658             L<https://stripe.com/docs/api/products/update#update_product>
2659             L<https://stripe.com/docs/api/service_products/update#update_service_product>
2660              
2661             =over
2662              
2663             =item * product_id - StripeProductId|Str - id of product to retrieve - required
2664              
2665             =item * active - Bool - whether the product is currently available for purchase
2666              
2667             =item * attributes - ArrayRef[Str] - a list of attributes that each sku can provide values for
2668              
2669             =item * caption - Str - a short description
2670              
2671             =item * deactivate_on - ArrayRef[Str] - an list of connect application identifiers that cannot purchase this product
2672              
2673             =item * description - Str - description
2674              
2675             =item * images - ArrayRef[Str] - a list of image URLs
2676              
2677             =item * metadata - HashRef[Str] - metadata
2678              
2679             =item * name - Str - name of the product
2680              
2681             =item * package_dimensions - HashRef - package dimensions for shipping
2682              
2683             =item * shippable - Bool - whether the product is a shipped good
2684              
2685             =item * statement_descriptor - Str - descriptor for statement
2686              
2687             =item * type - StripeProductType - the type of the product
2688              
2689             =item * unit_label - Str - label that represents units of the product
2690              
2691             =item * url - Str - URL of a publicly-accessible web page for the product
2692              
2693             =back
2694              
2695             Returns a L<Net::Stripe::Product>
2696              
2697             $stripe->update_product(
2698             product_id => $product_id,
2699             name => $new_name,
2700             );
2701              
2702             =head2 list_products
2703              
2704             Retrieve a list of Products
2705              
2706             L<https://stripe.com/docs/api/products/list#list_products>
2707             L<https://stripe.com/docs/api/service_products/list#list_service_products>
2708              
2709             =over
2710              
2711             =item * active - Bool - only return products that are active or inactive
2712              
2713             =item * ids - StripeProductId|Str - only return products with the given ids
2714              
2715             =item * shippable - Bool - only return products that can or cannot be shipped
2716              
2717             =item * url - Str - only return products with the given url
2718              
2719             =item * type - StripeProductType - only return products of this type
2720              
2721             =item * created - HashRef[Str] - created conditions to match
2722              
2723             =item * ending_before - Str - ending before condition
2724              
2725             =item * limit - Int - maximum number of objects to return
2726              
2727             =item * starting_after - Str - starting after condition
2728              
2729             =back
2730              
2731             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Product> objects.
2732              
2733             $stripe->list_products(
2734             limit => 5,
2735             );
2736              
2737             =head2 delete_product
2738              
2739             Delete an existing Product
2740              
2741             L<https://stripe.com/docs/api/products/delete#delete_product>
2742             L<https://stripe.com/docs/api/service_products/delete#delete_service_product>
2743              
2744             =over
2745              
2746             =item * product_id - StripeProductId|Str - id of product to delete - required
2747              
2748             =back
2749              
2750             Returns hashref of the form
2751              
2752             {
2753             deleted => <bool>,
2754             id => <product_id>,
2755             }
2756              
2757             $stripe->delete_product(
2758             product_id => $product_id,
2759             );
2760              
2761             =head1 Plan Methods
2762              
2763             =head2 post_plan
2764              
2765             Create a new plan.
2766              
2767             L<https://stripe.com/docs/api#create_plan>
2768              
2769             =over
2770              
2771             =item * id - Str - identifier of the plan
2772              
2773             =item * amount - Int - cost of the plan in cents
2774              
2775             =item * currency - Str
2776              
2777             =item * interval - Str
2778              
2779             =item * interval_count - Int - optional
2780              
2781             =item * name - Str - name of the plan
2782              
2783             =item * trial_period_days - Int - optional
2784              
2785             =item * statement_descriptor - Str - optional
2786              
2787             =item * metadata - HashRef - optional
2788              
2789             =back
2790              
2791             Returns a L<Net::Stripe::Plan> object.
2792              
2793             $stripe->post_plan(
2794             id => "free-$future_ymdhms",
2795             amount => 0,
2796             currency => 'usd',
2797             interval => 'year',
2798             name => "Freeplan $future_ymdhms",
2799             );
2800              
2801             =head2 get_plan
2802              
2803             Retrieves a plan.
2804              
2805             =over
2806              
2807             =item * plan_id - Str
2808              
2809             =back
2810              
2811             Returns a L<Net::Stripe::Plan>.
2812              
2813             $stripe->get_plan(plan_id => 'plan123');
2814              
2815             =head2 delete_plan
2816              
2817             Delete a plan.
2818              
2819             L<https://stripe.com/docs/api#delete_plan>
2820              
2821             =over
2822              
2823             =item * plan_id - L<Net::Stripe::Plan> or Str
2824              
2825             =back
2826              
2827             Returns a L<Net::Stripe::Plan> object.
2828              
2829             $stripe->delete_plan(plan_id => $plan);
2830              
2831             =head2 get_plans
2832              
2833             Return a list of plans.
2834              
2835             L<https://stripe.com/docs/api#list_plans>
2836              
2837             =over
2838              
2839             =item * product - StripeProductId|Str - only return plans for the given product
2840              
2841             =item * ending_before - Str, optional
2842              
2843             =item * limit - Int, optional
2844              
2845             =item * starting_after - Str, optional
2846              
2847             =back
2848              
2849             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Plan> objects.
2850              
2851             $stripe->get_plans(limit => 10);
2852              
2853             =head1 Coupon Methods
2854              
2855             =head2 post_coupon
2856              
2857             Create or update a coupon.
2858              
2859             L<https://stripe.com/docs/api#create_coupon>
2860              
2861             =over
2862              
2863             =item * id - Str, optional
2864              
2865             =item * duration - Str
2866              
2867             =item * amount_offset - Int, optional
2868              
2869             =item * currency - Str, optional
2870              
2871             =item * duration_in_months - Int, optional
2872              
2873             =item * max_redemptions - Int, optional
2874              
2875             =item * metadata - HashRef, optional
2876              
2877             =item * percent_off - Int, optional
2878              
2879             =item * redeem_by - Int, optional
2880              
2881             =back
2882              
2883             Returns a L<Net::Stripe::Coupon> object.
2884              
2885             $stripe->post_coupon(
2886             id => $coupon_id,
2887             percent_off => 100,
2888             duration => 'once',
2889             max_redemptions => 1,
2890             redeem_by => time() + 100,
2891             );
2892              
2893             =head2 get_coupon
2894              
2895             Retrieve a coupon.
2896              
2897             L<https://stripe.com/docs/api#retrieve_coupon>
2898              
2899             =over
2900              
2901             =item * coupon_id - Str
2902              
2903             =back
2904              
2905             Returns a L<Net::Stripe::Coupon> object.
2906              
2907             $stripe->get_coupon(coupon_id => 'id');
2908              
2909             =head2 delete_coupon
2910              
2911             Delete a coupon.
2912              
2913             L<https://stripe.com/docs/api#delete_coupon>
2914              
2915             =over
2916              
2917             =item * coupon_id - Str
2918              
2919             =back
2920              
2921             Returns a L<Net::Stripe::Coupon>.
2922              
2923             $stripe->delete_coupon(coupon_id => 'coupon123');
2924              
2925             =head2 get_coupons
2926              
2927             =over
2928              
2929             =item * ending_before - Str, optional
2930              
2931             =item * limit - Int, optional
2932              
2933             =item * starting_after - Str, optional
2934              
2935             =back
2936              
2937             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Coupon> objects.
2938              
2939             $stripe->get_coupons(limit => 15);
2940              
2941             =head1 Invoice Methods
2942              
2943             =head2 post_invoice
2944              
2945             Update an invoice.
2946              
2947             =over
2948              
2949             =item * invoice - L<Net::Stripe::Invoice>, Str
2950              
2951             =item * application_fee - Int - optional
2952              
2953             =item * closed - Bool - optional
2954              
2955             =item * description - Str - optional
2956              
2957             =item * metadata - HashRef - optional
2958              
2959             =back
2960              
2961             Returns a L<Net::Stripe::Invoice>.
2962              
2963             $stripe->post_invoice(invoice => $invoice, closed => 1)
2964              
2965             =head2 get_invoice
2966              
2967             =over
2968              
2969             =item * invoice_id - Str
2970              
2971             =back
2972              
2973             Returns a L<Net::Stripe::Invoice>.
2974              
2975             $stripe->get_invoice(invoice_id => 'testinvoice');
2976              
2977             =head2 pay_invoice
2978              
2979             =over
2980              
2981             =item * invoice_id - Str
2982              
2983             =back
2984              
2985             Returns a L<Net::Stripe::Invoice>.
2986              
2987             $stripe->pay_invoice(invoice_id => 'testinvoice');
2988              
2989             =head2 get_invoices
2990              
2991             Returns a list of invoices.
2992              
2993             L<https://stripe.com/docs/api#list_customer_invoices>
2994              
2995             =over
2996              
2997             =item * customer - L<Net::Stripe::Customer> or Str, optional
2998              
2999             =item * date - Int or HashRef, optional
3000              
3001             =item * ending_before - Str, optional
3002              
3003             =item * limit - Int, optional
3004              
3005             =item * starting_after - Str, optional
3006              
3007             =back
3008              
3009             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Invoice> objects.
3010              
3011             $stripe->get_invoices(limit => 10);
3012              
3013             =head2 create_invoice
3014              
3015             Create a new invoice.
3016              
3017             L<https://stripe.com/docs/api#create_invoice>
3018              
3019             =over
3020              
3021             =item * customer - L<Net::Stripe::Customer>, Str
3022              
3023             =item * application_fee - Int - optional
3024              
3025             =item * description - Str - optional
3026              
3027             =item * metadata - HashRef - optional
3028              
3029             =item * subscription - L<Net::Stripe::Subscription> or Str, optional
3030              
3031             =back
3032              
3033             Returns a L<Net::Stripe::Invoice>.
3034              
3035             $stripe->create_invoice(customer => 'custid', description => 'test');
3036              
3037             =head2 get_invoice
3038              
3039             =over
3040              
3041             =item * invoice_id - Str
3042              
3043             =back
3044              
3045             Returns a L<Net::Stripe::Invoice>.
3046              
3047             $stripe->get_invoice(invoice_id => 'test');
3048              
3049             =head2 get_upcominginvoice
3050              
3051             =over
3052              
3053             =item * customer, L<Net::Stripe::Customer> or Str
3054              
3055             =back
3056              
3057             Returns a L<Net::Stripe::Invoice>.
3058              
3059             $stripe->get_upcominginvoice(customer => $customer);
3060              
3061             =head1 Invoice Item Methods
3062              
3063             =head2 create_invoiceitem
3064              
3065             Create an invoice item.
3066              
3067             L<https://stripe.com/docs/api#create_invoiceitem>
3068              
3069             =over
3070              
3071             =item * customer - L<Net::Stripe::Customer> or Str
3072              
3073             =item * amount - Int
3074              
3075             =item * currency - Str
3076              
3077             =item * invoice - L<Net::Stripe::Invoice> or Str, optional
3078              
3079             =item * subscription - L<Net::Stripe::Subscription> or Str, optional
3080              
3081             =item * description - Str, optional
3082              
3083             =item * metadata - HashRef, optional
3084              
3085             =back
3086              
3087             Returns a L<Net::Stripe::Invoiceitem> object.
3088              
3089             $stripe->create_invoiceitem(customer => 'test', amount => 500, currency => 'USD');
3090              
3091             =head2 post_invoiceitem
3092              
3093             Update an invoice item.
3094              
3095             L<https://stripe.com/docs/api#create_invoiceitem>
3096              
3097             =over
3098              
3099             =item * invoice_item - L<Net::Stripe::Invoiceitem> or Str
3100              
3101             =item * amount - Int, optional
3102              
3103             =item * description - Str, optional
3104              
3105             =item * metadata - HashRef, optional
3106              
3107             =back
3108              
3109             Returns a L<Net::Stripe::Invoiceitem>.
3110              
3111             $stripe->post_invoiceitem(invoice_item => 'itemid', amount => 750);
3112              
3113             =head2 get_invoiceitem
3114              
3115             Retrieve an invoice item.
3116              
3117             =over
3118              
3119             =item * invoice_item - Str
3120              
3121             =back
3122              
3123             Returns a L<Net::Stripe::Invoiceitem>.
3124              
3125             $stripe->get_invoiceitem(invoice_item => 'testitemid');
3126              
3127             =head2 delete_invoiceitem
3128              
3129             Delete an invoice item.
3130              
3131             =over
3132              
3133             =item * invoice_item - L<Net::Stripe::Invoiceitem> or Str
3134              
3135             =back
3136              
3137             Returns a L<Net::Stripe::Invoiceitem>.
3138              
3139             $stripe->delete_invoiceitem(invoice_item => $invoice_item);
3140              
3141             =head2 get_invoiceitems
3142              
3143             =over
3144              
3145             =item * customer - L<Net::Stripe::Customer> or Str, optional
3146              
3147             =item * date - Int or HashRef, optional
3148              
3149             =item * ending_before - Str, optional
3150              
3151             =item * limit - Int, optional
3152              
3153             =item * starting_after - Str, optional
3154              
3155             =back
3156              
3157             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::Invoiceitem> objects.
3158              
3159             $stripe->get_invoiceitems(customer => 'test', limit => 30);
3160              
3161             =head1 Discount Methods
3162              
3163             =head2 delete_customer_discount
3164              
3165             Deletes a customer-wide discount.
3166              
3167             L<https://stripe.com/docs/api/curl#delete_discount>
3168              
3169             =over
3170              
3171             =item * customer - L<Net::Stripe::Customer> or Str - the customer with a discount to delete
3172              
3173             =back
3174              
3175             $stripe->delete_customer_discount(customer => $customer);
3176              
3177             Returns hashref of the form
3178              
3179             {
3180             deleted => <bool>
3181             }
3182              
3183             =head1 Payment Method Methods
3184              
3185             =head2 create_payment_method
3186              
3187             Create a PaymentMethod
3188              
3189             L<https://stripe.com/docs/api/payment_methods/create#create_payment_method>
3190              
3191             =over
3192              
3193             =item * type - StripePaymentMethodType - type of PaymentMethod - required
3194              
3195             =item * card - StripeTokenId - Token id for card associated with the PaymentMethod
3196              
3197             =item * billing_details - HashRef - billing information associated with the PaymentMethod
3198              
3199             =item * fpx - HashRef - details about the FPX payment method
3200              
3201             =item * ideal - HashRef - details about the iDEAL payment method
3202              
3203             =item * metadata - HashRef[Str] - metadata
3204              
3205             =item * sepa_debit - HashRef - details about the SEPA debit bank account
3206              
3207             =back
3208              
3209             Returns a L<Net::Stripe::PaymentMethod>.
3210              
3211             $stripe->create_payment_method(
3212             type => 'card',
3213             card => $token_id,
3214             );
3215              
3216             =head2 get_payment_method
3217              
3218             Retrieve an existing PaymentMethod
3219              
3220             L<https://stripe.com/docs/api/payment_methods/retrieve#retrieve_payment_method>
3221              
3222             =over
3223              
3224             =item * payment_method_id - StripePaymentMethodId - id of PaymentMethod to retrieve - required
3225              
3226             =back
3227              
3228             Returns a L<Net::Stripe::PaymentMethod>
3229              
3230             $stripe->get_payment_method(
3231             payment_method_id => $payment_method_id,
3232             );
3233              
3234             =head2 update_payment_method
3235              
3236             Update a PaymentMethod
3237              
3238             L<https://stripe.com/docs/api/payment_methods/update#update_payment_method>
3239              
3240             =over
3241              
3242             =item * payment_method_id - StripePaymentMethodId - id of PaymentMethod to update - required
3243              
3244             =item * billing_details - HashRef - billing information associated with the PaymentMethod
3245              
3246             =item * card - HashRef[Int] - card details to update
3247              
3248             =item * metadata - HashRef[Str] - metadata
3249              
3250             =item * sepa_debit - HashRef - details about the SEPA debit bank account
3251              
3252             =back
3253              
3254             Returns a L<Net::Stripe::PaymentMethod>
3255              
3256             $stripe->update_payment_method(
3257             payment_method_id => $payment_method_id,
3258             metadata => $metadata,
3259             );
3260              
3261             =head2 list_payment_methods
3262              
3263             Retrieve a list of PaymentMethods
3264              
3265             L<https://stripe.com/docs/api/payment_methods/list#list_payment_methods>
3266              
3267             =over
3268              
3269             =item * customer - StripeCustomerId - return only PaymentMethods for the specified Customer id - required
3270              
3271             =item * type - Str - filter by type - required
3272              
3273             =item * ending_before - Str - ending before condition
3274              
3275             =item * limit - Int - maximum number of objects to return
3276              
3277             =item * starting_after - Str - starting after condition
3278              
3279             =back
3280              
3281             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::PaymentMethod> objects
3282              
3283             $stripe->list_payment_methods(
3284             customer => $customer_id,
3285             type => 'card',
3286             limit => 10,
3287             );
3288              
3289             =head2 attach_payment_method
3290              
3291             Attach a PaymentMethod to a Customer
3292              
3293             L<https://stripe.com/docs/api/payment_methods/attach#customer_attach_payment_method>
3294              
3295             =over
3296              
3297             =item * payment_method_id - StripePaymentMethodId - id of PaymentMethod to attach - required
3298              
3299             =item * customer - StripeCustomerId - id of Customer to which to attach the PaymentMethod - required
3300              
3301             =back
3302              
3303             Returns a L<Net::Stripe::PaymentMethod>
3304              
3305             $stripe->attach_payment_method(
3306             payment_method_id => $payment_method_id,
3307             customer => $customer,
3308             );
3309              
3310             =head2 detach_payment_method
3311              
3312             Detach a PaymentMethod from a Customer
3313              
3314             L<https://stripe.com/docs/api/payment_methods/detach#customer_detach_payment_method>
3315              
3316             =over
3317              
3318             =item * payment_method_id - StripePaymentMethodId - id of PaymentMethod to detach - required
3319              
3320             =back
3321              
3322             Returns a L<Net::Stripe::PaymentMethod>.
3323              
3324             $stripe->detach_payment_method(
3325             payment_method_id => $payment_method_id,
3326             );
3327              
3328             =head1 Payment Intent Methods
3329              
3330             =head2 create_payment_intent
3331              
3332             Create a PaymentIntent object
3333              
3334             L<https://stripe.com/docs/api/payment_intents/create#create_payment_intent>
3335              
3336             =over
3337              
3338             =item * amount - Int - amount intended to be collected by this PaymentIntent - required
3339              
3340             =item * currency - Str - currency - required
3341              
3342             =item * application_fee_amount - Int - the amount of the application fee
3343              
3344             =item * capture_method - StripeCaptureMethod - capture method
3345              
3346             =item * confirm - Bool - attempt to confirm this PaymentIntent immediately
3347              
3348             =item * confirmation_method - StripeConfirmationMethod - confirmation method
3349              
3350             =item * customer - StripeCustomerId - id of Customer this PaymentIntent belongs to
3351              
3352             =item * description - Str - description
3353              
3354             =item * error_on_requires_action - Bool - fail the payment attempt if the PaymentIntent transitions into `requires_action`
3355              
3356             =item * mandate - Str - id of the mandate to be used for this payment
3357              
3358             =item * mandate_data - HashRef - details about the Mandate to create
3359              
3360             =item * metadata - HashRef[Str] - metadata
3361              
3362             =item * off_session - Bool - indicate that the customer is not in your checkout flow
3363              
3364             =item * on_behalf_of - Str - Stripe account ID for which these funds are intended
3365              
3366             =item * payment_method - StripePaymentMethodId - id of PaymentMethod to attach to this PaymentIntent
3367              
3368             =item * payment_method_options - HashRef - PaymentMethod-specific configuration for this PaymentIntent
3369              
3370             =item * payment_method_types - ArrayRef[StripePaymentMethodType] - list of PaymentMethod types that this PaymentIntent is allowed to use
3371              
3372             =item * receipt_email - Str - email address to send the receipt to
3373              
3374             =item * return_url - Str - URL to redirect your customer back to
3375              
3376             =item * save_payment_method - Bool - save the payment method to the customer
3377              
3378             =item * setup_future_usage - Str - allow future payments with this PaymentIntent's PaymentMethod
3379              
3380             =item * shipping - HashRef - shipping information for this PaymentIntent
3381              
3382             =item * statement_descriptor - Str - descriptor for statement
3383              
3384             =item * statement_descriptor_suffix - Str - suffix to be concatenated with the statement descriptor
3385              
3386             =item * transfer_data - HashRef - parameters used to automatically create a Transfer when the payment succeeds
3387              
3388             =item * transfer_group - Str - identifies the resulting payment as part of a group
3389              
3390             =item * use_stripe_sdk - Bool - use manual confirmation and the iOS or Android SDKs to handle additional authentication steps
3391              
3392             =back
3393              
3394             Returns a L<Net::Stripe::PaymentIntent>
3395              
3396             $stripe->create_payment_intent(
3397             amount => 3300,
3398             currency => 'usd',
3399             );
3400              
3401             =head2 get_payment_intent
3402              
3403             Retrieve an existing PaymentIntent
3404              
3405             L<https://stripe.com/docs/api/payment_intents/retrieve#retrieve_payment_intent>
3406              
3407             =over
3408              
3409             =item * payment_intent_id - StripePaymentIntentId - id of PaymentIntent to retrieve - required
3410              
3411             =item * client_secret - Str - client secret of the PaymentIntent to retrieve
3412              
3413             =back
3414              
3415             Returns a L<Net::Stripe::PaymentIntent>
3416              
3417             $stripe->get_payment_intent(
3418             payment_intent_id => $payment_intent_id,
3419             );
3420              
3421             =head2 update_payment_intent
3422              
3423             Update an existing PaymentIntent
3424              
3425             L<https://stripe.com/docs/api/payment_intents/update#update_payment_intent>
3426              
3427             =over
3428              
3429             =item * payment_intent_id - StripePaymentIntentId - id of PaymentIntent to update - required
3430              
3431             =item * amount - Int - amount intended to be collected by this PaymentIntent - required
3432              
3433             =item * application_fee_amount - Int - the amount of the application fee
3434              
3435             =item * currency - Str - currency - required
3436              
3437             =item * customer - StripeCustomerId - id of Customer this PaymentIntent belongs to
3438              
3439             =item * description - Str - description
3440              
3441             =item * metadata - HashRef[Str] - metadata
3442              
3443             =item * payment_method - StripePaymentMethodId - id of PaymentMethod to attach to this PaymentIntent
3444              
3445             =item * payment_method_options - HashRef - PaymentMethod-specific configuration for this PaymentIntent
3446              
3447             =item * payment_method_types - ArrayRef[StripePaymentMethodType] - list of PaymentMethod types that this PaymentIntent is allowed to use
3448              
3449             =item * receipt_email - Str - email address to send the receipt to
3450              
3451             =item * save_payment_method - Bool - save the payment method to the customer
3452              
3453             =item * setup_future_usage - Str - allow future payments with this PaymentIntent's PaymentMethod
3454              
3455             =item * shipping - HashRef - shipping information for this PaymentIntent
3456              
3457             =item * statement_descriptor - Str - descriptor for statement
3458              
3459             =item * statement_descriptor_suffix - Str - suffix to be concatenated with the statement descriptor
3460              
3461             =item * transfer_data - HashRef - parameters used to automatically create a Transfer when the payment succeeds
3462              
3463             =item * transfer_group - Str - identifies the resulting payment as part of a group
3464              
3465             =back
3466              
3467             Returns a L<Net::Stripe::PaymentIntent>
3468              
3469             $stripe->update_payment_intent(
3470             payment_intent_id => $payment_intent_id,
3471             description => 'Updated Description',
3472             );
3473              
3474             =head2 confirm_payment_intent
3475              
3476             Confirm that customer intends to pay with provided PaymentMethod
3477              
3478             L<https://stripe.com/docs/api/payment_intents/confirm#confirm_payment_intent>
3479              
3480             =over
3481              
3482             =item * payment_intent_id - StripePaymentIntentId - id of PaymentIntent to confirm - required
3483              
3484             =item * client_secret - Str - client secret of the PaymentIntent
3485              
3486             =item * error_on_requires_action - Bool - fail the payment attempt if the PaymentIntent transitions into `requires_action`
3487              
3488             =item * mandate - Str - id of the mandate to be used for this payment
3489              
3490             =item * mandate_data - HashRef - details about the Mandate to create
3491              
3492             =item * off_session - Bool - indicate that the customer is not in your checkout flow
3493              
3494             =item * payment_method - StripePaymentMethodId - id of PaymentMethod to attach to this PaymentIntent
3495              
3496             =item * payment_method_options - HashRef - PaymentMethod-specific configuration for this PaymentIntent
3497              
3498             =item * payment_method_types - ArrayRef[StripePaymentMethodType] - list of PaymentMethod types that this PaymentIntent is allowed to use
3499              
3500             =item * receipt_email - Str - email address to send the receipt to
3501              
3502             =item * return_url - Str - URL to redirect your customer back to
3503              
3504             =item * save_payment_method - Bool - save the payment method to the customer
3505              
3506             =item * setup_future_usage - Str - allow future payments with this PaymentIntent's PaymentMethod
3507              
3508             =item * shipping - HashRef - shipping information for this PaymentIntent
3509              
3510             =item * use_stripe_sdk - Bool - use manual confirmation and the iOS or Android SDKs to handle additional authentication steps
3511              
3512             =back
3513              
3514             Returns a L<Net::Stripe::PaymentIntent>
3515              
3516             $stripe->confirm_payment_intent(
3517             payment_intent_id => $payment_intent_id,
3518             );
3519              
3520             =head2 capture_payment_intent
3521              
3522             Capture the funds for the PaymentIntent
3523              
3524             L<https://stripe.com/docs/api/payment_intents/capture#capture_payment_intent>
3525              
3526             =over
3527              
3528             =item * payment_intent_id - StripePaymentIntentId - id of PaymentIntent to capture - required
3529              
3530             =item * amount_to_capture - Int - amount to capture from the PaymentIntent
3531              
3532             =item * application_fee_amount - Int - application fee amount
3533              
3534             =item * statement_descriptor - Str - descriptor for statement
3535              
3536             =item * statement_descriptor_suffix - Str - suffix to be concatenated with the statement descriptor
3537              
3538             =item * transfer_data - HashRef - parameters used to automatically create a Transfer when the payment succeeds
3539              
3540             =back
3541              
3542             Returns a L<Net::Stripe::PaymentIntent>
3543              
3544             $stripe->capture_payment_intent(
3545             payment_intent_id => $payment_intent_id,
3546             );
3547              
3548             =head2 cancel_payment_intent
3549              
3550             Cancel the PaymentIntent
3551              
3552             L<https://stripe.com/docs/api/payment_intents/cancel#cancel_payment_intent>
3553              
3554             =over
3555              
3556             =item * payment_intent_id - StripePaymentIntentId - id of PaymentIntent to cancel - required
3557              
3558             =item * cancellation_reason - StripeCancellationReason - reason for cancellation
3559              
3560             =back
3561              
3562             Returns a L<Net::Stripe::PaymentIntent>
3563              
3564             $stripe->cancel_payment_intent(
3565             payment_intent_id => $payment_intent_id,
3566             cancellation_reason => 'requested_by_customer',
3567             );
3568              
3569             =head2 list_payment_intents
3570              
3571             Retrieve a list of PaymentIntents
3572              
3573             L<https://stripe.com/docs/api/payment_intents/list#list_payment_intents>
3574              
3575             =over
3576              
3577             =item * customer - StripeCustomerId - return only PaymentIntents for the specified Customer id
3578              
3579             =item * created - HashRef[Int] - created conditions to match
3580              
3581             =item * ending_before - Str - ending before condition
3582              
3583             =item * limit - Int - maximum number of objects to return
3584              
3585             =item * starting_after - Str - starting after condition
3586              
3587             =back
3588              
3589             Returns a L<Net::Stripe::List> object containing L<Net::Stripe::PaymentIntent> objects.
3590              
3591             $stripe->list_payment_intents(
3592             customer => $customer_id,
3593             type => 'card',
3594             limit => 10,
3595             );
3596              
3597             =head1 RELEASE NOTES
3598              
3599             =head2 Version 0.40
3600              
3601             =head3 BREAKING CHANGES
3602              
3603             =over
3604              
3605             =item deprecate direct handling of PANs
3606              
3607             Stripe strongly discourages direct handling of PANs (primary account numbers),
3608             even in test mode, and returns invalid_request_error when passing PANs to the
3609             API from accounts that were created after October 2017. In live mode, all
3610             tokenization should be performed via client-side libraries because direct
3611             handling of PANs violates PCI compliance. So we have removed the methods and
3612             parameter constraints that allow direct handling of PANs and updated the
3613             unit tests appropriately.
3614              
3615             =item updating customer card by passing Customer object to post_customer()
3616              
3617             If you have code that updates a customer card by updating the internal values
3618             for an existing customer object and then posting that object:
3619              
3620             my $customer_obj = $stripe->get_customer(
3621             customer_id => $customer_id,
3622             );
3623             $customer_obj->card( $new_card );
3624             $stripe->post_customer( customer => $customer_obj );
3625              
3626             you must unset the default_card attribute in the existing object before
3627             posting the customer object.
3628              
3629             $customer_obj->default_card( undef );
3630              
3631             Otherwise there is a conflict, since the old default_card attribute in the
3632             object is serialized in the POST stream, and it appears that you are requesting
3633             to set default_card to the id of a card that no longer exists, but rather
3634             is being replaced by the new value of the card attribute in the object.
3635              
3636             =item Plan objects now linked to Product objects
3637              
3638             For Stripe API versions after 2018-02-15 L<https://stripe.com/docs/upgrades#2018-02-05>
3639             each Plan object is linked to a Product object with type=service. The
3640             Plan object 'name' and 'statement_descriptor' attributes have been moved to
3641             Product objects.
3642              
3643             =back
3644              
3645             =head3 DEPRECATION WARNING
3646              
3647             =over
3648              
3649             =item update 'card' to 'source' for Charge and Customer
3650              
3651             While the API returns both card-related and source-related values for earlier
3652             versions, making the update mostly backwards-compatible, Stripe API versions
3653             after 2015-02-18 L<https://stripe.com/docs/upgrades#2015-02-18> will no longer
3654             return the card-related values, so you should update your code where necessary
3655             to use the 'source' argument and method for Charge objects, and the 'source',
3656             'sources' and 'default_source' arguments and methods for Customer, in
3657             preparation for the eventual deprecation of the card-related arguments.
3658              
3659             =item update 'account_balance' to 'balance' for Customer
3660              
3661             While the API returns both 'account_balance' and 'balance' for earlier
3662             versions, making the update backwards-compatible, Stripe API versions
3663             after 2019-10-17 L<https://stripe.com/docs/upgrades#2019-10-17> do not
3664             accept or return 'account_balance', so you should update your code where
3665             necessary to use the 'balance' argument and method for Customer objects in
3666             preparation for the eventual deprecation of the 'account_balance' argument.
3667              
3668             =item use 'cancel_at_period_end' instead of 'at_period_end' for canceling Subscriptions
3669              
3670             For Stripe API versions after 2018-08-23
3671             L<https://stripe.com/docs/upgrades#2018-08-23>, you can no longer use
3672             'at_period_end' in delete_subscription(). The delete_subscription() method
3673             is reserved for immediate canceling going forward. You should update your
3674             code to use 'cancel_at_period_end in update_subscription() instead.
3675              
3676             =item update 'date' to 'created' for Invoice
3677              
3678             While the API returns both 'date' and 'created' for earlier versions, making
3679             the update backwards-compatible, Stripe API versions after 2019-03-14
3680             L<https://stripe.com/docs/upgrades#2019-03-14> only return 'created', so you
3681             should update your code where necessary to use the 'created' method for
3682             Invoice objects in preparation for the eventual deprecation of the 'date'
3683             argument.
3684              
3685             =item use 'auto_advance' instead of 'closed' for Invoice
3686              
3687             The 'closed' attribute for the Invoice object controls automatic collection,
3688             and has been deprecated in favor of the more specific 'auto_advance' attribute.
3689             Where you might have set closed=true on Invoices in the past, set
3690             auto_advance=false. While the API returns both 'closed' and 'auto_advance'
3691             for earlier versions, making the update backwards-compatible, Stripe API
3692             versions after 2018-11-08 L<https://stripe.com/docs/upgrades#2018-11-08>
3693             only return 'auto_advance', so you should update your code where necessary to
3694             use the 'auto_advance' argument and method for Invoice objects in preparation
3695             for the eventual deprecation of the 'closed' argument.
3696              
3697             =back
3698              
3699             =head3 BUG FIXES
3700              
3701             =over
3702              
3703             =item fix post_charge() arguments
3704              
3705             Some argument types for `customer` and `card` were non-functional in the
3706             current code and have been removed from the Kavorka method signature. We
3707             removed `Net::Stripe::Customer` and `HashRef` for `customer` and we removed
3708             `Net::Stripe::Card` and `Net::Stripe::Token` for `card`, as none of these
3709             forms were being serialized correctly for passing to the API call. We must
3710             retain `Net::Stripe::Card` for the `card` attribute in `Net::Stripe::Charge`
3711             because the `card` value returned from the API call is objectified into
3712             a card object. We have also added TypeConstraints for the string arguments
3713             passed and added in-method validation to ensure that the passed argument
3714             values make sense in the context of one another.
3715              
3716             =item cleanup post_card()
3717              
3718             Some argument types for `card` are not legitimate, or are being deprecated
3719             and have been removed from the Kavorka method signature. We removed
3720             `Net::Stripe::Card` and updated the string validation to disallow card id
3721             for `card`, as neither of these are legitimate when creating or updating a
3722             card L<https://github.com/lukec/stripe-perl/issues/138>, and the code path
3723             that appeared to be handling `Net::Stripe::Card` was actually unreachable
3724             L<https://github.com/lukec/stripe-perl/issues/100>. We removed the dead code
3725             paths and made the conditional structure more explicit, per discussion in
3726             L<https://github.com/lukec/stripe-perl/pull/133>. We also added unit tests
3727             for all calling forms, per L<https://github.com/lukec/stripe-perl/issues/139>.
3728              
3729             =item fix post_customer() arguments
3730              
3731             Some argument types for `card` are not legitimate and have been removed from
3732             the Kavorka method signature. We removed `Net::Stripe::Card` and updated the
3733             string validation to disallow card id for `card`, as neither of these are
3734             legitimate when creating or updating a customer L<https://github.com/lukec/stripe-perl/issues/138>.
3735             We have also updated the structure of the method so that we always create a
3736             Net::Stripe::Customer object before posting L<https://github.com/lukec/stripe-perl/issues/148>
3737             and cleaned up and centralized Net::Stripe:Token coercion code.
3738              
3739             =item default_card not updating in post_customer()
3740              
3741             Prior to ff84dd7, we were passing %args directly to _post(), and therefore
3742             default_card would have been included in the POST stream. Now we are creating
3743             a L<Net::Stripe::Customer> object and posting it, so the posted parameters
3744             rely on the explicit list in $customer_obj->form_fields(), which was lacking
3745             default_card. See also BREAKING CHANGES.
3746              
3747             =back
3748              
3749             =head3 ENHANCEMENTS
3750              
3751             =over
3752              
3753             =item coerce old lists
3754              
3755             In older Stripe API versions, some list-type data structures were returned
3756             as arrayrefs. We now coerce those old-style lists and collections into the
3757             hashref format that newer versions of the API return, with metadata stored
3758             top-level keys and the list elements in an arrayref with the key 'data',
3759             which is the format that C<Net::Stripe::List> expects. This makes the SDK
3760             compatible with the Stripe API back to the earliest documented API version
3761             L<https://stripe.com/docs/upgrades#2011-06-21>.
3762              
3763             =item encode card metdata in convert_to_form_fields()
3764              
3765             When passing a hashref with a nested metadata hashref to _post(), that
3766             metadata must be encoded properly before being passed to the Stripe API.
3767             There is now a dedicated block in convert_to_form_fields for this operation.
3768             This update was necessary because of the addition of update_card(), which
3769             accepts a card hashref, which may include metadata.
3770              
3771             =item encode objects in convert_to_form_fields()
3772              
3773             We removed the nested tertiary operator in _post() and updated
3774             convert_to_form_fields() so that it now handles encoding of objects, both
3775             top-level and nested. This streamlines the hashref vs object serailizing
3776             code, making it easy to adapt to other methods.
3777              
3778             =item remove manual serialization in _get_collections() and _get_with_args()
3779              
3780             We were using string contatenation to both serilize the individual query args,
3781             in _get_collections(), and to join the individual query args together, in
3782             _get_with_args(). This also involved some unnecessary duplication of the
3783             logic that convert_to_form_fields() was already capable of handling. We now
3784             use convert_to_form_fields() to process the passed data, and L<URI> to
3785             encode and serialize the query string. Along with other updates to
3786             convert_to_form_fields(), _get() can now easily handle the same calling
3787             form as _post(), eliminating the need for _get_collections() and
3788             _get_with_args(). We have also updated _delete() accordingly.
3789              
3790             =item add _get_all()
3791              
3792             Similar to methods provided by other SDKs, calls using this method will allow
3793             access to all records for a given object type without having to manually
3794             paginate through the results. It is not intended to be used directly, but
3795             will be accessed through new and existing list-retrieval methods. In order to
3796             maintain backwards-compatibility with existing list retrieval behavior, this
3797             method supports passing a value of 0 for 'limit' in order to retrieve all
3798             records. Any other positive integer value for 'limit' will attempt to retrieve
3799             that number of records up to the maximum available. As before, not passing a
3800             value for 'limit', or explicitly passing an undefined value, retrieves whatever
3801             number of records the API returns by default.
3802              
3803             =back
3804              
3805             =head3 UPDATES
3806              
3807             =over
3808              
3809             =item update statement_description to statement_descriptor
3810              
3811             The statement_description attribute is now statement_descriptor for
3812             L<Net::Stripe::Charge> and L<Net::Stripe::Plan>. The API docs
3813             L<https://stripe.com/docs/upgrades#2014-12-17> indicate that this change
3814             is backwards-compatible. You must update your code to reflect this change
3815             for parameters passed to these objects and methods called on these objects.
3816              
3817             =item update unit tests for Charge->status
3818              
3819             For Stripe API versions after 2015-02-18 L<https://stripe.com/docs/upgrades#2015-02-18>,
3820             the status property on the Charge object has a value of 'succeeded' for
3821             successful charges. Previously, the status property would be 'paid' for
3822             successful charges. This change does not affect the API calls themselves, but
3823             if your account is using Stripe API version 2015-02-18 or later, you should
3824             update any code that relies on strict checking of the return value of
3825             Charge->status.
3826              
3827             =item add update_card()
3828              
3829             This method allows updates to card address, expiration, metadata, etc for
3830             existing customer cards.
3831              
3832             =item update Token attributes
3833              
3834             Added type and client_ip attributes for L<Net::Stripe::Token>.
3835              
3836             =item allow capture of partial charge
3837              
3838             Passing 'amount' to capture_charge() allows capture of a partial charge.
3839             Per the API, any remaining amount is immediately refunded. The charge object
3840             now also has a 'refunds' attribute, representing a L<Net::Stripe::List>
3841             of L<Net::Stripe::Refund> objects for the charge.
3842              
3843             =item add Source
3844              
3845             Added a Source object. Also added 'source' attribute and argument for Charge
3846             objects and methods, and added 'source', 'sources' and 'default_source'
3847             attributes and arguments for Customer objects and methods.
3848              
3849             =item add balance for Customer
3850              
3851             Added 'balance' attribute and arguments for Customer objects and methods.
3852              
3853             =item add cancel_at_period_end for update_subscription()
3854              
3855             Added 'cancel_at_period_end' argument update_subscription() and added
3856             'cancel_at_period_end' to the POST stream for Subscription objects.
3857              
3858             =item update Invoice
3859              
3860             Added 'created' attribute for Invoice objects, and removed the required
3861             constraint for the deprecated 'date' attribute. Also added the 'auto_advance'
3862             attribute and removed the required constraint for the deprecated 'closed'
3863             attribute.
3864              
3865             =item add Product
3866              
3867             Added a Product object. Also added 'product' attribute and argument for Plan
3868             objects and methods.
3869              
3870             =item add PaymentMethod and PaymentIntent
3871              
3872             Added PaymentMethod and PaymentIntent objects and methods.
3873              
3874             =back
3875              
3876             =head1 SEE ALSO
3877              
3878             L<https://stripe.com>, L<https://stripe.com/docs/api>
3879              
3880             =encoding UTF-8
3881              
3882             =head1 AUTHORS
3883              
3884             =over 4
3885              
3886             =item *
3887              
3888             Luke Closs
3889              
3890             =item *
3891              
3892             Rusty Conover
3893              
3894             =back
3895              
3896             =head1 CONTRIBUTORS
3897              
3898             =for stopwords Andrew Solomon Brian Collins Devin M. Certas Dimitar Petrov Dylan Reinhold E. Choroba Florian Heyer Hermann Calabria Jonathan "Duke" Leto Luke Closs Mohammad S Anwar Olaf Alders Paul Cochrane Peter Scott Rusty Conover Sachin Sebastian sherrardb Sherrard Burton Slobodan Mišković Tom Eliaz
3899              
3900             =over 4
3901              
3902             =item *
3903              
3904             Andrew Solomon <andrew@geekuni.com>
3905              
3906             =item *
3907              
3908             Andrew Solomon <andrew@illywhacker.net>
3909              
3910             =item *
3911              
3912             Brian Collins <bricollins@gmail.com>
3913              
3914             =item *
3915              
3916             Devin M. Certas <devin@nacredata.com>
3917              
3918             =item *
3919              
3920             Dimitar Petrov <mitakaa@gmail.com>
3921              
3922             =item *
3923              
3924             Dylan Reinhold <dylan@gasdasoftware.com>
3925              
3926             =item *
3927              
3928             E. Choroba <choroba@matfyz.cz>
3929              
3930             =item *
3931              
3932             Florian Heyer <info@heyer-it.de>
3933              
3934             =item *
3935              
3936             Hermann Calabria <hermann@ivouch.com>
3937              
3938             =item *
3939              
3940             Jonathan "Duke" Leto <jonathan@leto.net>
3941              
3942             =item *
3943              
3944             Luke Closs <lukec@users.noreply.github.com>
3945              
3946             =item *
3947              
3948             Luke Closs <me@luk.ec>
3949              
3950             =item *
3951              
3952             Mohammad S Anwar <mohammad.anwar@yahoo.com>
3953              
3954             =item *
3955              
3956             Olaf Alders <olaf@wundersolutions.com>
3957              
3958             =item *
3959              
3960             Paul Cochrane <paul@liekut.de>
3961              
3962             =item *
3963              
3964             Peter Scott <peter@shotgundriver.com>
3965              
3966             =item *
3967              
3968             Rusty Conover <rusty@luckydinosaur.com>
3969              
3970             =item *
3971              
3972             Sachin Sebastian <sachinjsk@users.noreply.github.com>
3973              
3974             =item *
3975              
3976             sherrardb <32931314+sherrardb@users.noreply.github.com>
3977              
3978             =item *
3979              
3980             Sherrard Burton <sburton@allafrica.com>
3981              
3982             =item *
3983              
3984             Slobodan Mišković <slobodan@miskovic.ca>
3985              
3986             =item *
3987              
3988             Tom Eliaz <tom@tomeliaz.com>
3989              
3990             =back
3991              
3992             =head1 COPYRIGHT AND LICENSE
3993              
3994             This software is copyright (c) 2015 by Prime Radiant, Inc., (c) copyright 2014 Lucky Dinosaur LLC.
3995              
3996             This is free software; you can redistribute it and/or modify it under
3997             the same terms as the Perl 5 programming language system itself.
3998              
3999             =cut