lib/WebService/Braintree/_/CreditCard.pm

filter: Statementstmt 88.5% 54 / 61 Branchbran 50.0% 1 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 80.0% 8 / 10 Podpod 100% 3 / 3 totaltotal 83.5% 66 / 79 CC 3 SCAR 7.5
CC
3
Cov
85%
verification
6.0
__ANON__
2.3
expiration_date
2.0
CRAP 2.1
« lib/WebService/Braintree/ClientTokenGateway.pm ↑ Summary lib/WebService/Braintree/CreditCard.pm »
1 # vim: sw=4 ts=4 ft=perl
2  
3 package WebService::Braintree::_::CreditCard;
4 22 $WebService::Braintree::_::CreditCard::VERSION = '1.7';
5 22 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 WebService::Braintree::_::CreditCard
11  
12 =head1 PURPOSE
13  
14 This class represents a credit card.
15  
16 This class will only be created as part of a L<response|WebService::Braintree::Result> or L<error response|WebService::Braintree::ErrorResult>.
17  
18 =cut
19  
20 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 22 ▶use MooX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 22 extends 'WebService::Braintree::_';
24  
25 22 ▶use Types::Standard qw(ArrayRef Undef);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 22 ▶use WebService::Braintree::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 Address
28 CreditCardVerification
29 PaymentMethodNonce
30 Subscription
31 22 );
32  
33 =head1 ATTRIBUTES
34  
35 =cut
36  
37 =head2 billing_address()
38  
39 This returns the credit card's billing address (if it exists). This will be an
40 object of type L<WebService::Braintree::_::Address/>.
41  
42 =cut
43  
44 22 has billing_address => (
45 is => 'ro',
46 isa => Address,
47 coerce => 1,
48 );
49  
50 =head2 bin()
51  
52 This is the bin for this credit card.
53  
54 =cut
55  
56 22 has bin => (
57 is => 'ro',
58 );
59  
60 =head2 card_type()
61  
62 This is the card_type for this credit card.
63  
64 =cut
65  
66 22 has card_type => (
67 is => 'ro',
68 );
69  
70 =head2 cardholder_name()
71  
72 This is the cardholder name for this credit card.
73  
74 =cut
75  
76 22 has cardholder_name => (
77 is => 'ro',
78 );
79  
80 =head2 commercial()
81  
82 This is true if this credit card is commercial.
83  
84 =cut
85  
86 22 has commercial => (
87 is => 'ro',
88 );
89  
90 =head2 country_of_issuance()
91  
92 This is the country of issuance for this credit card.
93  
94 =cut
95  
96 22 has country_of_issuance => (
97 is => 'ro',
98 );
99  
100 =head2 created_at()
101  
102 This is when this credit card was created.
103  
104 =cut
105  
106 # Coerce this to Datetime
107 22 has created_at => (
108 is => 'ro',
109 );
110  
111 =head2 customer_id()
112  
113 This is the customer id for this credit card.
114  
115 =cut
116  
117 22 has customer_id => (
118 is => 'ro',
119 );
120  
121 =head2 customer_location()
122  
123 This is the customer location for this credit card.
124  
125 =cut
126  
127 22 has customer_location => (
128 is => 'ro',
129 );
130  
131 =head2 debit()
132  
133 This is true if this credit card is debit.
134  
135 =cut
136  
137 22 has debit => (
138 is => 'ro',
139 );
140  
141 =head2 default()
142  
143 This is true if this credit card is debit.
144  
145 C<< is_default() >> is an alias for this attribute.
146  
147 =cut
148  
149 22 has default => (
150 is => 'ro',
151 alias => 'is_default',
152 );
153  
154 =head2 durbin_regulated()
155  
156 This is true if this credit card is Durbin-regulated.
157  
158 =cut
159  
160 22 has durbin_regulated => (
161 is => 'ro',
162 );
163  
164 =head2 expiration_month()
165  
166 This is the expiration month for this credit card.
167  
168 =cut
169  
170 22 has expiration_month => (
171 is => 'ro',
172 );
173  
174 =head2 expiration_year()
175  
176 This is the expiration year for this credit card.
177  
178 =cut
179  
180 22 has expiration_year => (
181 is => 'ro',
182 );
183  
184 =head2 expired()
185  
186 This is true if this credit card is expired.
187  
188 C<< is_expired() >> is an alias for this attribute.
189  
190 =cut
191  
192 22 has expired => (
193 is => 'ro',
194 alias => 'is_expired',
195 );
196  
197 =head2 healthcare()
198  
199 This is true if this credit card is healthcare.
200  
201 =cut
202  
203 22 has healthcare => (
204 is => 'ro',
205 );
206  
207 =head2 image_url()
208  
209 This is the image url for this credit card.
210  
211 =cut
212  
213 # Coerce this to URI
214 22 has image_url => (
215 is => 'ro',
216 );
217  
218 =head2 issuing_bank()
219  
220 This is the issuing bank for this credit card.
221  
222 =cut
223  
224 22 has issuing_bank => (
225 is => 'ro',
226 );
227  
228 =head2 last_4()
229  
230 This is the last 4 digits for this credit card.
231  
232 =cut
233  
234 22 has last_4 => (
235 is => 'ro',
236 );
237  
238 =head2 payment_method_nonce()
239  
240 This is the payment method nonce for this credit card. If one is not returned,
241 then it will be created by default from the L</token>. If the token is undef,
242 then this will be undef as well.
243  
244 C<< nonce() >> is an alias for this attribute.
245  
246 =cut
247  
248 has payment_method_nonce => (
249 is => 'ro',
250 isa => PaymentMethodNonce | Undef,
251 coerce => 1,
252 3 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
253 3 my $self = shift;
254 3 ▶ return unless $self->token;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->token 3 0 3
255 0 return WebService::Braintree::PaymentMethodNonce->create($self->token);
256 },
257 22 alias => 'nonce',
258 );
259  
260 =head2 payroll()
261  
262 This is true if this credit card is payroll.
263  
264 =cut
265  
266 22 has payroll => (
267 is => 'ro',
268 );
269  
270 =head2 prepaid()
271  
272 This is true if this credit card is prepaid.
273  
274 =cut
275  
276 22 has prepaid => (
277 is => 'ro',
278 );
279  
280 =head2 product_id()
281  
282 This is the product id for this credit card.
283  
284 =cut
285  
286 22 has product_id => (
287 is => 'ro',
288 );
289  
290 =head2 subscriptions()
291  
292 This is an arrayref of L<subscriptions|WebService::Braintree::_::Susbcription>
293 associated with this credit card.
294  
295 =cut
296  
297 22 has subscriptions => (
298 is => 'ro',
299 isa => ArrayRef[Subscription],
300 coerce => 1,
301 );
302  
303 =head2 token()
304  
305 This is the token for this credit card.
306  
307 =cut
308  
309 22 has token => (
310 is => 'ro',
311 );
312  
313 =head2 unique_number_identifier()
314  
315 This is the unique number identifier for this credit card.
316  
317 =cut
318  
319 22 has unique_number_identifier => (
320 is => 'ro',
321 );
322  
323 =head2 updated_at()
324  
325 This is when this credit card was last updated. If it has never been updated,
326 then this should equal the L</created_at> date.
327  
328 =cut
329  
330 # Coerce this to Datetime
331 22 has updated_at => (
332 is => 'ro',
333 );
334  
335 =head2 venmo_sdk()
336  
337 This is true if this credit card is managed by the Venmo SDK.
338  
339 C<< is_venmo_sdk() >> is an alias for this attribute.
340  
341 =cut
342  
343 22 has venmo_sdk => (
344 is => 'ro',
345 alias => 'is_venmo_sdk',
346 );
347  
348 =head2 verifications()
349  
350 This is an arrayref of L<verifications|WebService::Braintree::_::CreditCardVerification>
351 associated with this credit card.
352  
353 =cut
354  
355 22 has verifications => (
356 is => 'ro',
357 isa => ArrayRef[CreditCardVerification],
358 coerce => 1,
359 );
360  
361 =head1 METHODS
362  
363 =head2 masked_number()
364  
365 This returns a masked credit card number suitable for display.
366  
367 =cut
368  
369 1 ▶sub masked_number {
Subroutine masked_number: called CC=1 SCAR=0.0
Pod documented
370 1 my $self = shift;
371 1 return $self->bin . "******" . $self->last_4;
372 }
373  
374 =head2 expiration_date()
375  
376 This returns the credit card's expiration in MM/YYYY format.
377  
378 =cut
379  
380 0 ▶sub expiration_date {
Subroutine expiration_date: not called CC=1 SCAR=6.9
Pod documented
381 0 my $self = shift;
382 0 return $self->expiration_month . "/" . $self->expiration_year;
383 }
384  
385 =head2 verification()
386  
387 This returns the most recent L<verification|WebService::Braintree::_::CreditCardVerification> (if any) associated with this credit card.
388  
389 =cut
390  
391 0 ▶sub verification {
Subroutine verification: not called CC=2 SCAR=17.9
Pod documented
392 0 my $self = shift;
393  
394 return (
395 sort {
396 0 $b->created_at cmp $a->created_at
397 0 ▶ } @{$self->verifications // []}
Condition0%0/2
$self->verifications // []
l!l
00
MC/DC0%0/1
$self->verifications // []
$self->verifications
Truth table0%0/2
A
A= $self->verifications
Aresult
11
00
398 )[0];
399 }
400  
401 22 __PACKAGE__->meta->make_immutable;
402  
403 22 1;
404 __END__
« lib/WebService/Braintree/ClientTokenGateway.pm ↑ Summary lib/WebService/Braintree/CreditCard.pm »