File Coverage

blib/lib/Net/API/Stripe/Payment/Method.pm
Criterion Covered Total %
statement 7 21 33.3
branch n/a
condition n/a
subroutine 3 17 17.6
pod 14 14 100.0
total 24 52 46.1


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Method.pm
3             ## Version v0.1.1
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/payment_methods
11             package Net::API::Stripe::Payment::Method;
12             BEGIN
13             {
14 1     1   847 use strict;
  1         3  
  1         27  
15 1     1   5 use parent qw( Net::API::Stripe::Generic );
  1         1  
  1         4  
16 1     1   339 our( $VERSION ) = 'v0.1.1';
17             };
18              
19 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
20              
21 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
22              
23 0     0 1   sub au_becs_debit { return( shift->_set_get_hash( 'three_d_secure', @_ ) ); }
24              
25 0     0 1   sub billing_details { return( shift->_set_get_object( 'billing_details', 'Net::API::Stripe::Billing::Details', @_ ) ); }
26              
27 0     0 1   sub card { return( shift->_set_get_object( 'card', 'Net::API::Stripe::Connect::ExternalAccount::Card', @_ ) ); }
28              
29 0     0 1   sub card_present { return( shift->_set_get_hash( 'card_present', @_ ) ); }
30              
31 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
32              
33             ## Expandable so either we get an id or we get the underlying object
34 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
35              
36 0     0 1   sub fpx { return( shift->_set_get_hash( 'fpx', @_ ) ); }
37              
38 0     0 1   sub ideal { return( shift->_set_get_hash( 'ideal', @_ ) ); }
39              
40 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
41              
42 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
43              
44             # sub sepa_debit { return( shift->_set_get_hash( 'sepa_debit', @_ ) ); }
45             sub sepa_debit
46             {
47 0     0 1   return( shift->_set_get_class( 'sepa_debit',
48             {
49             bank_code => { type => 'scalar' },
50             branch_code => { type => 'scalar' },
51             country => { type => 'scalar' },
52             fingerprint => { type => 'scalar' },
53             last4 => { type => 'scalar' },
54             }, @_ ) );
55             }
56              
57 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
58              
59             1;
60              
61             __END__
62              
63             =encoding utf8
64              
65             =head1 NAME
66              
67             Net::API::Stripe::Payment::Method - A Stripe Payment Method Object
68              
69             =head1 SYNOPSIS
70              
71             my $pm = $stripe->payment_method({
72             billing_details => $billing_details_object,
73             card => $card_object,
74             metadata => { transaction_id => 123, customer_id => 456 },
75             type => 'card',
76             });
77              
78             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
79              
80             =head1 VERSION
81              
82             v0.1.1
83              
84             =head1 DESCRIPTION
85              
86             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.
87              
88             =head1 CONSTRUCTOR
89              
90             =over 4
91              
92             =item B<new>( %ARG )
93              
94             Creates a new L<Net::API::Stripe::Payment::Method> object.
95             It may also take an hash like arguments, that also are method of the same name.
96              
97             =back
98              
99             =head1 METHODS
100              
101             =over 4
102              
103             =item B<id> string
104              
105             Unique identifier for the object.
106              
107             =item B<object> string, value is "payment_method"
108              
109             String representing the object’s type. Objects of the same type share the same value.
110              
111             =item B<au_becs_debit>
112              
113             If this is an au_becs_debit PaymentMethod, this hash contains details about the bank account.
114              
115             =over 8
116              
117             =item I<bsb_number> string
118              
119             Six-digit number identifying bank and branch associated with this bank account.
120              
121             =item I<fingerprint> string
122              
123             Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
124              
125             =item I<last4> string
126              
127             Last four digits of the bank account number.
128              
129             =back
130              
131             =item B<billing_details> hash
132              
133             Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
134              
135             This is a L<Net::API::Stripe::Billing::Details> object.
136              
137             =item B<card> hash
138              
139             If this is a card PaymentMethod, this hash contains details about the card.
140              
141             This is a L<Net::API::Stripe::Connect::ExternalAccount::Card> object.
142              
143             =item B<card_present> hash
144              
145             If this is an card_present PaymentMethod, this hash contains details about the Card Present payment method.
146              
147             =item B<created> timestamp
148              
149             Time at which the object was created. Measured in seconds since the Unix epoch.
150              
151             =item B<customer> string (expandable)
152              
153             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.
154              
155             =item B<fpx> hash
156              
157             If this is an fpx PaymentMethod, this hash contains details about the FPX payment method.
158              
159             =over 8
160              
161             =item I<bank> string
162              
163             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.
164              
165             =back
166              
167             =item B<ideal> hash
168              
169             If this is an ideal PaymentMethod, this hash contains details about the iDEAL payment method.
170              
171             =over 8
172              
173             =item I<bank> string
174              
175             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.
176              
177             =item I<bic> string
178              
179             The Bank Identifier Code of the customer’s bank, if the bank was provided.
180              
181             =back
182              
183             =item B<livemode> boolean
184              
185             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
186              
187             =item B<metadata> hash
188              
189             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.
190              
191             =item B<sepa_debit> hash
192              
193             If this is a sepa_debit PaymentMethod, this hash contains details about the SEPA debit bank account.
194              
195             =over 8
196              
197             =item I<bank_code> string
198              
199             Bank code of bank associated with the bank account.
200              
201             =item I<branch_code> string
202              
203             Branch code of bank associated with the bank account.
204              
205             =item I<country> string
206              
207             Two-letter ISO code representing the country the bank account is located in.
208              
209             =item I<fingerprint> string
210              
211             Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
212              
213             =item I<last4> string
214              
215             Last four characters of the IBAN.
216              
217             =back
218              
219             =item B<type> string
220              
221             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.
222              
223             Possible enum values: card, fpx, ideal, sepa_debit
224              
225             =back
226              
227             =head1 API SAMPLE
228              
229             {
230             "id": "pm_123456789",
231             "object": "payment_method",
232             "billing_details": {
233             "address": {
234             "city": "Anytown",
235             "country": "US",
236             "line1": "1234 Main street",
237             "line2": null,
238             "postal_code": "123456",
239             "state": null
240             },
241             "email": "jenny@example.com",
242             "name": null,
243             "phone": "+15555555555"
244             },
245             "card": {
246             "brand": "visa",
247             "checks": {
248             "address_line1_check": null,
249             "address_postal_code_check": null,
250             "cvc_check": null
251             },
252             "country": "US",
253             "exp_month": 8,
254             "exp_year": 2020,
255             "fingerprint": "kabvjbjcnbmbcmn",
256             "funding": "credit",
257             "generated_from": null,
258             "last4": "4242",
259             "three_d_secure_usage": {
260             "supported": true
261             },
262             "wallet": null
263             },
264             "created": 123456789,
265             "customer": null,
266             "livemode": false,
267             "metadata": {
268             "order_id": "123456789"
269             },
270             "type": "card"
271             }
272              
273             =head1 HISTORY
274              
275             =head2 v0.1
276              
277             Initial version
278              
279             =head1 STRIPE HISTORY
280              
281             =head2 2019-12-24
282              
283             Added properties B<ideal> and B<sepa_debit>
284              
285             =head1 AUTHOR
286              
287             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
288              
289             =head1 SEE ALSO
290              
291             Stripe API documentation:
292              
293             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>
294              
295             =head1 COPYRIGHT & LICENSE
296              
297             Copyright (c) 2020-2020 DEGUEST Pte. Ltd.
298              
299             You can use, copy, modify and redistribute this package and associated
300             files under the same terms as Perl itself.
301              
302             =cut