File Coverage

lib/Net/API/Stripe/Payment/Method.pm
Criterion Covered Total %
statement 19 35 54.2
branch n/a
condition n/a
subroutine 7 23 30.4
pod 16 16 100.0
total 42 74 56.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Method.pm
3             ## Version v0.3.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2022/10/29
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             ## https://stripe.com/docs/api/payment_methods
14             BEGIN
15             {
16             use strict;
17 2     2   24355800 use warnings;
  2         19  
  2         64  
18 2     2   11 # use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         65  
19             # use Net::API::Stripe::Payment::Method::Options qw( :all );
20             # We inherit rather than import so overriding does not trigger an error about subroutine being redefined
21             use parent qw( Net::API::Stripe::Payment::Method::Options );
22 2     2   12 use vars qw( $VERSION );
  2         4  
  2         11  
23 2     2   119 our( $VERSION ) = 'v0.3.0';
  2         5  
  2         100  
24 2     2   38 };
25              
26             use strict;
27 2     2   11 use warnings;
  2         4  
  2         39  
28 2     2   10  
  2         4  
  2         764  
29              
30 0     0 1    
31             # NOTE: alipay is inherited
32 0     0 1    
33             # NOTE: au_becs_debit is inherited
34              
35             # NOTE: bacs_debit is inherited
36              
37             # NOTE: bancontact is inherited
38              
39              
40             # NOTE: blik is inherited
41              
42 0     0 1   # NOTE: boleto is inherited
43              
44             # NOTE: card is inherited
45              
46             # NOTE: card_present is inherited
47              
48             { fingerprint => { type => "scalar" }, tax_id => { type => "scalar" } }, @_ ) ); }
49              
50              
51             # Expandable so either we get an id or we get the underlying object
52 0     0 1    
53              
54             # NOTE: eps is inherited
55 0     0 1    
56             # NOTE: fpx is inherited
57              
58             # NOTE: giropay is inherited
59 0     0 1    
60             # NOTE: grabpay is inherited
61              
62             # NOTE: ideal is inherited
63              
64             # NOTE: interac_present is inherited
65              
66             # NOTE: klarna is inherited
67              
68             # NOTE: konbini is inherited
69              
70              
71             {
72             email => { type => "scalar" },
73             persistent_token => { type => "scalar" },
74             }, @_ ) ); }
75              
76              
77 0     0 1    
78             # NOTE: multibanco is inherited
79 0     0 1    
80             # NOTE: oxxo is inherited
81              
82             # NOTE: p24 is inherited
83              
84             # NOTE: sepa_debit is inherited
85 0     0 1    
86             # NOTE: sofort is inherited
87 0     0 1    
88              
89              
90              
91              
92              
93              
94             1;
95             # NOTE: POD
96              
97             =encoding utf8
98              
99 0     0 1   =head1 NAME
100              
101 0     0 1   Net::API::Stripe::Payment::Method - A Stripe Payment Method Object
102              
103 0     0 1   =head1 SYNOPSIS
104              
105 0     0 1   my $pm = $stripe->payment_method({
106             billing_details => $billing_details_object,
107 0     0 1   card => $card_object,
108             metadata => { transaction_id => 123, customer_id => 456 },
109 0     0 1   type => 'card',
110             });
111              
112             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
113              
114             =head1 VERSION
115              
116             v0.3.0
117              
118             =head1 DESCRIPTION
119              
120             PaymentMethod objects represent your customer's payment instruments. They can be used with PaymentIntents (L<https://stripe.com/docs/payments/payment-intents>) to collect payments or saved to Customer objects to store instrument details for future payments.
121              
122             =head1 CONSTRUCTOR
123              
124             =head2 new( %ARG )
125              
126             Creates a new L<Net::API::Stripe::Payment::Method> object.
127             It may also take an hash like arguments, that also are method of the same name.
128              
129             =head1 METHODS
130              
131             =head2 id string
132              
133             Unique identifier for the object.
134              
135             =head2 object string, value is "payment_method"
136              
137             String representing the object’s type. Objects of the same type share the same value.
138              
139             =head2 alipay hash
140              
141             If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method.
142              
143             The Stripe API docs does not document any hash properties. There is some L<information about possible attributes here|https://stripe.com/docs/payments/alipay>
144              
145             =head2 au_becs_debit
146              
147             If this is an au_becs_debit PaymentMethod, this hash contains details about the bank account.
148              
149             =over 4
150              
151             =item I<bsb_number> string
152              
153             Six-digit number identifying bank and branch associated with this bank account.
154              
155             =item I<fingerprint> string
156              
157             Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
158              
159             =item I<last4> string
160              
161             Last four digits of the bank account number.
162              
163             =back
164              
165             =head2 bacs_debit hash
166              
167             If this is a `bacs_debit` PaymentMethod, this hash contains details about the Bacs Direct Debit bank account.
168              
169             It has the following properties:
170              
171             =over 4
172              
173             =item I<fingerprint> string
174              
175             Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
176              
177             =item I<last4> string
178              
179             Last four digits of the bank account number.
180              
181             =item I<network_status> string
182              
183             The status of the mandate on the Bacs network. Can be one of `pending`, `revoked`, `refused`, or `accepted`.
184              
185             =item I<reference> string
186              
187             The unique reference identifying the mandate on the Bacs network.
188              
189             =item I<sort_code> string
190              
191             Sort code of the bank account. (e.g., `10-20-30`)
192              
193             =item I<url> string
194              
195             The URL that will contain the mandate that the customer has signed.
196              
197             =back
198              
199             =head2 bancontact hash
200              
201             If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method.
202              
203             The Stripe API docs does not document any hash properties.
204              
205             =head2 billing_details hash
206              
207             Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
208              
209             This is a L<Net::API::Stripe::Billing::Details> object.
210              
211             =head2 boleto hash
212              
213             If this is a C<boleto> PaymentMethod, this hash contains details about the Boleto payment method.
214              
215             It has the following properties:
216              
217             =over 4
218              
219             =item C<fingerprint> string
220              
221             =item C<tax_id> string
222              
223             Uniquely identifies the customer tax id (CNPJ or CPF)
224              
225             =back
226              
227             =head2 card hash
228              
229             If this is a card PaymentMethod, this hash contains details about the card.
230              
231             This is a L<Net::API::Stripe::Connect::ExternalAccount::Card> object.
232              
233             =head2 card_present hash
234              
235             If this is an card_present PaymentMethod, this hash contains details about the Card Present payment method.
236              
237             =head2 created timestamp
238              
239             Time at which the object was created. Measured in seconds since the Unix epoch.
240              
241             =head2 customer string (expandable)
242              
243             The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer.
244              
245             =head2 eps hash
246              
247             If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method.
248              
249             The Stripe API docs does not document any hash properties.
250              
251             =head2 fpx hash
252              
253             If this is an fpx PaymentMethod, this hash contains details about the FPX payment method.
254              
255             =over 4
256              
257             =item I<bank> string
258              
259             The customer’s bank, if provided. Can be one of affin_bank, alliance_bank, ambank, bank_islam, bank_muamalat, bank_rakyat, bsn, cimb, hong_leong_bank, hsbc, kfh, maybank2u, ocbc, public_bank, rhb, standard_chartered, uob, deutsche_bank, maybank2e, or pb_enterprise.
260              
261             =back
262              
263             =head2 giropay hash
264              
265             If this is a C<giropay> PaymentMethod, this hash contains details about the Giropay payment method.
266              
267             The Stripe API docs does not document any hash properties.
268              
269             =head2 grabpay
270              
271             If this is a C<grabpay> PaymentMethod, this hash contains details about the GrabPay payment method.
272              
273             This is just a property with an empty hash. There are a few instances of this on Stripe api documentation.
274              
275             =head2 ideal hash
276              
277             If this is an ideal PaymentMethod, this hash contains details about the iDEAL payment method.
278              
279             =over 4
280              
281             =item I<bank> string
282              
283             The customer’s bank, if provided. Can be one of abn_amro, asn_bank, bunq, handelsbanken, ing, knab, moneyou, rabobank, regiobank, sns_bank, triodos_bank, or van_lanschot.
284              
285             =item I<bic> string
286              
287             The Bank Identifier Code of the customer’s bank, if the bank was provided.
288              
289             =back
290              
291             =head2 interac_present hash
292              
293             If this is an C<interac_present> PaymentMethod, this hash contains details about the Interac Present payment method.
294              
295             The Stripe API docs does not document any hash properties.
296              
297             =head2 klarna object
298              
299             If this is a C<klarna> PaymentMethod, this hash contains details about the Klarna payment method.
300              
301             This is a L<Net::API::Stripe::Connect::Person> object.
302              
303             =head2 link hash
304              
305             If this is an C<Link> PaymentMethod, this hash contains details about the Link payment method.
306              
307             It has the following properties:
308              
309             =over 4
310              
311             =item C<email> string
312              
313             Account owner's email address.
314              
315             =item C<persistent_token> string
316              
317             Token used for persistent Link logins.
318              
319             =back
320              
321             =head2 livemode boolean
322              
323             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
324              
325             =head2 metadata hash
326              
327             Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
328              
329             =head2 oxxo hash
330              
331             If this is an C<oxxo> PaymentMethod, this hash contains details about the OXXO payment method.
332              
333             The Stripe API docs now has the following properties:
334              
335             =over 4
336              
337             =item I<expires_after_days>
338              
339             he number of calendar days before an OXXO voucher expires. For example, if you create an OXXO voucher on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time.
340              
341             =back
342              
343             =head2 p24 hash
344              
345             If this is a C<p24> PaymentMethod, this hash contains details about the P24 payment method.
346              
347             It has the following properties:
348              
349             =over 4
350              
351             =item I<bank> string
352              
353             The customer's bank, if provided.
354              
355             =back
356              
357             =head2 paynow
358              
359             If this is a C<paynow> PaymentMethod, this hash contains details about the PayNow payment method.
360              
361             This is just a property with an empty hash. There are a few instances of this on Stripe api documentation.
362              
363             =head2 promptpay
364              
365             If this is a C<promptpay> PaymentMethod, this hash contains details about the PromptPay payment method.
366              
367             This is just a property with an empty hash. There are a few instances of this on Stripe api documentation.
368              
369             =head2 radar_options object
370              
371             Options to configure Radar. See L<Radar Session|https://stripe.com/docs/radar/radar-session> for more information.
372              
373             This is a L<Net::API::Stripe::Fraud::Review> object.
374              
375             =head2 sepa_debit hash
376              
377             If this is a sepa_debit PaymentMethod, this hash contains details about the SEPA debit bank account.
378              
379             This is a L<Net::API::Stripe::Connect::ExternalAccount::Card> object which uses the following properties:
380              
381             =over 4
382              
383             =item I<bank_code> string
384              
385             Bank code of bank associated with the bank account.
386              
387             =item I<branch_code> string
388              
389             Branch code of bank associated with the bank account.
390              
391             =item I<country> string
392              
393             Two-letter ISO code representing the country the bank account is located in.
394              
395             =item I<fingerprint> string
396              
397             Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
398              
399             =item I<generated_from>
400              
401             Information about the object that generated this PaymentMethod.
402              
403             =over 8
404              
405             =item I<charge>
406              
407             The ID of the Charge that generated this PaymentMethod, if any.
408              
409             =item I<setup_attempt>
410              
411             The ID of the SetupAttempt that generated this PaymentMethod, if any.
412              
413             =back
414              
415             =item I<last4> string
416              
417             Last four characters of the IBAN.
418              
419             =back
420              
421             =head2 sofort hash
422              
423             If this is a C<sofort> PaymentMethod, this hash contains details about the SOFORT payment method.
424              
425             It has the following properties:
426              
427             =over 4
428              
429             =item I<country> string
430              
431             Two-letter ISO code representing the country the bank account is located in.
432              
433             =item I<preferred_language>
434              
435             Preferred language of the Bancontact authorization page that the customer is redirected to.
436              
437             =back
438              
439             =head2 type string
440              
441             The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.
442              
443             Possible enum values: card, fpx, ideal, sepa_debit
444              
445             =head2 us_bank_account object
446              
447             If this is an C<us_bank_account> PaymentMethod, this hash contains details about the US bank account payment method.
448              
449             This is a L<Net::API::Stripe::Connect::ExternalAccount::Bank> object.
450              
451             =head2 wechat_pay
452              
453             If this is an C<wechat_pay> PaymentMethod, this hash contains details about the wechat_pay payment method.
454              
455             This is just a property with an empty hash. There are a few instances of this on Stripe api documentation.
456              
457             =head1 API SAMPLE
458              
459             {
460             "id": "pm_123456789",
461             "object": "payment_method",
462             "billing_details": {
463             "address": {
464             "city": "Anytown",
465             "country": "US",
466             "line1": "1234 Main street",
467             "line2": null,
468             "postal_code": "123456",
469             "state": null
470             },
471             "email": "jenny@example.com",
472             "name": null,
473             "phone": "+15555555555"
474             },
475             "card": {
476             "brand": "visa",
477             "checks": {
478             "address_line1_check": null,
479             "address_postal_code_check": null,
480             "cvc_check": null
481             },
482             "country": "US",
483             "exp_month": 8,
484             "exp_year": 2020,
485             "fingerprint": "kabvjbjcnbmbcmn",
486             "funding": "credit",
487             "generated_from": null,
488             "last4": "4242",
489             "three_d_secure_usage": {
490             "supported": true
491             },
492             "wallet": null
493             },
494             "created": 123456789,
495             "customer": null,
496             "livemode": false,
497             "metadata": {
498             "order_id": "123456789"
499             },
500             "type": "card"
501             }
502              
503             =head1 HISTORY
504              
505             =head2 v0.1
506              
507             Initial version
508              
509             =head1 STRIPE HISTORY
510              
511             =head2 2019-12-24
512              
513             Added properties B<ideal> and B<sepa_debit>
514              
515             =head1 AUTHOR
516              
517             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
518              
519             =head1 SEE ALSO
520              
521             Stripe API documentation:
522              
523             L<https://stripe.com/docs/api/payment_methods>, L<https://stripe.com/docs/payments/payment-methods>, L<https://stripe.com/docs/payments/cards/reusing-cards>
524              
525             =head1 COPYRIGHT & LICENSE
526              
527             Copyright (c) 2020-2020 DEGUEST Pte. Ltd.
528              
529             You can use, copy, modify and redistribute this package and associated
530             files under the same terms as Perl itself.
531              
532             =cut