| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Braintree::Configuration; |
|
2
|
|
|
|
|
|
|
$WebService::Braintree::Configuration::VERSION = '0.94'; |
|
3
|
20
|
|
|
20
|
|
380
|
use 5.010_001; |
|
|
20
|
|
|
|
|
72
|
|
|
4
|
20
|
|
|
20
|
|
107
|
use strictures 1; |
|
|
20
|
|
|
|
|
150
|
|
|
|
20
|
|
|
|
|
726
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WebService::Braintree::Configuration |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 PURPOSE |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This keeps all configuration information for your WebService::Braintree |
|
13
|
|
|
|
|
|
|
installation. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
A singleton of this class is instantiated when you use L<WebService::Braintree>. |
|
16
|
|
|
|
|
|
|
You are intended to set attributes of this class immediately, then the rest of |
|
17
|
|
|
|
|
|
|
the distribution knows what to do. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
20
|
|
|
20
|
|
6654
|
use WebService::Braintree::Gateway; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Moose; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# IS THIS UNUSED? I cannot find reference in the current documentation for Ruby |
|
25
|
|
|
|
|
|
|
# or Node.JS nor is it referenced anywhere else in the code. |
|
26
|
|
|
|
|
|
|
has partner_id => (is => 'rw'); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Get these values from L<Braintree's API credentials documentation|https://articles.braintreepayments.com/control-panel/important-gateway-credentials#api-credentials>. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
These attributes are standard mutators. If you invoke them with a value, they |
|
33
|
|
|
|
|
|
|
will set the attribute to that value. If you invoke them without a value, they |
|
34
|
|
|
|
|
|
|
will return the current value. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 merchant_id(?$value) |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This is your merchant_id. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has merchant_id => (is => 'rw'); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 public_key(?$value) |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This is your public_key. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has public_key => (is => 'rw'); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 private_key(?$value) |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is your private_key. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has private_key => (is => 'rw'); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 environment(?$value) |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is your environment. The environment can be: |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item development | integration |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is when you're using a local server for testing. It's unlikely you will |
|
69
|
|
|
|
|
|
|
ever want to use this. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item sandbox |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is when you're using your Braintree sandbox for testing. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item qa |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This is when you're using qa-master.braintreegateway.com for testing. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item production |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is when you're live and rocking. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
If you provide a value other than the ones listed above, a warning will be |
|
86
|
|
|
|
|
|
|
thrown. This distribution will probably not work properly in that case. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Management reserves the right to change this from a warning to a thrown |
|
89
|
|
|
|
|
|
|
exception in the future. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 USAGE |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Do yourself a favor and store these values in a configuration file, not your |
|
94
|
|
|
|
|
|
|
source-controlled code. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
has environment => ( |
|
99
|
|
|
|
|
|
|
is => 'rw', |
|
100
|
|
|
|
|
|
|
trigger => sub { |
|
101
|
|
|
|
|
|
|
my ($self, $new_value, $old_value) = @_; |
|
102
|
|
|
|
|
|
|
my %valid = map { $_ => 1 } qw( |
|
103
|
|
|
|
|
|
|
development integration sandbox qa production |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
if (!$valid{$new_value}) { |
|
106
|
|
|
|
|
|
|
warn 'Assigned invalid value to WebService::Braintree::Configuration::environment'; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if ($new_value eq 'integration') { |
|
110
|
|
|
|
|
|
|
$self->public_key('integration_public_key'); |
|
111
|
|
|
|
|
|
|
$self->private_key('integration_private_key'); |
|
112
|
|
|
|
|
|
|
$self->merchant_id('integration_merchant_id'); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
has gateway => (is => 'ro', lazy => 1, default => sub { |
|
118
|
|
|
|
|
|
|
WebService::Braintree::Gateway->new({config => shift}); |
|
119
|
|
|
|
|
|
|
}); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# This method is used in ::HTTP |
|
122
|
|
|
|
|
|
|
sub base_merchant_url { |
|
123
|
|
|
|
|
|
|
my $self = shift; |
|
124
|
|
|
|
|
|
|
return $self->base_url() . $self->base_merchant_path; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Below here, these methods do *NOT* appear to be used outside of this class. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub base_merchant_path { |
|
130
|
|
|
|
|
|
|
my $self = shift; |
|
131
|
|
|
|
|
|
|
return '/merchants/' . $self->merchant_id; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub base_url { |
|
135
|
|
|
|
|
|
|
my $self = shift; |
|
136
|
|
|
|
|
|
|
return $self->protocol . '://' . $self->server . ':' . $self->port; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub is_development { |
|
140
|
|
|
|
|
|
|
my $self = shift; |
|
141
|
|
|
|
|
|
|
return 1 if $self->environment eq 'development'; |
|
142
|
|
|
|
|
|
|
return 1 if $self->environment eq 'integration'; |
|
143
|
|
|
|
|
|
|
return; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub port { |
|
147
|
|
|
|
|
|
|
my $self = shift; |
|
148
|
|
|
|
|
|
|
if ($self->is_development) { |
|
149
|
|
|
|
|
|
|
return $ENV{'GATEWAY_PORT'} || '3000' |
|
150
|
|
|
|
|
|
|
} else { |
|
151
|
|
|
|
|
|
|
return 443; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub server { |
|
156
|
|
|
|
|
|
|
my $self = shift; |
|
157
|
|
|
|
|
|
|
return { |
|
158
|
|
|
|
|
|
|
development => 'localhost', |
|
159
|
|
|
|
|
|
|
integration => 'localhost', |
|
160
|
|
|
|
|
|
|
sandbox => 'api.sandbox.braintreegateway.com', |
|
161
|
|
|
|
|
|
|
qa => 'qa-master.braintreegateway.com', |
|
162
|
|
|
|
|
|
|
production => 'api.braintreegateway.com', |
|
163
|
|
|
|
|
|
|
}->{$self->environment}; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub auth_url { |
|
167
|
|
|
|
|
|
|
my $self = shift; |
|
168
|
|
|
|
|
|
|
return { |
|
169
|
|
|
|
|
|
|
development => 'http://auth.venmo.dev:9292', |
|
170
|
|
|
|
|
|
|
integration => 'http://auth.venmo.dev:9292', |
|
171
|
|
|
|
|
|
|
sandbox => 'https://auth.sandbox.venmo.com', |
|
172
|
|
|
|
|
|
|
qa => 'https://auth.qa.venmo.com', |
|
173
|
|
|
|
|
|
|
production => 'https://auth.venmo.com', |
|
174
|
|
|
|
|
|
|
}->{$self->environment}; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub ssl_enabled { |
|
179
|
|
|
|
|
|
|
my $self = shift; |
|
180
|
|
|
|
|
|
|
return ! $self->is_development; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub protocol { |
|
184
|
|
|
|
|
|
|
my $self = shift; |
|
185
|
|
|
|
|
|
|
return $self->ssl_enabled ? 'https' : 'http'; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 METHODS |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
There is one read-only method. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 api_version() |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This returns the Braintree API version this distribution speaks. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# This method is used in ::HTTP |
|
199
|
|
|
|
|
|
|
sub api_version { |
|
200
|
|
|
|
|
|
|
return "4"; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
|
206
|
|
|
|
|
|
|
__END__ |