File Coverage

lib/Net/API/Stripe/Token.pm
Criterion Covered Total %
statement 19 28 67.8
branch n/a
condition n/a
subroutine 7 16 43.7
pod 9 9 100.0
total 35 53 66.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Token.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/tokens/object
11             package Net::API::Stripe::Token;
12             BEGIN
13             {
14 2     2   21325012 use strict;
  2         16  
  2         66  
15 2     2   12 use warnings;
  2         5  
  2         68  
16 2     2   13 use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         18  
17 2     2   169 use vars qw( $VERSION );
  2         4  
  2         131  
18 2     2   42 our( $VERSION ) = 'v0.100.0';
19             };
20              
21 2     2   14 use strict;
  2         10  
  2         78  
22 2     2   13 use warnings;
  2         9  
  2         456  
23              
24 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
25              
26 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
27              
28 0     0 1   sub bank_account { return( shift->_set_get_object( 'bank_account', 'Net::API::Stripe::Payment::BankAccount', @_ ) ); }
29              
30 0     0 1   sub card { return( shift->_set_get_object( 'card', 'Net::API::Stripe::Payment::Card', @_ ) ); }
31              
32 0     0 1   sub client_ip { return( shift->_set_get_scalar( 'client_ip', @_ ) ); }
33              
34 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
35              
36 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
37              
38             ## account, bank_account, card, person, or pii
39 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
40              
41 0     0 1   sub used { return( shift->_set_get_boolean( 'used', @_ ) ); }
42              
43             1;
44             # NOTE: POD
45             __END__
46              
47             =encoding utf8
48              
49             =head1 NAME
50              
51             Net::API::Stripe::Token - A Stripe Token Object
52              
53             =head1 SYNOPSIS
54              
55             my $token = $stripe->token({
56             card => $card_object,
57             client_ip => '1.2.3.4',
58             livemode => $stripe->false,
59             type => 'card',
60             used => $stripe->false,
61             });
62              
63             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
64              
65             =head1 VERSION
66              
67             v0.100.0
68              
69             =head1 DESCRIPTION
70              
71             Tokenisation is the process Stripe uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. You should use Stripe's recommended payments integrations (L<https://stripe.com/docs/payments>) to perform this process client-side. This ensures that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.
72              
73             If you cannot use client-side tokenization, you can also create tokens using the API with either your publishable or secret API key. Keep in mind that if your integration uses this method, you are responsible for any PCI compliance that may be required, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer's information is not sent directly to Stripe, so Stripe cannot determine how it is handled or stored.
74              
75             Tokens cannot be stored or used more than once. To store card or bank account information for later use, you can create Customer objects (L<Net::API::Stripe::Customer> / L<https://stripe.com/docs/api#customers>) or Custom accounts (L<Net::API::Stripe::Connect::ExternalAccount::Bank> and L<Net::API::Stripe::Connect::ExternalAccount::Card> / L<https://stripe.com/docs/api#external_accounts>). Note that Radar (L<https://stripe.com/docs/radar>), Stripe's integrated solution for automatic fraud protection, supports only integrations that use client-side tokenization.
76              
77             =head1 CONSTRUCTOR
78              
79             =head2 new( %ARG )
80              
81             Creates a new L<Net::API::Stripe::Token> object.
82             It may also take an hash like arguments, that also are method of the same name.
83              
84             =head1 METHODS
85              
86             =head2 id string
87              
88             Unique identifier for the object.
89              
90             =head2 object string, value is "token"
91              
92             String representing the object’s type. Objects of the same type share the same value.
93              
94             =head2 bank_account hash
95              
96             Hash describing the bank account.
97              
98             This is a L<Net::API::Stripe::Payment::BankAccount> object.
99              
100             =head2 card hash
101              
102             Hash describing the card used to make the charge.
103              
104             This is a L<Net::API::Stripe::Payment::Card> object.
105              
106             =head2 client_ip string
107              
108             IP address of the client that generated the token.
109              
110             =head2 created timestamp
111              
112             Time at which the object was created. Measured in seconds since the Unix epoch.
113              
114             =head2 livemode boolean
115              
116             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
117              
118             =head2 type string
119              
120             Type of the token: account, bank_account, card, or pii.
121              
122             =head2 used boolean
123              
124             Whether this token has already been used (tokens can be used only once).
125              
126             =head1 API SAMPLE
127              
128             {
129             "id": "tok_fake123456789",
130             "object": "token",
131             "card": {
132             "id": "card_fake123456789",
133             "object": "card",
134             "address_city": null,
135             "address_country": null,
136             "address_line1": null,
137             "address_line1_check": null,
138             "address_line2": null,
139             "address_state": null,
140             "address_zip": null,
141             "address_zip_check": null,
142             "brand": "Visa",
143             "country": "US",
144             "cvc_check": null,
145             "dynamic_last4": null,
146             "exp_month": 8,
147             "exp_year": 2020,
148             "fingerprint": "x18XyLUPM6hub5xz",
149             "funding": "credit",
150             "last4": "4242",
151             "metadata": {},
152             "name": null,
153             "tokenization_method": null
154             },
155             "client_ip": null,
156             "created": 1571314413,
157             "livemode": false,
158             "type": "card",
159             "used": false
160             }
161              
162             =head1 HISTORY
163              
164             =head2 v0.1
165              
166             Initial version
167              
168             =head1 AUTHOR
169              
170             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
171              
172             =head1 SEE ALSO
173              
174             Stripe API documentation:
175              
176             L<https://stripe.com/docs/api/tokens>, L<https://stripe.com/docs/payments/cards/collecting/web#create-token>
177              
178             =head1 COPYRIGHT & LICENSE
179              
180             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
181              
182             You can use, copy, modify and redistribute this package and associated
183             files under the same terms as Perl itself.
184              
185             =cut