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