braintree 2.102.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +6 -3
- data/lib/braintree.rb +3 -17
- data/lib/braintree/address.rb +0 -22
- data/lib/braintree/address_gateway.rb +2 -2
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +5 -76
- data/lib/braintree/credit_card_gateway.rb +3 -32
- data/lib/braintree/credit_card_verification.rb +14 -0
- data/lib/braintree/customer.rb +3 -72
- data/lib/braintree/customer_gateway.rb +0 -23
- data/lib/braintree/dispute.rb +1 -7
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute/transaction.rb +2 -0
- data/lib/braintree/dispute_gateway.rb +2 -7
- data/lib/braintree/error_codes.rb +152 -170
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/gateway.rb +0 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +1 -1
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +2 -0
- data/lib/braintree/payment_instrument_type.rb +1 -4
- data/lib/braintree/payment_method_gateway.rb +4 -8
- data/lib/braintree/payment_method_parser.rb +1 -7
- data/lib/braintree/risk_data.rb +4 -1
- data/lib/braintree/subscription.rb +5 -5
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +5 -20
- data/lib/braintree/transaction.rb +9 -73
- data/lib/braintree/transaction/address_details.rb +11 -0
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/paypal_details.rb +3 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +14 -21
- data/lib/braintree/transaction_search.rb +0 -1
- data/lib/braintree/util.rb +17 -2
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/webhook_notification.rb +0 -10
- data/lib/braintree/webhook_testing_gateway.rb +0 -43
- data/lib/braintree/xml/libxml.rb +1 -0
- data/lib/braintree/xml/parser.rb +11 -34
- data/spec/integration/braintree/address_spec.rb +2 -89
- data/spec/integration/braintree/client_api/spec_helper.rb +92 -66
- data/spec/integration/braintree/credit_card_spec.rb +20 -467
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -0
- data/spec/integration/braintree/customer_spec.rb +22 -362
- data/spec/integration/braintree/dispute_search_spec.rb +3 -3
- data/spec/integration/braintree/dispute_spec.rb +1 -2
- data/spec/integration/braintree/merchant_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_spec.rb +77 -120
- data/spec/integration/braintree/paypal_account_spec.rb +1 -1
- data/spec/integration/braintree/subscription_spec.rb +11 -16
- data/spec/integration/braintree/transaction_search_spec.rb +3 -3
- data/spec/integration/braintree/transaction_spec.rb +274 -524
- data/spec/integration/spec_helper.rb +1 -4
- data/spec/spec_helper.rb +1 -11
- data/spec/unit/braintree/address_spec.rb +0 -8
- data/spec/unit/braintree/credit_card_spec.rb +28 -21
- data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
- data/spec/unit/braintree/customer_spec.rb +4 -12
- data/spec/unit/braintree/dispute_spec.rb +4 -12
- data/spec/unit/braintree/http_spec.rb +3 -3
- data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +59 -0
- data/spec/unit/braintree/transaction_spec.rb +17 -37
- data/spec/unit/braintree/util_spec.rb +37 -3
- data/spec/unit/braintree/webhook_notification_spec.rb +1 -1
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- metadata +28 -32
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -81
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/coinbase_details.rb +0 -16
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/braintree/xml/rexml.rb +0 -71
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
- data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -5,7 +5,6 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
5
5
|
SSL_TEST_PORT = ENV['SSL_TEST_PORT'] || 8444
|
6
6
|
|
7
7
|
require File.dirname(__FILE__) + "/../spec_helper"
|
8
|
-
require File.dirname(__FILE__) + "/../hacks/tcp_socket"
|
9
8
|
|
10
9
|
def start_ssl_server
|
11
10
|
web_server_pid_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "httpsd.pid"))
|
@@ -13,9 +12,7 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
13
12
|
FileUtils.rm(web_server_pid_file) if File.exist?(web_server_pid_file)
|
14
13
|
command = File.expand_path(File.join(File.dirname(__FILE__), "..", "script", "httpsd.rb"))
|
15
14
|
`#{command} #{web_server_pid_file}`
|
16
|
-
TCPSocket.
|
17
|
-
|
18
|
-
yield
|
15
|
+
TCPSocket.new("127.0.0.1",SSL_TEST_PORT)
|
19
16
|
|
20
17
|
10.times { unless File.exists?(web_server_pid_file); sleep 1; end }
|
21
18
|
ensure
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
4
4
|
require "rubygems"
|
5
5
|
require "bundler/setup"
|
6
6
|
require "rspec"
|
7
|
-
require "libxml"
|
8
7
|
require "pry"
|
9
8
|
|
10
9
|
braintree_lib = "#{project_root}/lib"
|
@@ -28,10 +27,6 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
def now_in_eastern
|
32
|
-
(Time.now.utc - 5*60*60).strftime("%Y-%m-%d")
|
33
|
-
end
|
34
|
-
|
35
30
|
module SpecHelper
|
36
31
|
|
37
32
|
DefaultMerchantAccountId = "sandbox_credit_card"
|
@@ -188,16 +183,11 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
188
183
|
end
|
189
184
|
|
190
185
|
def matches?(xml_string)
|
191
|
-
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string
|
192
|
-
@rexml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string, Braintree::Xml::Rexml)
|
186
|
+
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
|
193
187
|
if @libxml_parse != @expected_hash
|
194
188
|
@results = @libxml_parse
|
195
189
|
@failed_parser = "libxml"
|
196
190
|
false
|
197
|
-
elsif @rexml_parse != @expected_hash
|
198
|
-
@results = @rexml_parse
|
199
|
-
@failed_parser = "rexml"
|
200
|
-
false
|
201
191
|
else
|
202
192
|
true
|
203
193
|
end
|
@@ -94,12 +94,4 @@ describe Braintree::Address do
|
|
94
94
|
end.to raise_error(NoMethodError, /protected method .new/)
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
98
|
-
describe "update" do
|
99
|
-
it "raises an exception if hash includes an invalid key" do
|
100
|
-
expect do
|
101
|
-
Braintree::Address._new(Braintree::Configuration.gateway, {}).update(:street_address => "456 E Main", :invalid_key2 => "foo")
|
102
|
-
end.to raise_error(ArgumentError, "invalid keys: invalid_key2")
|
103
|
-
end
|
104
|
-
end
|
105
97
|
end
|
@@ -15,7 +15,6 @@ describe Braintree::CreditCard do
|
|
15
15
|
:billing_address_id,
|
16
16
|
:cardholder_name,
|
17
17
|
:cvv,
|
18
|
-
:device_session_id,
|
19
18
|
:expiration_date,
|
20
19
|
:expiration_month,
|
21
20
|
:expiration_year,
|
@@ -23,7 +22,6 @@ describe Braintree::CreditCard do
|
|
23
22
|
:token,
|
24
23
|
:venmo_sdk_payment_method_code,
|
25
24
|
:device_data,
|
26
|
-
:fraud_merchant_id,
|
27
25
|
:payment_method_nonce,
|
28
26
|
{:external_vault=>[:network_transaction_id]},
|
29
27
|
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
@@ -37,6 +35,7 @@ describe Braintree::CreditCard do
|
|
37
35
|
:first_name,
|
38
36
|
:last_name,
|
39
37
|
:locality,
|
38
|
+
:phone_number,
|
40
39
|
:postal_code,
|
41
40
|
:region,
|
42
41
|
:street_address
|
@@ -62,7 +61,6 @@ describe Braintree::CreditCard do
|
|
62
61
|
:billing_address_id,
|
63
62
|
:cardholder_name,
|
64
63
|
:cvv,
|
65
|
-
:device_session_id,
|
66
64
|
:expiration_date,
|
67
65
|
:expiration_month,
|
68
66
|
:expiration_year,
|
@@ -70,7 +68,6 @@ describe Braintree::CreditCard do
|
|
70
68
|
:token,
|
71
69
|
:venmo_sdk_payment_method_code,
|
72
70
|
:device_data,
|
73
|
-
:fraud_merchant_id,
|
74
71
|
:payment_method_nonce,
|
75
72
|
{:external_vault=>[:network_transaction_id]},
|
76
73
|
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
@@ -84,6 +81,7 @@ describe Braintree::CreditCard do
|
|
84
81
|
:first_name,
|
85
82
|
:last_name,
|
86
83
|
:locality,
|
84
|
+
:phone_number,
|
87
85
|
:postal_code,
|
88
86
|
:region,
|
89
87
|
:street_address,
|
@@ -103,21 +101,6 @@ describe Braintree::CreditCard do
|
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
|
-
describe "self.create_from_transparent_redirect" do
|
107
|
-
it "raises an exception if the query string is forged" do
|
108
|
-
expect do
|
109
|
-
Braintree::CreditCard.create_from_transparent_redirect("http_status=200&forged=query_string")
|
110
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "self.create_credit_card_url" do
|
115
|
-
it "returns the url" do
|
116
|
-
config = Braintree::Configuration.instantiate
|
117
|
-
Braintree::CreditCard.create_credit_card_url.should == "http#{config.ssl? ? 's' : ''}://#{config.server}:#{config.port}/merchants/integration_merchant_id/payment_methods/all/create_via_transparent_redirect_request"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
104
|
describe "==" do
|
122
105
|
it "returns true if given a credit card with the same token" do
|
123
106
|
first = Braintree::CreditCard._new(:gateway, :token => 123)
|
@@ -196,7 +179,8 @@ describe Braintree::CreditCard do
|
|
196
179
|
:expiration_year => "2020",
|
197
180
|
:last_4 => "1111",
|
198
181
|
:token => "tok1",
|
199
|
-
:updated_at => Time.now
|
182
|
+
:updated_at => Time.now,
|
183
|
+
:is_network_tokenized => false,
|
200
184
|
)
|
201
185
|
output = credit_card.inspect
|
202
186
|
output.should include(%q(bin: "411111"))
|
@@ -210,6 +194,7 @@ describe Braintree::CreditCard do
|
|
210
194
|
output.should include(%q(token: "tok1"))
|
211
195
|
output.should include(%Q(updated_at: #{credit_card.updated_at.inspect}))
|
212
196
|
output.should include(%Q(created_at: #{credit_card.created_at.inspect}))
|
197
|
+
output.should include(%q(is_network_tokenized?: false))
|
213
198
|
end
|
214
199
|
end
|
215
200
|
|
@@ -224,10 +209,32 @@ describe Braintree::CreditCard do
|
|
224
209
|
end
|
225
210
|
end
|
226
211
|
|
212
|
+
describe "is_network_tokenized?" do
|
213
|
+
it "returns true" do
|
214
|
+
credit_card = Braintree::CreditCard._new(
|
215
|
+
:gateway,
|
216
|
+
:bin => "510510",
|
217
|
+
:last_4 => "5100",
|
218
|
+
:is_network_tokenized => true
|
219
|
+
)
|
220
|
+
credit_card.is_network_tokenized?.should == true
|
221
|
+
end
|
222
|
+
|
223
|
+
it "returns false" do
|
224
|
+
credit_card = Braintree::CreditCard._new(
|
225
|
+
:gateway,
|
226
|
+
:bin => "510510",
|
227
|
+
:last_4 => "5100",
|
228
|
+
:is_network_tokenized => false
|
229
|
+
)
|
230
|
+
credit_card.is_network_tokenized?.should == false
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
227
234
|
describe "self.update" do
|
228
235
|
it "raises an exception if attributes contain an invalid key" do
|
229
236
|
expect do
|
230
|
-
Braintree::CreditCard.
|
237
|
+
Braintree::CreditCard.update(:gateway, :invalid_key => 'val')
|
231
238
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
232
239
|
end
|
233
240
|
end
|
@@ -42,6 +42,13 @@ describe Braintree::CreditCardVerification do
|
|
42
42
|
Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
|
43
43
|
end
|
44
44
|
|
45
|
+
it "accepts network_transaction_id" do
|
46
|
+
verification = Braintree::CreditCardVerification._new(
|
47
|
+
:network_transaction_id => "123456789012345"
|
48
|
+
)
|
49
|
+
expect(verification.network_transaction_id).to eq "123456789012345"
|
50
|
+
end
|
51
|
+
|
45
52
|
describe "self.create" do
|
46
53
|
it "rejects invalid parameters" do
|
47
54
|
expect do
|
@@ -91,7 +91,6 @@ describe Braintree::Customer do
|
|
91
91
|
:billing_address_id,
|
92
92
|
:cardholder_name,
|
93
93
|
:cvv,
|
94
|
-
:device_session_id,
|
95
94
|
:expiration_date,
|
96
95
|
:expiration_month,
|
97
96
|
:expiration_year,
|
@@ -99,7 +98,6 @@ describe Braintree::Customer do
|
|
99
98
|
:token,
|
100
99
|
:venmo_sdk_payment_method_code,
|
101
100
|
:device_data,
|
102
|
-
:fraud_merchant_id,
|
103
101
|
:payment_method_nonce,
|
104
102
|
{:external_vault=>[:network_transaction_id]},
|
105
103
|
{:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
|
@@ -113,6 +111,7 @@ describe Braintree::Customer do
|
|
113
111
|
:first_name,
|
114
112
|
:last_name,
|
115
113
|
:locality,
|
114
|
+
:phone_number,
|
116
115
|
:postal_code,
|
117
116
|
:region,
|
118
117
|
:street_address
|
@@ -151,6 +150,7 @@ describe Braintree::Customer do
|
|
151
150
|
:first_name,
|
152
151
|
:last_name,
|
153
152
|
:locality,
|
153
|
+
:phone_number,
|
154
154
|
:postal_code,
|
155
155
|
:region,
|
156
156
|
:street_address,
|
@@ -180,7 +180,6 @@ describe Braintree::Customer do
|
|
180
180
|
:billing_address_id,
|
181
181
|
:cardholder_name,
|
182
182
|
:cvv,
|
183
|
-
:device_session_id,
|
184
183
|
:expiration_date,
|
185
184
|
:expiration_month,
|
186
185
|
:expiration_year,
|
@@ -188,7 +187,6 @@ describe Braintree::Customer do
|
|
188
187
|
:token,
|
189
188
|
:venmo_sdk_payment_method_code,
|
190
189
|
:device_data,
|
191
|
-
:fraud_merchant_id,
|
192
190
|
:payment_method_nonce,
|
193
191
|
{:external_vault=>[:network_transaction_id]},
|
194
192
|
{:options => [
|
@@ -211,6 +209,7 @@ describe Braintree::Customer do
|
|
211
209
|
:first_name,
|
212
210
|
:last_name,
|
213
211
|
:locality,
|
212
|
+
:phone_number,
|
214
213
|
:postal_code,
|
215
214
|
:region,
|
216
215
|
:street_address,
|
@@ -244,6 +243,7 @@ describe Braintree::Customer do
|
|
244
243
|
:first_name,
|
245
244
|
:last_name,
|
246
245
|
:locality,
|
246
|
+
:phone_number,
|
247
247
|
:postal_code,
|
248
248
|
:region,
|
249
249
|
:street_address,
|
@@ -255,14 +255,6 @@ describe Braintree::Customer do
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
-
describe "self.create_from_transparent_redirect" do
|
259
|
-
it "raises an exception if the query string is forged" do
|
260
|
-
expect do
|
261
|
-
Braintree::Customer.create_from_transparent_redirect("http_status=200&forged=query_string")
|
262
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
258
|
describe "==" do
|
267
259
|
it "returns true when given a customer with the same id" do
|
268
260
|
first = Braintree::Customer._new(:gateway, :id => 123)
|
@@ -42,6 +42,7 @@ describe Braintree::Dispute do
|
|
42
42
|
:amount => "31.00",
|
43
43
|
:id => "open_disputed_transaction",
|
44
44
|
:created_at => Time.utc(2009, 2, 9, 12, 59, 59),
|
45
|
+
:installment_count => nil,
|
45
46
|
:order_id => nil,
|
46
47
|
:purchase_order_number => "po",
|
47
48
|
:payment_instrument_subtype => "Visa",
|
@@ -197,13 +198,6 @@ describe Braintree::Dispute do
|
|
197
198
|
|
198
199
|
describe "with optional params" do
|
199
200
|
it "does not raise an exception if the optional parameters are valid" do
|
200
|
-
Braintree::Http.stub(:new).and_return double.as_null_object
|
201
|
-
expect do
|
202
|
-
Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", tag: "", sequence_number: 3 })
|
203
|
-
end.to_not raise_error
|
204
|
-
end
|
205
|
-
|
206
|
-
it "does not raise an exception if the category parameter is provided" do
|
207
201
|
Braintree::Http.stub(:new).and_return double.as_null_object
|
208
202
|
expect do
|
209
203
|
Braintree::Dispute.add_text_evidence("dispute_id", { content: "a", category: "", sequence_number: 3 })
|
@@ -319,12 +313,14 @@ describe Braintree::Dispute do
|
|
319
313
|
|
320
314
|
dispute.transaction.amount.should == 31.00
|
321
315
|
dispute.transaction.id.should == "open_disputed_transaction"
|
316
|
+
dispute.transaction.created_at.should == Time.utc(2009, 2, 9, 12, 59, 59)
|
317
|
+
dispute.transaction.installment_count.should == nil
|
322
318
|
dispute.transaction.order_id.should == nil
|
323
319
|
dispute.transaction.purchase_order_number.should == "po"
|
324
320
|
dispute.transaction.payment_instrument_subtype.should == "Visa"
|
325
321
|
end
|
326
322
|
|
327
|
-
it "converts status_history hash into an array of Dispute::
|
323
|
+
it "converts status_history hash into an array of Dispute::StatusHistory objects" do
|
328
324
|
dispute = Braintree::Dispute._new(attributes)
|
329
325
|
|
330
326
|
dispute.status_history.length.should == 1
|
@@ -395,10 +391,6 @@ describe Braintree::Dispute do
|
|
395
391
|
describe "comments" do
|
396
392
|
let(:dispute) { Braintree::Dispute._new(attributes) }
|
397
393
|
|
398
|
-
it "#forwarded_comments returns `processor_comments`" do
|
399
|
-
expect(dispute.forwarded_comments).to eq(dispute.processor_comments)
|
400
|
-
end
|
401
|
-
|
402
394
|
it "#processor_comments" do
|
403
395
|
expect(dispute.processor_comments).to eq(attributes[:processor_comments])
|
404
396
|
end
|
@@ -130,7 +130,7 @@ END
|
|
130
130
|
expect(default_headers["Accept-Encoding"]).to eq("gzip")
|
131
131
|
expect(default_headers["Content-Type"]).to eq("application/xml")
|
132
132
|
expect(default_headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
133
|
-
expect(default_headers["X-ApiVersion"]).to eq("
|
133
|
+
expect(default_headers["X-ApiVersion"]).to eq("6")
|
134
134
|
end
|
135
135
|
|
136
136
|
it "overwrites defaults with override headers" do
|
@@ -144,7 +144,7 @@ END
|
|
144
144
|
expect(headers["Authorization"]).to eq("token")
|
145
145
|
expect(headers["Content-Type"]).to eq("application/xml")
|
146
146
|
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
147
|
-
expect(headers["X-ApiVersion"]).to eq("
|
147
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
148
148
|
end
|
149
149
|
|
150
150
|
it "extends default headers when new headers are specified" do
|
@@ -156,7 +156,7 @@ END
|
|
156
156
|
expect(headers["Accept-Encoding"]).to eq("gzip")
|
157
157
|
expect(headers["Content-Type"]).to eq("application/xml")
|
158
158
|
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
159
|
-
expect(headers["X-ApiVersion"]).to eq("
|
159
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
160
160
|
expect(headers["New-Header"]).to eq("New Value")
|
161
161
|
end
|
162
162
|
end
|
@@ -32,5 +32,19 @@ describe Braintree::LocalPaymentCompleted do
|
|
32
32
|
local_payment_completed.transaction.order_id.should eq("an-order-id")
|
33
33
|
local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
|
34
34
|
end
|
35
|
+
|
36
|
+
it "initializes the object with the appropriate attributes set if no transaction is provided" do
|
37
|
+
params = {
|
38
|
+
payment_id: "a-payment-id",
|
39
|
+
payer_id: "a-payer-id",
|
40
|
+
payment_method_nonce: "a-nonce",
|
41
|
+
}
|
42
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
43
|
+
|
44
|
+
local_payment_completed.payment_id.should eq("a-payment-id")
|
45
|
+
local_payment_completed.payer_id.should eq("a-payer-id")
|
46
|
+
local_payment_completed.payment_method_nonce.should eq("a-nonce")
|
47
|
+
local_payment_completed.transaction.should be_nil
|
48
|
+
end
|
35
49
|
end
|
36
50
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::PayPalDetails do
|
4
|
+
describe "initialize" do
|
5
|
+
it "sets all fields" do
|
6
|
+
details = Braintree::Transaction::PayPalDetails.new(
|
7
|
+
:authorization_id => "id",
|
8
|
+
:billing_agreement_id => "billing-agreement-id",
|
9
|
+
:capture_id => "capture-id",
|
10
|
+
:custom_field => "custom-field",
|
11
|
+
:debug_id => "debug-id",
|
12
|
+
:description => "description",
|
13
|
+
:image_url => "www.image.com",
|
14
|
+
:implicitly_vaulted_payment_method_global_id => "global-id",
|
15
|
+
:implicitly_vaulted_payment_method_token => "payment-method-token",
|
16
|
+
:payee_email => "payee@example.com",
|
17
|
+
:payee_id => "payee-id",
|
18
|
+
:payer_email => "payer@example.com",
|
19
|
+
:payer_first_name => "Grace",
|
20
|
+
:payer_id => "payer-id",
|
21
|
+
:payer_last_name => "Hopper",
|
22
|
+
:payer_status =>"status",
|
23
|
+
:payment_id => "payment-id",
|
24
|
+
:refund_from_transaction_fee_amount => "1.00",
|
25
|
+
:refund_from_transaction_fee_currency_iso_code => "123",
|
26
|
+
:refund_id => "refund-id",
|
27
|
+
:seller_protection_status => "seller-protection-status",
|
28
|
+
:token => "token",
|
29
|
+
:transaction_fee_amount => "2.00",
|
30
|
+
:transaction_fee_currency_iso_code => "123"
|
31
|
+
)
|
32
|
+
|
33
|
+
expect(details.authorization_id).to eq("id")
|
34
|
+
expect(details.billing_agreement_id).to eq("billing-agreement-id")
|
35
|
+
expect(details.capture_id).to eq("capture-id")
|
36
|
+
expect(details.custom_field).to eq("custom-field")
|
37
|
+
expect(details.debug_id).to eq("debug-id")
|
38
|
+
expect(details.description).to eq("description")
|
39
|
+
expect(details.image_url).to eq("www.image.com")
|
40
|
+
expect(details.implicitly_vaulted_payment_method_global_id).to eq("global-id")
|
41
|
+
expect(details.implicitly_vaulted_payment_method_token).to eq("payment-method-token")
|
42
|
+
expect(details.payee_email).to eq("payee@example.com")
|
43
|
+
expect(details.payee_id).to eq("payee-id")
|
44
|
+
expect(details.payer_email).to eq("payer@example.com")
|
45
|
+
expect(details.payer_first_name).to eq("Grace")
|
46
|
+
expect(details.payer_id).to eq("payer-id")
|
47
|
+
expect(details.payer_last_name).to eq("Hopper")
|
48
|
+
expect(details.payer_status).to eq("status")
|
49
|
+
expect(details.payment_id).to eq("payment-id")
|
50
|
+
expect(details.refund_from_transaction_fee_amount).to eq("1.00")
|
51
|
+
expect(details.refund_from_transaction_fee_currency_iso_code).to eq("123")
|
52
|
+
expect(details.refund_id).to eq("refund-id")
|
53
|
+
expect(details.seller_protection_status).to eq("seller-protection-status")
|
54
|
+
expect(details.token).to eq("token")
|
55
|
+
expect(details.transaction_fee_amount).to eq("2.00")
|
56
|
+
expect(details.transaction_fee_currency_iso_code).to eq("123")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -17,14 +17,6 @@ describe Braintree::Transaction do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe "self.create_from_transparent_redirect" do
|
21
|
-
it "raises an exception if the query string is forged" do
|
22
|
-
expect do
|
23
|
-
Braintree::Transaction.create_from_transparent_redirect("http_status=200&forged=query_string")
|
24
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
20
|
describe "self.find" do
|
29
21
|
it "raises error if passed empty string" do
|
30
22
|
expect do
|
@@ -45,13 +37,6 @@ describe Braintree::Transaction do
|
|
45
37
|
end
|
46
38
|
end
|
47
39
|
|
48
|
-
describe "self.create_transaction_url" do
|
49
|
-
it "returns the url" do
|
50
|
-
config = Braintree::Configuration.instantiate
|
51
|
-
Braintree::Transaction.create_transaction_url.should == "http#{config.ssl? ? 's' : ''}://#{config.server}:#{config.port}/merchants/integration_merchant_id/transactions/all/create_via_transparent_redirect_request"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
40
|
describe "self.submit_for_settlement" do
|
56
41
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
57
42
|
expect do
|
@@ -106,7 +91,7 @@ describe Braintree::Transaction do
|
|
106
91
|
}
|
107
92
|
)
|
108
93
|
disbursement = transaction.disbursement_details
|
109
|
-
disbursement.disbursement_date.should == "2013-04-03"
|
94
|
+
disbursement.disbursement_date.should == Date.parse("2013-04-03")
|
110
95
|
disbursement.settlement_amount.should == "120.00"
|
111
96
|
disbursement.settlement_currency_iso_code.should == "USD"
|
112
97
|
disbursement.settlement_currency_exchange_rate.should == "1"
|
@@ -171,25 +156,6 @@ describe Braintree::Transaction do
|
|
171
156
|
transaction.three_d_secure_info.liability_shift_possible.should == true
|
172
157
|
end
|
173
158
|
|
174
|
-
it "sets up ideal_payment_details" do
|
175
|
-
transaction = Braintree::Transaction._new(
|
176
|
-
:gateway,
|
177
|
-
:ideal_payment => {
|
178
|
-
:ideal_payment_id => "idealpayment_abc_123",
|
179
|
-
:ideal_transaction_id => "1150000008857321",
|
180
|
-
:masked_iban => "12************7890",
|
181
|
-
:bic => "RABONL2U",
|
182
|
-
:image_url => "http://www.example.com/ideal.png"
|
183
|
-
}
|
184
|
-
)
|
185
|
-
|
186
|
-
transaction.ideal_payment_details.ideal_payment_id.should == "idealpayment_abc_123"
|
187
|
-
transaction.ideal_payment_details.ideal_transaction_id.should == "1150000008857321"
|
188
|
-
transaction.ideal_payment_details.masked_iban.should == "12************7890"
|
189
|
-
transaction.ideal_payment_details.bic.should == "RABONL2U"
|
190
|
-
transaction.ideal_payment_details.image_url.should == "http://www.example.com/ideal.png"
|
191
|
-
end
|
192
|
-
|
193
159
|
it "sets up history attributes in status_history" do
|
194
160
|
time = Time.utc(2010,1,14)
|
195
161
|
transaction = Braintree::Transaction._new(
|
@@ -276,16 +242,18 @@ describe Braintree::Transaction do
|
|
276
242
|
end
|
277
243
|
|
278
244
|
describe "inspect" do
|
279
|
-
it "includes the id, type, amount, and
|
245
|
+
it "includes the id, type, amount, status, and processed_with_network_token?" do
|
280
246
|
transaction = Braintree::Transaction._new(
|
281
247
|
:gateway,
|
282
248
|
:id => "1234",
|
283
249
|
:type => "sale",
|
284
250
|
:amount => "100.00",
|
285
|
-
:status => Braintree::Transaction::Status::Authorized
|
251
|
+
:status => Braintree::Transaction::Status::Authorized,
|
252
|
+
:processed_with_network_token => false,
|
286
253
|
)
|
287
254
|
output = transaction.inspect
|
288
255
|
output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
|
256
|
+
output.should include(%Q(processed_with_network_token?: false))
|
289
257
|
end
|
290
258
|
end
|
291
259
|
|
@@ -394,4 +362,16 @@ describe Braintree::Transaction do
|
|
394
362
|
)
|
395
363
|
end
|
396
364
|
end
|
365
|
+
|
366
|
+
describe "processed_with_network_token?" do
|
367
|
+
it "is true if the transaction was processed with a network token" do
|
368
|
+
transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => true)
|
369
|
+
transaction.processed_with_network_token?.should == true
|
370
|
+
end
|
371
|
+
|
372
|
+
it "is false if the transaction was not processed with a network token" do
|
373
|
+
transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => false)
|
374
|
+
transaction.processed_with_network_token?.should == false
|
375
|
+
end
|
376
|
+
end
|
397
377
|
end
|