| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Braintree::CreditCard; |
|
2
|
|
|
|
|
|
|
$WebService::Braintree::CreditCard::VERSION = '0.94'; |
|
3
|
20
|
|
|
20
|
|
372
|
use 5.010_001; |
|
|
20
|
|
|
|
|
61
|
|
|
4
|
20
|
|
|
20
|
|
103
|
use strictures 1; |
|
|
20
|
|
|
|
|
123
|
|
|
|
20
|
|
|
|
|
712
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
6381
|
use WebService::Braintree::CreditCard::CardType; |
|
|
20
|
|
|
|
|
44
|
|
|
|
20
|
|
|
|
|
475
|
|
|
7
|
20
|
|
|
20
|
|
4452
|
use WebService::Braintree::CreditCard::Location; |
|
|
20
|
|
|
|
|
38
|
|
|
|
20
|
|
|
|
|
448
|
|
|
8
|
20
|
|
|
20
|
|
4168
|
use WebService::Braintree::CreditCard::Prepaid; |
|
|
20
|
|
|
|
|
39
|
|
|
|
20
|
|
|
|
|
440
|
|
|
9
|
20
|
|
|
20
|
|
4189
|
use WebService::Braintree::CreditCard::Debit; |
|
|
20
|
|
|
|
|
37
|
|
|
|
20
|
|
|
|
|
479
|
|
|
10
|
20
|
|
|
20
|
|
5221
|
use WebService::Braintree::CreditCard::Payroll; |
|
|
20
|
|
|
|
|
37
|
|
|
|
20
|
|
|
|
|
452
|
|
|
11
|
20
|
|
|
20
|
|
4244
|
use WebService::Braintree::CreditCard::Healthcare; |
|
|
20
|
|
|
|
|
35
|
|
|
|
20
|
|
|
|
|
499
|
|
|
12
|
20
|
|
|
20
|
|
4253
|
use WebService::Braintree::CreditCard::DurbinRegulated; |
|
|
20
|
|
|
|
|
35
|
|
|
|
20
|
|
|
|
|
430
|
|
|
13
|
20
|
|
|
20
|
|
4196
|
use WebService::Braintree::CreditCard::Commercial; |
|
|
20
|
|
|
|
|
36
|
|
|
|
20
|
|
|
|
|
464
|
|
|
14
|
20
|
|
|
20
|
|
4290
|
use WebService::Braintree::CreditCard::CountryOfIssuance; |
|
|
20
|
|
|
|
|
39
|
|
|
|
20
|
|
|
|
|
465
|
|
|
15
|
20
|
|
|
20
|
|
4216
|
use WebService::Braintree::CreditCard::IssuingBank; |
|
|
20
|
|
|
|
|
40
|
|
|
|
20
|
|
|
|
|
460
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
WebService::Braintree::CreditCard |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 PURPOSE |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This class creates, updates, deletes, and finds credit cards. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
20
|
|
|
20
|
|
87
|
use Moose; |
|
|
20
|
|
|
|
|
28
|
|
|
|
20
|
|
|
|
|
115
|
|
|
28
|
|
|
|
|
|
|
extends 'WebService::Braintree::PaymentMethod'; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 CLASS METHODS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 create() |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This takes a hashref of parameters and returns the credit card created. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub create { |
|
39
|
0
|
|
|
0
|
1
|
|
my ($class, $params) = @_; |
|
40
|
0
|
|
|
|
|
|
$class->gateway->credit_card->create($params); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 create() |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This takes a nonce and returns the credit card (if it exists). |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub from_nonce { |
|
50
|
0
|
|
|
0
|
0
|
|
my ($class, $nonce) = @_; |
|
51
|
0
|
|
|
|
|
|
$class->gateway->credit_card->from_nonce($nonce); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 find() |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This takes a token and returns the credit card (if it exists). |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub find { |
|
61
|
0
|
|
|
0
|
1
|
|
my ($class, $token) = @_; |
|
62
|
0
|
|
|
|
|
|
$class->gateway->credit_card->find($token); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 update() |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This takes a token and a hashref of parameters. It will update the |
|
68
|
|
|
|
|
|
|
corresponding credit card (if found) and returns the updated credit card. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub update { |
|
73
|
0
|
|
|
0
|
1
|
|
my($class, $token, $params) = @_; |
|
74
|
0
|
|
|
|
|
|
$class->gateway->credit_card->update($token, $params); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 update() |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This takes a token. It will delete the corresponding credit card (if found). |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub delete { |
|
84
|
0
|
|
|
0
|
1
|
|
my ($class, $token) = @_; |
|
85
|
0
|
|
|
|
|
|
$class->gateway->credit_card->delete($token); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub gateway { |
|
89
|
0
|
|
|
0
|
0
|
|
WebService::Braintree->configuration->gateway; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
In addition to the methods provided by the keys returned from Braintree, this |
|
95
|
|
|
|
|
|
|
class provides the following methods: |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 billing_address() |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This returns the credit card's billing address (if it exists). This will be an |
|
100
|
|
|
|
|
|
|
object of type L<WebService::Braintree::Address/>. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has billing_address => (is => 'rw'); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub BUILD { |
|
107
|
0
|
|
|
0
|
0
|
|
my ($self, $attrs) = @_; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->build_sub_object($attrs, |
|
110
|
|
|
|
|
|
|
method => 'billing_address', |
|
111
|
|
|
|
|
|
|
class => 'Address', |
|
112
|
|
|
|
|
|
|
key => 'billing_address', |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->set_attributes_from_hash($self, $attrs); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 masked_number() |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This returns a masked credit card number suitable for display. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub masked_number { |
|
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
126
|
0
|
|
|
|
|
|
return $self->bin . "******" . $self->last_4; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 expiration_date() |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This returns the credit card's expiration in MM/YY format. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub expiration_date { |
|
136
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
137
|
0
|
|
|
|
|
|
return $self->expiration_month . "/" . $self->expiration_year; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 is_default() |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This returns true if this credit card is the default credit card. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub is_default { |
|
147
|
0
|
|
|
0
|
1
|
|
return shift->default; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 is_venmo_sdk() |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This returns true if this credit card uses the Venmo SDK. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub is_venmo_sdk { |
|
157
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
return $self->venmo_sdk; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
|
164
|
|
|
|
|
|
|
__END__ |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 NOTES |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Most of the classes normally used in WebService::Braintree inherit from |
|
169
|
|
|
|
|
|
|
L<WebService::Braintree::ResultObject/>. This class, however, inherits from |
|
170
|
|
|
|
|
|
|
L<WebService::Braintree::PaymentMethod/>. The primary benefit of this is that |
|
171
|
|
|
|
|
|
|
these objects have a C<< token() >> attribute. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 TODO |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item Need to document the keys and values that are returned |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item Need to document the required and optional input parameters |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item Need to document the possible errors/exceptions |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |