line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::Result; |
2
|
|
|
|
|
|
|
$WebService::Braintree::Result::VERSION = '0.92'; |
3
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5492
|
use Hash::Inflator; |
|
1
|
|
|
|
|
360
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
5
|
use WebService::Braintree::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
6
|
1
|
|
|
1
|
|
256
|
use WebService::Braintree::ValidationErrorCollection; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
342
|
use WebService::Braintree::CreditCardVerification; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
427
|
use WebService::Braintree::Nonce; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
415
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $response_objects = { |
13
|
|
|
|
|
|
|
address => "WebService::Braintree::Address", |
14
|
|
|
|
|
|
|
apple_pay => "WebService::Braintree::ApplePayCard", |
15
|
|
|
|
|
|
|
apple_pay_card => "WebService::Braintree::ApplePayCard", |
16
|
|
|
|
|
|
|
credit_card => "WebService::Braintree::CreditCard", |
17
|
|
|
|
|
|
|
customer => "WebService::Braintree::Customer", |
18
|
|
|
|
|
|
|
merchant_account => "WebService::Braintree::MerchantAccount", |
19
|
|
|
|
|
|
|
payment_method => { |
20
|
|
|
|
|
|
|
credit_card => "WebService::Braintree::CreditCard", |
21
|
|
|
|
|
|
|
paypal_account => "WebService::Braintree::PayPalAccount" |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
payment_method_nonce => "WebService::Braintree::Nonce", |
24
|
|
|
|
|
|
|
settlement_batch_summary => "WebService::Braintree::SettlementBatchSummary", |
25
|
|
|
|
|
|
|
subscription => "WebService::Braintree::Subscription", |
26
|
|
|
|
|
|
|
transaction => "WebService::Braintree::Transaction", |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has response => ( is => 'ro' ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _get_response { |
32
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
33
|
0
|
|
0
|
|
|
0
|
return $self->response->{'api_error_response'} || $self->response; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub patch_in_response_accessors { |
37
|
2
|
|
|
2
|
0
|
4
|
my $field_rules = shift; |
38
|
2
|
|
|
|
|
9
|
while (my($key, $rule) = each(%$field_rules)) { |
39
|
13
|
100
|
|
|
|
358
|
if (ref($rule) eq "HASH") { |
40
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
41
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
42
|
0
|
|
|
|
|
0
|
my $response = $self->_get_response(); |
43
|
0
|
|
|
|
|
0
|
while (my($subkey, $subrule) = each(%$rule)) { |
44
|
0
|
|
|
|
|
0
|
my $field_value = $self->$subkey; |
45
|
0
|
0
|
|
|
|
0
|
if ($field_value) { |
46
|
0
|
|
|
|
|
0
|
keys %$rule; |
47
|
0
|
|
|
|
|
0
|
return $field_value; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
return undef; |
52
|
1
|
|
|
|
|
4
|
}); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
32
|
patch_in_response_accessors($rule); |
55
|
|
|
|
|
|
|
} else { |
56
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
58
|
0
|
|
|
|
|
|
my $response = $self->_get_response(); |
59
|
0
|
0
|
|
|
|
|
if (!$response->{$key}) { |
60
|
0
|
|
|
|
|
|
return undef; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $rule->new($response->{$key}); |
64
|
12
|
|
|
|
|
41
|
}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
patch_in_response_accessors($response_objects); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub is_success { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
0
|
|
|
|
|
return 1 unless $self->response->{'api_error_response'}; |
74
|
0
|
|
|
|
|
|
return 0; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub api_error_response { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
return $self->response->{'api_error_response'}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub message { |
83
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
84
|
0
|
0
|
|
|
|
|
return $self->api_error_response->{'message'} if $self->api_error_response; |
85
|
0
|
|
|
|
|
|
return ""; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub errors { |
89
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
90
|
0
|
|
|
|
|
|
return WebService::Braintree::ValidationErrorCollection->new($self->api_error_response->{errors}); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub credit_card_verification { |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
return WebService::Braintree::CreditCardVerification->new($self->api_error_response->{verification}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|