braintree 2.12.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/braintree.gemspec +17 -0
- data/lib/braintree.rb +55 -55
- data/lib/braintree/address_gateway.rb +1 -0
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/customer_gateway.rb +1 -1
- data/lib/braintree/error_codes.rb +2 -1
- data/lib/braintree/subscription_gateway.rb +1 -0
- data/lib/braintree/transaction.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +1 -0
- data/lib/braintree/transaction_search.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/transaction_search_spec.rb +11 -0
- data/spec/integration/spec_helper.rb +3 -1
- data/spec/script/httpsd.rb +1 -1
- data/spec/unit/braintree/address_spec.rb +12 -0
- data/spec/unit/braintree/configuration_spec.rb +5 -0
- data/spec/unit/braintree/credit_card_spec.rb +20 -0
- data/spec/unit/braintree/customer_spec.rb +14 -0
- data/spec/unit/braintree/subscription_spec.rb +20 -0
- data/spec/unit/braintree/transaction_spec.rb +20 -0
- metadata +7 -6
data/braintree.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'braintree/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "braintree"
|
6
|
+
s.summary = "Braintree Gateway Ruby Client Library"
|
7
|
+
s.description = "Ruby library for integrating with the Braintree Gateway"
|
8
|
+
s.version = Braintree::Version::String
|
9
|
+
s.author = "Braintree"
|
10
|
+
s.email = "code@getbraintree.com"
|
11
|
+
s.homepage = "http://www.braintreepayments.com/"
|
12
|
+
s.rubyforge_project = "braintree"
|
13
|
+
s.has_rdoc = false
|
14
|
+
s.files = Dir.glob ["README.rdoc", "LICENSE", "{lib,spec}/**/*.rb", "lib/**/*.crt", "*.gemspec"]
|
15
|
+
s.add_dependency "builder", ">= 2.0.0"
|
16
|
+
end
|
17
|
+
|
data/lib/braintree.rb
CHANGED
@@ -14,60 +14,60 @@ require "zlib"
|
|
14
14
|
|
15
15
|
require "builder"
|
16
16
|
|
17
|
-
require
|
17
|
+
require "braintree/exceptions"
|
18
18
|
|
19
|
-
require
|
20
|
-
require
|
19
|
+
require "braintree/base_module"
|
20
|
+
require "braintree/modification"
|
21
21
|
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
require
|
49
|
-
require
|
50
|
-
require
|
51
|
-
require
|
52
|
-
require
|
53
|
-
require
|
54
|
-
require
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
65
|
-
require
|
66
|
-
require
|
67
|
-
require
|
68
|
-
require
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
require
|
73
|
-
require
|
22
|
+
require "braintree/add_on"
|
23
|
+
require "braintree/add_on_gateway"
|
24
|
+
require "braintree/address/country_names"
|
25
|
+
require "braintree/address"
|
26
|
+
require "braintree/address_gateway"
|
27
|
+
require "braintree/advanced_search"
|
28
|
+
require "braintree/configuration"
|
29
|
+
require "braintree/credit_card"
|
30
|
+
require "braintree/credit_card_gateway"
|
31
|
+
require "braintree/credit_card_verification"
|
32
|
+
require "braintree/customer"
|
33
|
+
require "braintree/customer_gateway"
|
34
|
+
require "braintree/customer_search"
|
35
|
+
require "braintree/descriptor"
|
36
|
+
require "braintree/digest"
|
37
|
+
require "braintree/discount"
|
38
|
+
require "braintree/discount_gateway"
|
39
|
+
require "braintree/error_codes"
|
40
|
+
require "braintree/error_result"
|
41
|
+
require "braintree/errors"
|
42
|
+
require "braintree/gateway"
|
43
|
+
require "braintree/http"
|
44
|
+
require "braintree/plan"
|
45
|
+
require "braintree/plan_gateway"
|
46
|
+
require "braintree/settlement_batch_summary"
|
47
|
+
require "braintree/settlement_batch_summary_gateway"
|
48
|
+
require "braintree/resource_collection"
|
49
|
+
require "braintree/subscription"
|
50
|
+
require "braintree/subscription_gateway"
|
51
|
+
require "braintree/subscription_search"
|
52
|
+
require "braintree/successful_result"
|
53
|
+
require "braintree/test/credit_card_numbers"
|
54
|
+
require "braintree/test/transaction_amounts"
|
55
|
+
require "braintree/transaction"
|
56
|
+
require "braintree/transaction/address_details"
|
57
|
+
require "braintree/transaction/credit_card_details"
|
58
|
+
require "braintree/transaction/customer_details"
|
59
|
+
require "braintree/transaction/subscription_details"
|
60
|
+
require "braintree/transaction_gateway"
|
61
|
+
require "braintree/transaction_search"
|
62
|
+
require "braintree/transaction/status_details"
|
63
|
+
require "braintree/transparent_redirect"
|
64
|
+
require "braintree/transparent_redirect_gateway"
|
65
|
+
require "braintree/util"
|
66
|
+
require "braintree/validation_error"
|
67
|
+
require "braintree/validation_error_collection"
|
68
|
+
require "braintree/version"
|
69
|
+
require "braintree/xml"
|
70
|
+
require "braintree/xml/generator"
|
71
|
+
require "braintree/xml/libxml"
|
72
|
+
require "braintree/xml/rexml"
|
73
|
+
require "braintree/xml/parser"
|
@@ -31,6 +31,7 @@ module Braintree
|
|
31
31
|
|
32
32
|
def find(customer_or_customer_id, address_id)
|
33
33
|
customer_id = _determine_customer_id(customer_or_customer_id)
|
34
|
+
raise ArgumentError if address_id.nil? || address_id.strip.to_s == ""
|
34
35
|
response = @config.http.get("/customers/#{customer_id}/addresses/#{address_id}")
|
35
36
|
Address._new(@gateway, response[:address])
|
36
37
|
rescue NotFoundError
|
@@ -33,7 +33,7 @@ module Braintree
|
|
33
33
|
|
34
34
|
def find(customer_id)
|
35
35
|
raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
|
36
|
-
raise ArgumentError, "customer_id cannot be blank" if customer_id.to_s == ""
|
36
|
+
raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.strip.to_s == ""
|
37
37
|
response = @config.http.get("/customers/#{customer_id}")
|
38
38
|
Customer._new(@gateway, response[:customer])
|
39
39
|
rescue NotFoundError
|
@@ -174,7 +174,8 @@ module Braintree
|
|
174
174
|
CustomerIdIsInvalid = "91510"
|
175
175
|
HasAlreadyBeenRefunded = "91512"
|
176
176
|
MerchantAccountIdIsInvalid = "91513"
|
177
|
-
MerchantAccountIsSuspended = "
|
177
|
+
MerchantAccountIsSuspended = "91515"
|
178
|
+
MerchantAccountDoesNotSupportRefunds = "91547"
|
178
179
|
MerchantAccountNameIsInvalid = "91513" # Deprecated
|
179
180
|
OrderIdIsTooLong = "91501"
|
180
181
|
PaymentMethodConflict = "91515"
|
@@ -39,6 +39,8 @@ module Braintree
|
|
39
39
|
module Type # :nodoc:
|
40
40
|
Credit = "credit" # :nodoc:
|
41
41
|
Sale = "sale" # :nodoc:
|
42
|
+
|
43
|
+
All = constants.map { |c| const_get(c) }
|
42
44
|
end
|
43
45
|
|
44
46
|
attr_reader :avs_error_response_code, :avs_postal_code_response_code, :avs_street_address_response_code
|
data/lib/braintree/version.rb
CHANGED
@@ -88,7 +88,7 @@ describe Braintree::Http do
|
|
88
88
|
it "rejects when the certificate isn't verified by our certificate authority (self-signed)" do
|
89
89
|
config = Braintree::Configuration.instantiate
|
90
90
|
config.stub(:ssl?).and_return(true)
|
91
|
-
config.stub(:port).and_return(
|
91
|
+
config.stub(:port).and_return(SSL_TEST_PORT)
|
92
92
|
|
93
93
|
start_ssl_server do
|
94
94
|
expect do
|
@@ -104,7 +104,7 @@ describe Braintree::Http do
|
|
104
104
|
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "ssl", "geotrust_global.crt"))
|
105
105
|
)
|
106
106
|
config.stub(:ssl?).and_return(true)
|
107
|
-
config.stub(:port).and_return(
|
107
|
+
config.stub(:port).and_return(SSL_TEST_PORT)
|
108
108
|
|
109
109
|
start_ssl_server do
|
110
110
|
expect do
|
@@ -381,6 +381,17 @@ describe Braintree::Transaction, "search" do
|
|
381
381
|
end
|
382
382
|
end
|
383
383
|
|
384
|
+
context "invalid search" do
|
385
|
+
it "raises an exception on invalid transaction type" do
|
386
|
+
expect do
|
387
|
+
collection = Braintree::Transaction.search do |search|
|
388
|
+
search.customer_id.is "9171566"
|
389
|
+
search.type.is "settled"
|
390
|
+
end
|
391
|
+
end.to raise_error(ArgumentError)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
384
395
|
context "range fields" do
|
385
396
|
context "amount" do
|
386
397
|
it "searches on amount" do
|
@@ -1,5 +1,6 @@
|
|
1
1
|
unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
2
2
|
INTEGRATION_SPEC_HELPER_LOADED = true
|
3
|
+
SSL_TEST_PORT = ENV['SSL_TEST_PORT'] || 8443
|
3
4
|
|
4
5
|
require File.dirname(__FILE__) + "/../spec_helper"
|
5
6
|
require File.dirname(__FILE__) + "/../hacks/tcp_socket"
|
@@ -10,11 +11,12 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
10
11
|
FileUtils.rm(web_server_pid_file) if File.exist?(web_server_pid_file)
|
11
12
|
command = File.expand_path(File.join(File.dirname(__FILE__), "..", "script", "httpsd.rb"))
|
12
13
|
`#{command} #{web_server_pid_file}`
|
13
|
-
TCPSocket.wait_for_service :host => "127.0.0.1", :port =>
|
14
|
+
TCPSocket.wait_for_service :host => "127.0.0.1", :port => SSL_TEST_PORT
|
14
15
|
|
15
16
|
yield
|
16
17
|
|
17
18
|
10.times { unless File.exists?(web_server_pid_file); sleep 1; end }
|
19
|
+
ensure
|
18
20
|
Process.kill "INT", File.read(web_server_pid_file).to_i
|
19
21
|
end
|
20
22
|
|
data/spec/script/httpsd.rb
CHANGED
@@ -12,7 +12,7 @@ cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
|
|
12
12
|
pid_file = ARGV[0]
|
13
13
|
|
14
14
|
s = WEBrick::HTTPServer.new(
|
15
|
-
:Port => 8443,
|
15
|
+
:Port => (ENV['SSL_TEST_PORT'] || 8443),
|
16
16
|
:Logger => WEBrick::Log::new(nil, WEBrick::Log::ERROR),
|
17
17
|
:DocumentRoot => File.join(File.dirname(__FILE__)),
|
18
18
|
:ServerType => WEBrick::Daemon,
|
@@ -66,6 +66,18 @@ describe Braintree::Address do
|
|
66
66
|
Braintree::Address.find("spaces not allowed", "address_id")
|
67
67
|
end.to raise_error(ArgumentError, "customer_id contains invalid characters")
|
68
68
|
end
|
69
|
+
|
70
|
+
it "raises an error if address_id is blank" do
|
71
|
+
expect do
|
72
|
+
Braintree::Address.find("customer_id", "")
|
73
|
+
end.to raise_error(ArgumentError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "raises an error if address_id is blank" do
|
77
|
+
expect do
|
78
|
+
Braintree::Address.find("customer_id", nil)
|
79
|
+
end.to raise_error(ArgumentError)
|
80
|
+
end
|
69
81
|
end
|
70
82
|
|
71
83
|
describe "self.new" do
|
@@ -195,6 +195,11 @@ describe Braintree::Configuration do
|
|
195
195
|
Braintree::Configuration.environment = :sandbox
|
196
196
|
Braintree::Configuration.instantiate.server.should == "sandbox.braintreegateway.com"
|
197
197
|
end
|
198
|
+
|
199
|
+
it "is qa.braintreegateway.com for qa" do
|
200
|
+
Braintree::Configuration.environment = :qa
|
201
|
+
Braintree::Configuration.instantiate.server.should == "qa.braintreegateway.com"
|
202
|
+
end
|
198
203
|
end
|
199
204
|
|
200
205
|
describe "ssl?" do
|
@@ -119,6 +119,26 @@ describe Braintree::CreditCard do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
describe "self.find" do
|
123
|
+
it "raises error if passed empty string" do
|
124
|
+
expect do
|
125
|
+
Braintree::CreditCard.find("")
|
126
|
+
end.to raise_error(ArgumentError)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "raises error if passed invalid string" do
|
130
|
+
expect do
|
131
|
+
Braintree::CreditCard.find("\t")
|
132
|
+
end.to raise_error(ArgumentError)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "raises error if passed nil" do
|
136
|
+
expect do
|
137
|
+
Braintree::CreditCard.find(nil)
|
138
|
+
end.to raise_error(ArgumentError)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
122
142
|
describe "inspect" do
|
123
143
|
it "includes the token first" do
|
124
144
|
output = Braintree::CreditCard._new(:gateway, :token => "cc123").inspect
|
@@ -41,6 +41,20 @@ describe Braintree::Customer do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
describe "self.find" do
|
45
|
+
it "raises an exception if the id is blank" do
|
46
|
+
expect do
|
47
|
+
Braintree::Customer.find(" ")
|
48
|
+
end.to raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises an exception if the id is nil" do
|
52
|
+
expect do
|
53
|
+
Braintree::Customer.find(nil)
|
54
|
+
end.to raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
44
58
|
describe "self.update" do
|
45
59
|
it "raises an exception if hash includes an invalid key" do
|
46
60
|
expect do
|
@@ -22,6 +22,26 @@ describe Braintree::Subscription do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe "self.find" do
|
26
|
+
it "raises error if passed empty string" do
|
27
|
+
expect do
|
28
|
+
Braintree::Subscription.find("")
|
29
|
+
end.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "raises error if passed empty string wth space" do
|
33
|
+
expect do
|
34
|
+
Braintree::Subscription.find(" ")
|
35
|
+
end.to raise_error(ArgumentError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises error if passed nil" do
|
39
|
+
expect do
|
40
|
+
Braintree::Subscription.find(nil)
|
41
|
+
end.to raise_error(ArgumentError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
25
45
|
describe "self.search" do
|
26
46
|
it "only allows specified values for status" do
|
27
47
|
lambda do
|
@@ -25,6 +25,26 @@ describe Braintree::Transaction do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "self.find" do
|
29
|
+
it "raises error if passed empty string" do
|
30
|
+
expect do
|
31
|
+
Braintree::Transaction.find("")
|
32
|
+
end.to raise_error(ArgumentError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "raises error if passed empty string wth space" do
|
36
|
+
expect do
|
37
|
+
Braintree::Transaction.find(" ")
|
38
|
+
end.to raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises error if passed nil" do
|
42
|
+
expect do
|
43
|
+
Braintree::Transaction.find(nil)
|
44
|
+
end.to raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
28
48
|
describe "self.create_transaction_url" do
|
29
49
|
it "returns the url" do
|
30
50
|
port = Braintree::Configuration.instantiate.port
|
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: 59
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 13
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.13.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-11-03 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/ssl/sandbox_braintreegateway_com.ca.crt
|
155
155
|
- lib/ssl/securetrust_ca.crt
|
156
156
|
- lib/ssl/www_braintreegateway_com.ca.crt
|
157
|
+
- braintree.gemspec
|
157
158
|
has_rdoc: true
|
158
159
|
homepage: http://www.braintreepayments.com/
|
159
160
|
licenses: []
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
requirements: []
|
185
186
|
|
186
187
|
rubyforge_project: braintree
|
187
|
-
rubygems_version: 1.
|
188
|
+
rubygems_version: 1.3.7
|
188
189
|
signing_key:
|
189
190
|
specification_version: 3
|
190
191
|
summary: Braintree Gateway Ruby Client Library
|