braintree 2.10.3 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/braintree.rb +2 -2
- data/lib/braintree/configuration.rb +3 -9
- data/lib/braintree/error_codes.rb +7 -0
- data/lib/braintree/error_result.rb +0 -6
- data/lib/braintree/gateway.rb +2 -2
- data/lib/braintree/http.rb +1 -1
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/settlement_batch_summary.rb +24 -0
- data/lib/braintree/settlement_batch_summary_gateway.rb +24 -0
- data/lib/braintree/successful_result.rb +0 -4
- data/lib/braintree/test/credit_card_numbers.rb +0 -7
- data/lib/braintree/version.rb +2 -2
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +61 -0
- data/spec/integration/braintree/transaction_spec.rb +0 -100
- data/spec/unit/braintree/configuration_spec.rb +2 -9
- data/spec/unit/braintree/error_result_spec.rb +0 -13
- data/spec/unit/braintree/successful_result_spec.rb +0 -6
- metadata +11 -10
- data/lib/braintree/payer_authentication.rb +0 -31
- data/lib/braintree/payer_authentication_gateway.rb +0 -25
- data/spec/unit/braintree/payer_authentication_spec.rb +0 -38
data/lib/braintree.rb
CHANGED
@@ -41,8 +41,8 @@ require File.dirname(__FILE__) + "/braintree/error_result"
|
|
41
41
|
require File.dirname(__FILE__) + "/braintree/errors"
|
42
42
|
require File.dirname(__FILE__) + "/braintree/gateway"
|
43
43
|
require File.dirname(__FILE__) + "/braintree/http"
|
44
|
-
require File.dirname(__FILE__) + "/braintree/
|
45
|
-
require File.dirname(__FILE__) + "/braintree/
|
44
|
+
require File.dirname(__FILE__) + "/braintree/settlement_batch_summary"
|
45
|
+
require File.dirname(__FILE__) + "/braintree/settlement_batch_summary_gateway"
|
46
46
|
require File.dirname(__FILE__) + "/braintree/resource_collection"
|
47
47
|
require File.dirname(__FILE__) + "/braintree/subscription"
|
48
48
|
require File.dirname(__FILE__) + "/braintree/subscription_gateway"
|
@@ -2,10 +2,9 @@ module Braintree
|
|
2
2
|
# See http://www.braintreepayments.com/docs/ruby
|
3
3
|
class Configuration
|
4
4
|
API_VERSION = "2" # :nodoc:
|
5
|
-
DEFAULT_ENDPOINT = "www" # :nodoc:
|
6
5
|
|
7
6
|
class << self
|
8
|
-
attr_writer :custom_user_agent, :
|
7
|
+
attr_writer :custom_user_agent, :logger, :merchant_id, :public_key, :private_key
|
9
8
|
end
|
10
9
|
attr_reader :merchant_id, :public_key, :private_key
|
11
10
|
|
@@ -35,7 +34,6 @@ module Braintree
|
|
35
34
|
def self.instantiate # :nodoc:
|
36
35
|
config = new(
|
37
36
|
:custom_user_agent => @custom_user_agent,
|
38
|
-
:endpoint => @endpoint,
|
39
37
|
:environment => environment,
|
40
38
|
:logger => logger,
|
41
39
|
:merchant_id => merchant_id,
|
@@ -49,7 +47,7 @@ module Braintree
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def initialize(options = {})
|
52
|
-
[:
|
50
|
+
[:environment, :merchant_id, :public_key, :private_key, :custom_user_agent, :logger].each do |attr|
|
53
51
|
instance_variable_set "@#{attr}", options[attr]
|
54
52
|
end
|
55
53
|
end
|
@@ -75,10 +73,6 @@ module Braintree
|
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
78
|
-
def endpoint
|
79
|
-
@endpoint || DEFAULT_ENDPOINT
|
80
|
-
end
|
81
|
-
|
82
76
|
def http # :nodoc:
|
83
77
|
Http.new(self)
|
84
78
|
end
|
@@ -105,7 +99,7 @@ module Braintree
|
|
105
99
|
when :development
|
106
100
|
"localhost"
|
107
101
|
when :production
|
108
|
-
"
|
102
|
+
"www.braintreegateway.com"
|
109
103
|
when :qa
|
110
104
|
"qa-master.braintreegateway.com"
|
111
105
|
when :sandbox
|
@@ -84,6 +84,12 @@ module Braintree
|
|
84
84
|
NameFormatIsInvalid = "92201"
|
85
85
|
end
|
86
86
|
|
87
|
+
module SettlementBatchSummary
|
88
|
+
CustomFieldIsInvalid = "82303"
|
89
|
+
SettlementDateIsInvalid = "82302"
|
90
|
+
SettlementDateIsRequired = "82301"
|
91
|
+
end
|
92
|
+
|
87
93
|
# See http://www.braintreepayments.com/docs/ruby/subscriptions/validations
|
88
94
|
module Subscription
|
89
95
|
BillingDayOfMonthCannotBeUpdated = "91918"
|
@@ -101,6 +107,7 @@ module Braintree
|
|
101
107
|
InconsistentStartDate = "91917"
|
102
108
|
InvalidRequestFormat = "91921"
|
103
109
|
MerchantAccountIdIsInvalid = "91901"
|
110
|
+
MismatchCurrencyISOCode = "91923"
|
104
111
|
NumberOfBillingCyclesCannotBeBlank = "91912"
|
105
112
|
NumberOfBillingCyclesIsTooSmall = "91909"
|
106
113
|
NumberOfBillingCyclesMustBeGreaterThanZero = "91907"
|
@@ -3,14 +3,12 @@ module Braintree
|
|
3
3
|
class ErrorResult
|
4
4
|
|
5
5
|
attr_reader :credit_card_verification, :transaction, :subscription, :errors, :params, :message
|
6
|
-
attr_reader :payer_authentication
|
7
6
|
|
8
7
|
def initialize(gateway, data) # :nodoc:
|
9
8
|
@gateway = gateway
|
10
9
|
@params = data[:params]
|
11
10
|
@credit_card_verification = CreditCardVerification._new(data[:verification]) if data[:verification]
|
12
11
|
@message = data[:message]
|
13
|
-
@payer_authentication = PayerAuthentication._new(gateway, data[:payer_authentication]) if data[:payer_authentication]
|
14
12
|
@transaction = Transaction._new(gateway, data[:transaction]) if data[:transaction]
|
15
13
|
@subscription = Subscription._new(gateway, data[:subscription]) if data[:subscription]
|
16
14
|
@errors = Errors.new(data[:errors])
|
@@ -26,10 +24,6 @@ module Braintree
|
|
26
24
|
"#<#{self.class} params:{...} errors:<#{@errors._inner_inspect}>#{verification_inspect}#{transaction_inspect}>"
|
27
25
|
end
|
28
26
|
|
29
|
-
def payer_authentication_required?
|
30
|
-
!!@payer_authentication
|
31
|
-
end
|
32
|
-
|
33
27
|
# Always returns false.
|
34
28
|
def success?
|
35
29
|
false
|
data/lib/braintree/gateway.rb
CHANGED
data/lib/braintree/http.rb
CHANGED
@@ -16,7 +16,7 @@ module Braintree
|
|
16
16
|
|
17
17
|
def get(path)
|
18
18
|
response = _http_do Net::HTTP::Get, path
|
19
|
-
if response.code.to_i == 200
|
19
|
+
if response.code.to_i == 200 || response.code.to_i == 422
|
20
20
|
Xml.hash_from_xml(_body(response))
|
21
21
|
else
|
22
22
|
Util.raise_exception_for_status_code(response.code)
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Braintree
|
2
|
+
class SettlementBatchSummary
|
3
|
+
include BaseModule
|
4
|
+
attr_reader :records
|
5
|
+
|
6
|
+
def self.generate(settlement_date, group_by_custom_field = nil)
|
7
|
+
criteria = { :settlement_date => settlement_date }
|
8
|
+
criteria.merge!({:group_by_custom_field => group_by_custom_field}) if group_by_custom_field
|
9
|
+
Configuration.gateway.settlement_batch_summary.generate(criteria)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(gateway, attributes)
|
13
|
+
@gateway = gateway
|
14
|
+
set_instance_variables_from_hash(attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
protected :new
|
19
|
+
def _new(*args)
|
20
|
+
self.new(*args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Braintree
|
2
|
+
class SettlementBatchSummaryGateway # :nodoc
|
3
|
+
def initialize(gateway)
|
4
|
+
@gateway = gateway
|
5
|
+
@config = gateway.config
|
6
|
+
end
|
7
|
+
|
8
|
+
def generate(criteria)
|
9
|
+
Util.verify_keys(_signature, criteria)
|
10
|
+
response = @config.http.post "/settlement_batch_summary", :settlement_batch_summary => criteria
|
11
|
+
if response[:settlement_batch_summary]
|
12
|
+
SuccessfulResult.new(:settlement_batch_summary => SettlementBatchSummary._new(@gateway, response[:settlement_batch_summary]))
|
13
|
+
elsif response[:api_error_response]
|
14
|
+
ErrorResult.new(@gateway, response[:api_error_response])
|
15
|
+
else
|
16
|
+
raise UnexpectedError, "expected :settlement_batch_summary or :api_error_response"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def _signature
|
21
|
+
[:settlement_date, :group_by_custom_field]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -25,13 +25,6 @@ module Braintree
|
|
25
25
|
Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115]
|
26
26
|
Unknowns = %w[1000000000000008]
|
27
27
|
|
28
|
-
module PayerAuthentication
|
29
|
-
ValidMaestro = "6304000000000000"
|
30
|
-
InvalidMaestro = "6773900000000000007"
|
31
|
-
AuthenticationSuccessfulPayload = "authentication_successful_payload"
|
32
|
-
AuthenticationFailedPayload = "authentication_failed_payload"
|
33
|
-
end
|
34
|
-
|
35
28
|
module FailsSandboxVerification
|
36
29
|
AmEx = "378734493671000"
|
37
30
|
Discover = "6011000990139424"
|
data/lib/braintree/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
3
|
+
|
4
|
+
describe Braintree::SettlementBatchSummary do
|
5
|
+
describe "self.generate" do
|
6
|
+
it "returns an empty collection if there is not data" do
|
7
|
+
result = Braintree::SettlementBatchSummary.generate("1979-01-01")
|
8
|
+
result.should be_success
|
9
|
+
result.settlement_batch_summary.records.size.should be_zero
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns an error response if the date cannot be parsed" do
|
13
|
+
result = Braintree::SettlementBatchSummary.generate("NOT A DATE :(")
|
14
|
+
result.should_not be_success
|
15
|
+
result.errors.for(:settlement_batch_summary).on(:settlement_date).map {|e| e.code}.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns transactions settled on a given day" do
|
19
|
+
transaction = Braintree::Transaction.sale!(
|
20
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
21
|
+
:credit_card => {
|
22
|
+
:number => Braintree::Test::CreditCardNumbers::AmExes.first,
|
23
|
+
:expiration_date => "05/2012",
|
24
|
+
:cardholder_name => "Sergio Ramos"
|
25
|
+
},
|
26
|
+
:options => { :submit_for_settlement => true }
|
27
|
+
)
|
28
|
+
SpecHelper.settle_transaction transaction.id
|
29
|
+
|
30
|
+
result = Braintree::SettlementBatchSummary.generate(Time.now.strftime("%Y-%m-%d"))
|
31
|
+
result.should be_success
|
32
|
+
amex_records = result.settlement_batch_summary.records.select {|row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
33
|
+
amex_records.first[:count].to_i.should >= 1
|
34
|
+
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can be grouped by a custom field" do
|
38
|
+
transaction = Braintree::Transaction.sale!(
|
39
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
40
|
+
:credit_card => {
|
41
|
+
:number => Braintree::Test::CreditCardNumbers::AmExes.first,
|
42
|
+
:expiration_date => "05/2012",
|
43
|
+
:cardholder_name => "Sergio Ramos"
|
44
|
+
},
|
45
|
+
:custom_fields => {
|
46
|
+
:store_me => "1"
|
47
|
+
},
|
48
|
+
:options => { :submit_for_settlement => true }
|
49
|
+
)
|
50
|
+
SpecHelper.settle_transaction transaction.id
|
51
|
+
|
52
|
+
result = Braintree::SettlementBatchSummary.generate(Time.now.strftime("%Y-%m-%d"), 'store_me')
|
53
|
+
result.should be_success
|
54
|
+
|
55
|
+
amex_records = result.settlement_batch_summary.records.select {|row| row[:store_me] == "1" }
|
56
|
+
amex_records.should_not be_empty
|
57
|
+
amex_records.first[:count].to_i.should >= 1
|
58
|
+
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -152,106 +152,6 @@ describe Braintree::Transaction do
|
|
152
152
|
codes.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
153
153
|
end
|
154
154
|
|
155
|
-
context "maestro authentication" do
|
156
|
-
it "returns an authentication response on successful lookup" do
|
157
|
-
result = Braintree::Transaction.create(
|
158
|
-
:type => "sale",
|
159
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
160
|
-
:merchant_account_id => "secure_code_ma",
|
161
|
-
:credit_card => {
|
162
|
-
:number => Braintree::Test::CreditCardNumbers::PayerAuthentication::ValidMaestro,
|
163
|
-
:expiration_date => "01/2012"
|
164
|
-
}
|
165
|
-
)
|
166
|
-
|
167
|
-
result.success?.should == false
|
168
|
-
result.payer_authentication_required?.should == true
|
169
|
-
|
170
|
-
payer_authentication = result.payer_authentication
|
171
|
-
payer_authentication.id.should match(/\A[a-z0-9]+\z/)
|
172
|
-
payer_authentication.post_url.should match(%r{\Ahttps?://})
|
173
|
-
payer_authentication.post_params.size.should == 1
|
174
|
-
payer_authentication.post_params.first.name.should == "PaReq"
|
175
|
-
payer_authentication.post_params.first.value.should_not be_empty
|
176
|
-
|
177
|
-
result = Braintree::PayerAuthentication.authenticate(
|
178
|
-
payer_authentication.id,
|
179
|
-
Braintree::Test::CreditCardNumbers::PayerAuthentication::AuthenticationSuccessfulPayload
|
180
|
-
)
|
181
|
-
|
182
|
-
result.success?.should == true
|
183
|
-
result.transaction.id.should =~ /^\w{6}$/
|
184
|
-
result.transaction.type.should == "sale"
|
185
|
-
result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
|
186
|
-
result.transaction.processor_authorization_code.should_not be_nil
|
187
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Maestro[0, 6]
|
188
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Maestro[-4..-1]
|
189
|
-
result.transaction.credit_card_details.expiration_date.should == "01/2012"
|
190
|
-
result.transaction.credit_card_details.customer_location.should == "US"
|
191
|
-
end
|
192
|
-
|
193
|
-
it "attempts to create the transaction on an unsuccessful authentication" do
|
194
|
-
result = Braintree::Transaction.create(
|
195
|
-
:type => "sale",
|
196
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
197
|
-
:merchant_account_id => "secure_code_ma",
|
198
|
-
:credit_card => {
|
199
|
-
:number => Braintree::Test::CreditCardNumbers::PayerAuthentication::ValidMaestro,
|
200
|
-
:expiration_date => "01/2012"
|
201
|
-
}
|
202
|
-
)
|
203
|
-
|
204
|
-
result.success?.should == false
|
205
|
-
result.payer_authentication_required?.should == true
|
206
|
-
|
207
|
-
payer_authentication = result.payer_authentication
|
208
|
-
payer_authentication.id.should match(/\A[a-z0-9]+\z/)
|
209
|
-
payer_authentication.post_url.should match(%r{\Ahttps?://})
|
210
|
-
payer_authentication.post_params.size.should == 1
|
211
|
-
payer_authentication.post_params.first.name.should == "PaReq"
|
212
|
-
payer_authentication.post_params.first.value.should_not be_empty
|
213
|
-
|
214
|
-
result = Braintree::PayerAuthentication.authenticate(
|
215
|
-
payer_authentication.id,
|
216
|
-
Braintree::Test::CreditCardNumbers::PayerAuthentication::AuthenticationFailedPayload
|
217
|
-
)
|
218
|
-
|
219
|
-
result.success?.should == true
|
220
|
-
result.transaction.id.should =~ /^\w{6}$/
|
221
|
-
result.transaction.type.should == "sale"
|
222
|
-
result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
|
223
|
-
result.transaction.processor_authorization_code.should_not be_nil
|
224
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Maestro[0, 6]
|
225
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Maestro[-4..-1]
|
226
|
-
result.transaction.credit_card_details.expiration_date.should == "01/2012"
|
227
|
-
result.transaction.credit_card_details.customer_location.should == "US"
|
228
|
-
end
|
229
|
-
|
230
|
-
it "runs a regular transaction on unsuccessful lookup" do
|
231
|
-
cc_number = Braintree::Test::CreditCardNumbers::PayerAuthentication::InvalidMaestro
|
232
|
-
result = Braintree::Transaction.create(
|
233
|
-
:type => "sale",
|
234
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
235
|
-
:merchant_account_id => "secure_code_ma",
|
236
|
-
:credit_card => {
|
237
|
-
:number => cc_number,
|
238
|
-
:expiration_date => "01/2012"
|
239
|
-
}
|
240
|
-
)
|
241
|
-
|
242
|
-
result.payer_authentication_required?.should == false
|
243
|
-
result.success?.should == true
|
244
|
-
result.transaction.id.should =~ /^\w{6}$/
|
245
|
-
result.transaction.type.should == "sale"
|
246
|
-
result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
|
247
|
-
result.transaction.processor_authorization_code.should_not be_nil
|
248
|
-
result.transaction.credit_card_details.bin.should == cc_number[0, 6]
|
249
|
-
result.transaction.credit_card_details.last_4.should == cc_number[-4..-1]
|
250
|
-
result.transaction.credit_card_details.expiration_date.should == "01/2012"
|
251
|
-
result.transaction.credit_card_details.customer_location.should == "US"
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
155
|
context "gateway rejection reason" do
|
256
156
|
it "exposes the cvv gateway rejection reason" do
|
257
157
|
old_merchant = Braintree::Configuration.merchant_id
|
@@ -11,10 +11,9 @@ describe Braintree::Configuration do
|
|
11
11
|
|
12
12
|
after do
|
13
13
|
Braintree::Configuration.merchant_id = @original_merchant_id
|
14
|
-
Braintree::Configuration.public_key
|
14
|
+
Braintree::Configuration.public_key = @original_public_key
|
15
15
|
Braintree::Configuration.private_key = @original_private_key
|
16
16
|
Braintree::Configuration.environment = @original_environment
|
17
|
-
Braintree::Configuration.endpoint = Braintree::Configuration::DEFAULT_ENDPOINT
|
18
17
|
end
|
19
18
|
|
20
19
|
describe "base_merchant_path" do
|
@@ -181,7 +180,7 @@ describe Braintree::Configuration do
|
|
181
180
|
|
182
181
|
end
|
183
182
|
|
184
|
-
describe "server" do
|
183
|
+
describe "self.server" do
|
185
184
|
it "is localhost for development" do
|
186
185
|
Braintree::Configuration.environment = :development
|
187
186
|
Braintree::Configuration.instantiate.server.should == "localhost"
|
@@ -196,12 +195,6 @@ describe Braintree::Configuration do
|
|
196
195
|
Braintree::Configuration.environment = :sandbox
|
197
196
|
Braintree::Configuration.instantiate.server.should == "sandbox.braintreegateway.com"
|
198
197
|
end
|
199
|
-
|
200
|
-
it "can by changed by configuring the production endpoint" do
|
201
|
-
Braintree::Configuration.environment = :production
|
202
|
-
Braintree::Configuration.endpoint = "custom-endpoint"
|
203
|
-
Braintree::Configuration.instantiate.server.should == "custom-endpoint.braintreegateway.com"
|
204
|
-
end
|
205
198
|
end
|
206
199
|
|
207
200
|
describe "ssl?" do
|
@@ -74,17 +74,4 @@ describe Braintree::ErrorResult do
|
|
74
74
|
result.inspect.should_not include("transaction")
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
78
|
-
describe "payer_authentication_required?" do
|
79
|
-
it "is true if payer_authentication is in the response" do
|
80
|
-
result = Braintree::ErrorResult.new(
|
81
|
-
:gateway,
|
82
|
-
:payer_authentication => {:id => "public_id", :post_url => "post_url", :post_params => []},
|
83
|
-
:errors => {},
|
84
|
-
:verification => nil,
|
85
|
-
:transaction => nil
|
86
|
-
)
|
87
|
-
result.payer_authentication_required?.should be_true
|
88
|
-
end
|
89
|
-
end
|
90
77
|
end
|
@@ -24,10 +24,4 @@ describe Braintree::SuccessfulResult do
|
|
24
24
|
result.inspect.should == "#<Braintree::SuccessfulResult foo:\"foo_value\">"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
describe "payer_authentication_required?" do
|
29
|
-
it "is always false" do
|
30
|
-
Braintree::SuccessfulResult.new.payer_authentication_required?.should be_false
|
31
|
-
end
|
32
|
-
end
|
33
27
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 35
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 11
|
9
|
+
- 0
|
10
|
+
version: 2.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Braintree
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-24 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -68,9 +68,10 @@ files:
|
|
68
68
|
- lib/braintree/gateway.rb
|
69
69
|
- lib/braintree/http.rb
|
70
70
|
- lib/braintree/modification.rb
|
71
|
-
- lib/braintree/payer_authentication.rb
|
72
|
-
- lib/braintree/payer_authentication_gateway.rb
|
73
71
|
- lib/braintree/resource_collection.rb
|
72
|
+
- lib/braintree/settlement_batch.rb
|
73
|
+
- lib/braintree/settlement_batch_summary.rb
|
74
|
+
- lib/braintree/settlement_batch_summary_gateway.rb
|
74
75
|
- lib/braintree/subscription.rb
|
75
76
|
- lib/braintree/subscription_gateway.rb
|
76
77
|
- lib/braintree/subscription_search.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- spec/integration/braintree/customer_spec.rb
|
106
107
|
- spec/integration/braintree/error_codes_spec.rb
|
107
108
|
- spec/integration/braintree/http_spec.rb
|
109
|
+
- spec/integration/braintree/settlement_batch_summary_spec.rb
|
108
110
|
- spec/integration/braintree/subscription_spec.rb
|
109
111
|
- spec/integration/braintree/test/transaction_amounts_spec.rb
|
110
112
|
- spec/integration/braintree/transaction_search_spec.rb
|
@@ -123,7 +125,6 @@ files:
|
|
123
125
|
- spec/unit/braintree/error_result_spec.rb
|
124
126
|
- spec/unit/braintree/errors_spec.rb
|
125
127
|
- spec/unit/braintree/http_spec.rb
|
126
|
-
- spec/unit/braintree/payer_authentication_spec.rb
|
127
128
|
- spec/unit/braintree/resource_collection_spec.rb
|
128
129
|
- spec/unit/braintree/subscription_search_spec.rb
|
129
130
|
- spec/unit/braintree/subscription_spec.rb
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
requirements: []
|
176
177
|
|
177
178
|
rubyforge_project: braintree
|
178
|
-
rubygems_version: 1.
|
179
|
+
rubygems_version: 1.3.7
|
179
180
|
signing_key:
|
180
181
|
specification_version: 3
|
181
182
|
summary: Braintree Gateway Ruby Client Library
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class PayerAuthentication
|
3
|
-
include BaseModule # :nodoc:
|
4
|
-
|
5
|
-
attr_reader :id, :post_params, :post_url
|
6
|
-
|
7
|
-
def self.authenticate(payer_authentication_id, response_payload)
|
8
|
-
Configuration.gateway.payer_authentication.authenticate(
|
9
|
-
payer_authentication_id,
|
10
|
-
response_payload
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(gateway, attributes) # :nodoc:
|
15
|
-
@gateway = gateway
|
16
|
-
set_instance_variables_from_hash(attributes)
|
17
|
-
|
18
|
-
@post_params = (@post_params || []).map do |params|
|
19
|
-
OpenStruct.new(:name => params[:name], :value => params[:value])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class << self
|
24
|
-
protected :new
|
25
|
-
end
|
26
|
-
|
27
|
-
def self._new(*args) # :nodoc:
|
28
|
-
self.new *args
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class PayerAuthenticationGateway # :nodoc:
|
3
|
-
def initialize(gateway)
|
4
|
-
@gateway = gateway
|
5
|
-
@config = gateway.config
|
6
|
-
end
|
7
|
-
|
8
|
-
def authenticate(payer_authentication_id, response_payload)
|
9
|
-
response = @config.http.post(
|
10
|
-
"/payer_authentications/#{payer_authentication_id}/authenticate",
|
11
|
-
:payer_authentication => {
|
12
|
-
:response_payload => response_payload
|
13
|
-
}
|
14
|
-
)
|
15
|
-
|
16
|
-
if response[:transaction]
|
17
|
-
SuccessfulResult.new(:transaction => Transaction._new(@gateway, response[:transaction]))
|
18
|
-
elsif response[:api_error_response]
|
19
|
-
ErrorResult.new(@gateway, response[:api_error_response])
|
20
|
-
else
|
21
|
-
raise UnexpectedError, "expected :transaction or :api_error_response"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
describe Braintree::PayerAuthentication do
|
4
|
-
describe "id" do
|
5
|
-
it "returns the given id" do
|
6
|
-
payer_authentication = Braintree::PayerAuthentication._new(
|
7
|
-
:gateway,
|
8
|
-
:id => :test_id
|
9
|
-
)
|
10
|
-
|
11
|
-
payer_authentication.id.should == :test_id
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "post_params" do
|
16
|
-
it "returns the given post params" do
|
17
|
-
payer_authentication = Braintree::PayerAuthentication._new(
|
18
|
-
:gateway,
|
19
|
-
:post_params => [{:name => 'imaname', :value => 'andimavalue'}]
|
20
|
-
)
|
21
|
-
|
22
|
-
post_param = payer_authentication.post_params.first
|
23
|
-
post_param.name.should == 'imaname'
|
24
|
-
post_param.value.should == 'andimavalue'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "post_url" do
|
29
|
-
it "returns the given post url" do
|
30
|
-
payer_authentication = Braintree::PayerAuthentication._new(
|
31
|
-
:gateway,
|
32
|
-
:post_url => "http://example.com"
|
33
|
-
)
|
34
|
-
|
35
|
-
payer_authentication.post_url.should == "http://example.com"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|