File Coverage

lib/Net/API/Stripe/Payment/Source.pm
Criterion Covered Total %
statement 19 99 19.1
branch n/a
condition n/a
subroutine 7 87 8.0
pod 80 80 100.0
total 106 266 39.8


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Source.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/sources/object
11             BEGIN
12             {
13             use strict;
14 2     2   23950099 use warnings;
  2         15  
  2         61  
15 2     2   10 use parent qw( Net::API::Stripe::Generic );
  2         6  
  2         60  
16 2     2   10 use vars qw( $VERSION );
  2         4  
  2         12  
17 2     2   155 our( $VERSION ) = 'v0.100.0';
  2         5  
  2         123  
18 2     2   40 };
19              
20             use strict;
21 2     2   23 use warnings;
  2         5  
  2         50  
22 2     2   9  
  2         4  
  2         3544  
23              
24 0     0 1    
25              
26 0     0 1    
27              
28 0     0 1    
29              
30 0     0 1    
31              
32 0     0 1    
33              
34 0     0 1    
35              
36 0     0 1    
37              
38 0     0 1    
39              
40 0     0 1    
41              
42 0     0 1    
43              
44 0     0 1    
45              
46 0     0 1    
47              
48 0     0 1    
49              
50 0     0 1   ## If type is set to "card"
51              
52 0     0 1    
53              
54 0     0 1    
55              
56 0     0 1    
57              
58 0     0 1    
59              
60 0     0 1    
61              
62 0     0 1    
63              
64 0     0 1    
65              
66 0     0 1    
67              
68 0     0 1    
69              
70 0     0 1    
71              
72 0     0 1    
73              
74 0     0 1    
75              
76 0     0 1    
77              
78              
79 0     0 1    
80              
81 0     0 1    
82              
83 0     0 1    
84             ## "Information related to the receiver flow. Present if the source is a receiver (flow is receiver)."
85 0     0 1    
86              
87 0     0 1    
88              
89 0     0 1    
90              
91 0     0 1    
92              
93 0     0 1    
94              
95 0     0 1    
96              
97 0     0 1    
98              
99 0     0 1    
100              
101 0     0 1    
102              
103 0     0 1    
104              
105 0     0 1   1;
106              
107 0     0 1    
108             =encoding utf8
109 0     0 1    
110             =head1 NAME
111 0     0 1    
112             Net::API::Stripe::Payment::Source - A Stripe Payment Source Object
113 0     0 1    
114             =head1 SYNOPSIS
115 0     0 1    
116             my $source = $stripe->source({
117 0     0 1   account => $account_object,
118             account_holder_name => 'John Doe',
119 0     0 1   account_holder_type => 'individual',
120             active => $stripe->true,
121 0     0 1   # Or maybe more simply you pass a Net::API::Stripe::Address object
122             # address => $address_object
123 0     0 1   address_line1 => '1-2-3 Kudan-Minami, Chiyoda-ku',
124             address_line2 => 'Big Bldg 12F',
125 0     0 1   address_city => 'Tokyo',
126             address_state => undef,
127 0     0 1   address_zip => '123-4567',
128             address_country => 'jp',
129 0     0 1   amount => 2000,
130             brand => 'Visa',
131 0     0 1   card => $card_object,
132             country => 'jp',
133 0     0 1   currency => 'jpy',
134             description => 'Primary source for customer',
135 0     0 1   email => 'john.doe@example.com',
136             exp_month => 4,
137 0     0 1   exp_year => 2030,
138             funding => 'debit',
139 0     0 1   metadata => { transaction_id => 123, customer_id => 456 },
140             name => 'John Doe',
141 0     0 1   statement_descriptor => 'Big Corp Services',
142             type => 'card',
143 0     0 1   });
144              
145             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
146 0     0 1    
147             =head1 VERSION
148 0     0 1    
149             v0.100.0
150 0     0 1    
151             =head1 DESCRIPTION
152 0     0 1    
153             Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Stripe API just like a Card object: once chargeable, they can be charged, or can be attached to customers.
154 0     0 1    
155             Stripe states this approach for card is deprecated in favour or PaymentIntent: L<https://stripe.com/docs/sources/cards>
156 0     0 1    
157             =head1 CONSTRUCTOR
158 0     0 1    
159             =head2 new( %ARG )
160 0     0 1    
161             Creates a new L<Net::API::Stripe::Payment::Source> object.
162 0     0 1    
163             =head1 METHODS
164 0     0 1    
165             =head2 id string
166 0     0 1    
167             Unique identifier for the object.
168 0     0 1    
169             =head2 object string, value is "source"
170 0     0 1    
171             String representing the object’s type. Objects of the same type share the same value.
172 0     0 1    
173             =head2 account custom only string (expandable)
174 0     0 1    
175             The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead.
176 0     0 1    
177             When expanded, this is a L<Net::API::Stripe::Connect::Account>
178 0     0 1    
179             =head2 account_holder_name string
180 0     0 1    
181             The name of the person or business that owns the bank account.
182 0     0 1    
183             =head2 account_holder_type string
184 0     0 1    
185             The type of entity that holds the account. This can be either individual or company.
186              
187             =head2 ach_credit_transfer
188              
189             If B<type> is set to C<ach_credit_transfer>, this is a L<Net::API::Stripe::Payment::Source::ACHCreditTransfer> object.
190              
191             It is not very clear in the Stripe API, but in the B<type> property, they mention "An additional hash is included on the source with a name matching this value. It contains additional information specific to the payment method (L<https://stripe.com/docs/sources>) used." :/
192              
193             =head2 ach_debit
194              
195             If B<type> is set to C<ach_debit>, this is a L<Net::API::Stripe::Payment::Source::ACHDebit> object.
196              
197             It is not very clear in the Stripe API, but in the B<type> property, they mention "An additional hash is included on the source with a name matching this value. It contains additional information specific to the payment method (L<https://stripe.com/docs/sources>) used." :/
198              
199             =head2 active boolean
200              
201             True when this bitcoin receiver has received a non-zero amount of bitcoin.
202              
203             =head2 address L<Net::API::Stripe::Address> object or hash
204              
205             This is a helper method. Provided with either a L<Net::API::Stripe::Address> object or a hash with same properties, this will assign all the address_* properties by calling its method.
206              
207             =head2 address L<Net::API::Stripe::Address> object or hash
208              
209             This is a helper method. Provided with either a L<Net::API::Stripe::Address> object or a hash with same properties, this will assign all the address_* properties by calling its method.
210              
211             =head2 address_city string
212              
213             City/District/Suburb/Town/Village.
214              
215             =head2 address_country string
216              
217             Billing address country, if provided when creating card.
218              
219             =head2 address_line1 string
220              
221             Address line 1 (Street address/PO Box/Company name).
222              
223             =head2 address_line1_check string
224              
225             If address_line1 was provided, results of the check: pass, fail, unavailable, or unchecked.
226              
227             =head2 address_line2 string
228              
229             Address line 2 (Apartment/Suite/Unit/Building).
230              
231             =head2 address_state string
232              
233             State/County/Province/Region.
234              
235             =head2 address_zip string
236              
237             ZIP or postal code.
238              
239             =head2 address_zip_check string
240              
241             If address_zip was provided, results of the check: pass, fail, unavailable, or unchecked.
242              
243             =head2 alipay
244              
245             If B<type> is set to C<alipay>, this is a L<Net::API::Stripe::Payment::Method::Details::Alipay> object.
246              
247             =head2 amount integer
248              
249             A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources.
250              
251             =head2 amount_received positive integer or zero
252              
253             The amount of currency to which bitcoin_amount_received has been converted.
254              
255             =head2 available_payout_methods array
256              
257             A set of available payout methods for this card. Will be either ["standard"] or ["standard", "instant"]. Only values from this set should be passed as the method when creating a transfer.
258              
259             =head2 bancontact
260              
261             If B<type> is set to C<bancontact>, this is a L<Net::API::Stripe::Payment::Method::Details::BanContact> object.
262              
263             =head2 bank_name string
264              
265             Name of the bank associated with the routing number (e.g., WELLS FARGO).
266              
267             =head2 bitcoin_amount positive integer
268              
269             The amount of bitcoin that the customer should send to fill the receiver. The bitcoin_amount is denominated in Satoshi: there are 10^8 Satoshi in one bitcoin.
270              
271             =head2 bitcoin_amount_received positive integer or zero
272              
273             The amount of bitcoin that has been sent by the customer to this receiver.
274              
275             =head2 bitcoin_uri string
276              
277             This URI can be displayed to the customer as a clickable link (to activate their bitcoin client) or as a QR code (for mobile wallets).
278              
279             =head2 brand string
280              
281             Card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
282              
283             =head2 card object
284              
285             If B<type> is set to C<card>, this is a L<Net::API::Stripe::Payment::Card> object. See also L<https://stripe.com/docs/sources/cards>.
286              
287             =head2 card_present
288              
289             If B<type> is set to C<card_present>, this is a L<Net::API::Stripe::Payment::Method::Details::CardPresent> object.
290              
291             =head2 client_secret string
292              
293             The client secret of the source. Used for client-side retrieval using a publishable key.
294              
295             =head2 code_verification hash
296              
297             Information related to the code verification flow. Present if the source is authenticated by a verification code (flow is code_verification).
298              
299             This is a L<Net::API::Stripe::Payment::Source::CodeVerification> object.
300              
301             =head2 country string
302              
303             Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you’ve collected.
304              
305             =head2 created timestamp
306              
307             Time at which the object was created. Measured in seconds since the Unix epoch.
308              
309             =head2 currency currency
310              
311             Three-letter ISO code for the currency associated with the source. This is the currency for which the source will be chargeable once ready. Required for single_use sources.
312              
313             =head2 customer string
314              
315             The ID of the customer to which this source is attached. This will not be present when the source has not been attached to a customer. If it is expanded, this would be a L<Net::API::Stripe::Customer> object.
316              
317             =head2 cvc_check string
318              
319             If a CVC was provided, results of the check: pass, fail, unavailable, or unchecked.
320              
321             =head2 description string
322              
323             An arbitrary string attached to the object. Often useful for displaying to users.
324              
325             =head2 dynamic_last4 string
326              
327             (For tokenized numbers only.) The last four digits of the device account number.
328              
329             =head2 email string
330              
331             The customer’s email address, set by the API call that creates the receiver.
332              
333             =head2 eps
334              
335             If B<type> is set to C<eps>, this is a L<Net::API::Stripe::Payment::Method::Details::EPS> object.
336              
337             =head2 exp_month integer
338              
339             Two-digit number representing the card’s expiration month.
340              
341             =head2 exp_year integer
342              
343             Four-digit number representing the card’s expiration year.
344              
345             =head2 filled boolean
346              
347             This flag is initially false and updates to true when the customer sends the bitcoin_amount to this receiver.
348              
349             =head2 fingerprint string
350              
351             Uniquely identifies this particular card number. You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
352              
353             =head2 flow string
354              
355             The authentication flow of the source. flow is one of redirect, receiver, code_verification, none.
356              
357             =head2 livemode boolean
358              
359             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
360              
361             =head2 funding string
362              
363             Card funding type. Can be credit, debit, prepaid, or unknown.
364              
365             =head2 giropay
366              
367             If B<type> is set to C<giropay>, this is a L<Net::API::Stripe::Payment::Method::Details::Giropay> object.
368              
369             =head2 ideal
370              
371             If B<type> is set to C<ideal>, this is a L<Net::API::Stripe::Payment::Method::Details::Ideal> object.
372              
373             =head2 inbound_address string
374              
375             A bitcoin address that is specific to this receiver. The customer can send bitcoin to this address to fill the receiver.
376              
377             =head2 klarna
378              
379             If B<type> is set to C<klarna>, this is a L<Net::API::Stripe::Payment::Method::Details::Klarna> object.
380              
381             =head2 last4 string
382              
383             The last four digits of the card.
384              
385             =head2 livemode boolean
386              
387             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
388              
389             =head2 metadata hash
390              
391             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.
392              
393             =head2 multibanco
394              
395             If B<type> is set to C<multibanco>, this is a L<Net::API::Stripe::Payment::Method::Details::MultiBanco> object.
396              
397             =head2 name string
398              
399             Cardholder name.
400              
401             =head2 p24
402              
403             If B<type> is set to C<p24>, this is a L<Net::API::Stripe::Payment::Method::Details::P24> object.
404              
405             =head2 payment string
406              
407             The ID of the payment created from the receiver, if any. Hidden when viewing the receiver with a publishable key.
408              
409             =head2 owner hash
410              
411             Information about the owner of the payment instrument that may be used or required by particular source types.
412              
413             This is a L<Net::API::Stripe::Payment::Source::Owner> object.
414              
415             =head2 payment_amount positive integer
416              
417             If the Alipay account object is not reusable, the exact amount that you can create a charge for.
418              
419             =head2 payment_currency currency
420              
421             If the Alipay account object is not reusable, the exact currency that you can create a charge for.
422              
423             =head2 receiver hash
424              
425             Information related to the receiver flow. Present if the source is a receiver (flow is receiver).
426              
427             This is a L<Net::API::Stripe::Payment::Source::Receiver> object.
428              
429             =head2 recipient string (expandable)
430              
431             The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead.
432              
433             When expanded, this is a L<Net::API::Stripe::Customer>.
434              
435             =head2 redirect hash
436              
437             Information related to the redirect flow. Present if the source is authenticated by a redirect (flow is redirect).
438              
439             This is a L<Net::API::Stripe::Payment::Source::Redirect> object.
440              
441             =head2 reusable boolean
442              
443             True if you can create multiple payments using this account. If the account is reusable, then you can freely choose the amount of each payment.
444              
445             =head2 refund_address string
446              
447             The refund address of this bitcoin receiver.
448              
449             =head2 routing_number string
450              
451             The routing transit number for the bank account.
452              
453             =head2 sofort hash
454              
455             If B<type> is set to C<sofort>, this is a L<Net::API::Stripe::Payment::Details::Sofort> virtual object, ie it is created dynamically by L<Nodule::Generic/"set_get_hash_as_object">
456              
457             =head2 source_order hash
458              
459             Information about the items and shipping associated with the source. Required for transactional credit (for example Klarna) sources before you can charge it. This is a L<Net::API::Stripe::Order> object.
460              
461             =over 4
462              
463             =item I<amount> integer
464              
465             A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order.
466              
467             =item I<currency> currency
468              
469             Three-letter ISO currency code, in lowercase. Must be a supported currency.
470              
471             =item I<email> string
472              
473             The email address of the customer placing the order.
474              
475             =item I<items> array of hashes
476              
477             List of items constituting the order. This is an array of L<Net::API::Stripe::Order::Item> objects.
478              
479             =item I<shipping> hash
480              
481             The shipping address for the order. Present if the order is for goods to be shipped. This is a L<Net::API::Stripe::Shipping> object
482              
483             =back
484              
485             =head2 statement_descriptor string
486              
487             Extra information about a source. This will appear on your customer’s statement every time you charge the source.
488              
489             =head2 status string
490              
491             The status of the source, one of canceled, chargeable, consumed, failed, or pending. Only chargeable sources can be used to create a charge.
492              
493             =head2 stripe_account
494              
495             If B<type> is set to C<stripe_account>, this is a L<Net::API::Stripe::Payment::Method::Details::StripeAccount> object.
496              
497             =head2 tokenization_method string
498              
499             If the card number is tokenized, this is the method that was used. Can be apple_pay or google_pay.
500              
501             =head2 transactions
502              
503             A list (L<Net::API::Stripe::List>) of L<Net::API::Stripe::Bitcoin::Transaction> object
504              
505             =head2 type string
506              
507             The type of the source. The type is a payment method, one of ach_credit_transfer, ach_debit, alipay, bancontact, card, card_present, eps, giropay, ideal, multibanco, klarna, p24, sepa_debit, sofort, three_d_secure, or wechat. An additional hash is included on the source with a name matching this value. It contains additional information specific to the payment method (L<https://stripe.com/docs/sources>) used.
508              
509             =head2 uncaptured_funds boolean
510              
511             This receiver contains uncaptured funds that can be used for a payment or refunded.
512              
513             =head2 usage string
514              
515             Either reusable or single_use. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned.
516              
517             =head2 used boolean
518              
519             Whether this Alipay account object has ever been used for a payment.
520              
521             =head2 used_for_payment boolean
522              
523             Indicate if this source is used for payment.
524              
525             =head2 username string
526              
527             The username for the Alipay account.
528              
529             =head2 wechat
530              
531             If L</type> is set to C<wechat>, this is a L<Net::API::Stripe::Payment::Method::Details::WeChat> object.
532              
533             =head1 API SAMPLE
534              
535             {
536             "id": "src_fake123456789",
537             "object": "source",
538             "ach_credit_transfer": {
539             "account_number": "test_52796e3294dc",
540             "routing_number": "110000000",
541             "fingerprint": "anvbmbvmnbvmab",
542             "bank_name": "TEST BANK",
543             "swift_code": "TSTEZ122"
544             },
545             "amount": null,
546             "client_secret": "src_client_secret_fake123456789",
547             "created": 1571314413,
548             "currency": "jpy",
549             "flow": "receiver",
550             "livemode": false,
551             "metadata": {},
552             "owner": {
553             "address": null,
554             "email": "jenny.rosen@example.com",
555             "name": null,
556             "phone": null,
557             "verified_address": null,
558             "verified_email": null,
559             "verified_name": null,
560             "verified_phone": null
561             },
562             "receiver": {
563             "address": "121042882-38381234567890123",
564             "amount_charged": 0,
565             "amount_received": 0,
566             "amount_returned": 0,
567             "refund_attributes_method": "email",
568             "refund_attributes_status": "missing"
569             },
570             "statement_descriptor": null,
571             "status": "pending",
572             "type": "ach_credit_transfer",
573             "usage": "reusable"
574             }
575              
576             =head1 HISTORY
577              
578             =head2 v0.1
579              
580             Initial version
581              
582             =head1 STRIPE HISTORY
583              
584             =head2 2018-01-23
585              
586             When being viewed by a platform, cards and bank accounts created on behalf of connected accounts will have a fingerprint that is universal across all connected accounts. For accounts that are not connect platforms, there will be no change.
587              
588             =head1 AUTHOR
589              
590             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
591              
592             =head1 SEE ALSO
593              
594             Stripe API documentation:
595              
596             L<https://stripe.com/docs/api/sources>, L<https://stripe.com/docs/sources>, L<https://stripe.com/docs/sources/customers>
597              
598             =head1 COPYRIGHT & LICENSE
599              
600             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
601              
602             You can use, copy, modify and redistribute this package and associated
603             files under the same terms as Perl itself.
604              
605             =cut
606