Permalink
Browse files

2.17.0

  • Loading branch information...
1 parent a5f18a5 commit 5c2e57274e5daed4b8d7d29c3d54fc84bfd134ff @braintreeps braintreeps committed Sep 13, 2012
View
3 CHANGELOG.rdoc
@@ -1,3 +1,6 @@
+== 2.17.0
+* Adds prepaid attribute to credit cards (possible values: Yes, No, Unknown)
+
== 2.16.0
* Adds webhook gateways for parsing, verifying, and testing incoming
View
2 lib/braintree/address_gateway.rb
@@ -31,7 +31,7 @@ def delete(customer_or_customer_id, address_id)
def find(customer_or_customer_id, address_id)
customer_id = _determine_customer_id(customer_or_customer_id)
- raise ArgumentError if address_id.nil? || address_id.strip.to_s == ""
+ raise ArgumentError if address_id.nil? || address_id.to_s.strip == ""
response = @config.http.get("/customers/#{customer_id}/addresses/#{address_id}")
Address._new(@gateway, response[:address])
rescue NotFoundError
View
10 lib/braintree/credit_card.rb
@@ -26,8 +26,14 @@ module CustomerLocation
US = "us"
end
+ module Prepaid
+ Yes = "Yes"
+ No = "No"
+ Unknown = "Unknown"
+ end
+
attr_reader :billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
- :expiration_year, :last_4, :unique_number_identifier, :subscriptions, :token, :updated_at
+ :expiration_year, :last_4, :prepaid, :unique_number_identifier, :subscriptions, :token, :updated_at
# See http://www.braintreepayments.com/docs/ruby/credit_cards/create
def self.create(attributes)
@@ -227,7 +233,7 @@ class << self
def self._attributes # :nodoc:
[
:billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
- :expiration_year, :last_4, :token, :updated_at
+ :expiration_year, :last_4, :token, :updated_at, :prepaid
]
end
View
2 lib/braintree/credit_card_gateway.rb
@@ -41,7 +41,7 @@ def expiring_between(start_date, end_date, options = {})
end
def find(token)
- raise ArgumentError if token.nil? || token.strip.to_s == ""
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
response = @config.http.get "/payment_methods/#{token}"
CreditCard._new(@gateway, response[:credit_card])
rescue NotFoundError
View
2 lib/braintree/customer_gateway.rb
@@ -33,7 +33,7 @@ def delete(customer_id)
def find(customer_id)
raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
- raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.strip.to_s == ""
+ raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.to_s.strip == ""
response = @config.http.get("/customers/#{customer_id}")
Customer._new(@gateway, response[:customer])
rescue NotFoundError
View
2 lib/braintree/subscription_gateway.rb
@@ -24,7 +24,7 @@ def create(attributes)
end
def find(id)
- raise ArgumentError if id.nil? || id.strip.to_s == ""
+ raise ArgumentError if id.nil? || id.to_s.strip == ""
response = @config.http.get "/subscriptions/#{id}"
Subscription._new(@gateway, response[:subscription])
rescue NotFoundError
View
3 lib/braintree/test/credit_card_numbers.rb
@@ -21,8 +21,9 @@ module CreditCardNumbers
Visa = "4012888888881881"
VisaInternational = "4009348888881881" # :nodoc:
+ VisaPrepaid = "4500600000000061"
- Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115]
+ Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115 4500600000000061]
Unknowns = %w[1000000000000008]
module FailsSandboxVerification
View
2 lib/braintree/version.rb
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 2
- Minor = 16
+ Minor = 17
Tiny = 0
String = "#{Major}.#{Minor}.#{Tiny}"
View
37 spec/integration/braintree/credit_card_spec.rb
@@ -243,6 +243,43 @@
Braintree::CreditCard.find(card1.token).should_not be_default
end
+
+ it "sets the prepaid field if the card is prepaid" do
+ customer = Braintree::Customer.create!
+ result = Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::VisaPrepaid,
+ :expiration_date => "05/2014",
+ :options => {:verify_card => true}
+ )
+ credit_card = result.credit_card
+ credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Yes
+ end
+
+ it "sets negative card type identifiers" do
+ customer = Braintree::Customer.create!
+ result = Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "05/2014",
+ :options => {:verify_card => true}
+ )
+ credit_card = result.credit_card
+ credit_card.prepaid.should == Braintree::CreditCard::Prepaid::No
+ end
+
+ it "doesn't set the card type identifiers for an un-identified card" do
+ customer = Braintree::Customer.create!
+ result = Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
+ :expiration_date => "05/2014",
+ :options => {:verify_card => true}
+ )
+ credit_card = result.credit_card
+ credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Unknown
+ end
+
end
describe "self.create!" do
View
2 spec/integration/braintree/customer_spec.rb
@@ -140,7 +140,7 @@
:first_name => "Mike",
:last_name => "Jones",
:credit_card => {
- :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2015",
:options => {:fail_on_duplicate_payment_method => true}
}
View
7 spec/unit/braintree/address_spec.rb
@@ -78,6 +78,13 @@
Braintree::Address.find("customer_id", nil)
end.to raise_error(ArgumentError)
end
+
+ it "does not raise an error if address_id does not respond to strip" do
+ Braintree::Http.stub(:new).and_return stub.as_null_object
+ expect do
+ Braintree::Address.find("customer_id", 8675309)
+ end.to_not raise_error(NoMethodError)
+ end
end
describe "self.new" do
View
7 spec/unit/braintree/credit_card_spec.rb
@@ -137,6 +137,13 @@
Braintree::CreditCard.find(nil)
end.to raise_error(ArgumentError)
end
+
+ it "does not raise an error if address_id does not respond to strip" do
+ Braintree::Http.stub(:new).and_return stub.as_null_object
+ expect do
+ Braintree::CreditCard.find(8675309)
+ end.to_not raise_error(NoMethodError)
+ end
end
describe "inspect" do
View
7 spec/unit/braintree/customer_spec.rb
@@ -53,6 +53,13 @@
Braintree::Customer.find(nil)
end.to raise_error(ArgumentError)
end
+
+ it "does not raise an exception if the id is a fixnum" do
+ Braintree::Http.stub(:new).and_return stub.as_null_object
+ expect do
+ Braintree::Customer.find(8675309)
+ end.to_not raise_error(NoMethodError)
+ end
end
describe "self.update" do
View
7 spec/unit/braintree/subscription_spec.rb
@@ -40,6 +40,13 @@ def default_params
Braintree::Subscription.find(nil)
end.to raise_error(ArgumentError)
end
+
+ it "does not raise an error if subscription id does not respond to strip" do
+ Braintree::Http.stub(:new).and_return stub(:get => {:subscription => default_params})
+ expect do
+ Braintree::Subscription.find(8675309)
+ end.to_not raise_error(NoMethodError)
+ end
end
describe "self.search" do

0 comments on commit 5c2e572

Please sign in to comment.