Browse files

Add new alias credit_card.brand for credit_card.type and handle the b…

…rand correctly in Netaxept
  • Loading branch information...
1 parent 9b96bcc commit 3a2a7a0173cd42d95694d3cd3385118665647666 @Soleone Soleone committed Sep 28, 2010
View
1 CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
* DirecPay: Add support for additional options in Return class [Soleone]
+* Add new alias credit_card.brand for credit_card.type and handle the brand correctly in Netaxept [Soleone]
* Iridium: Do not depend on ExpiryDate class for credit_card [Soleone]
* PayFlow: Use same timeout of 60 seconds in HTTP header and XML for all requests [Soleone]
* PayPal Website Payments Pro CA no longer supports American Express cards [Soleone]
View
2 lib/active_merchant/billing/credit_card.rb
@@ -53,6 +53,8 @@ class CreditCard
# run validation on the passed in value if it is supplied
attr_accessor :verification_value
+ alias_method :brand, :type
+
# Provides proxy access to an expiry date object
def expiry_date
ExpiryDate.new(@month, @year)
View
5 lib/active_merchant/billing/gateways/netaxept.rb
@@ -106,9 +106,10 @@ def add_order(post, money, options)
'american_express' => 'a',
}
def add_creditcard(post, creditcard)
- prefix = CARD_TYPE_PREFIXES[creditcard.type]
+ brand = Gateway.card_brand(creditcard)
+ prefix = CARD_TYPE_PREFIXES[brand]
unless prefix
- raise ArgumentError.new("Card type #{creditcard.type} not supported.")
+ raise ArgumentError.new("Card type #{brand} not supported.")
end
post[:creditcard] = {}
View
5 test/unit/credit_card_test.rb
@@ -315,4 +315,9 @@ def test_before_validate_handles_blank_number
assert !card.valid?
assert_equal "", card.number
end
+
+ def test_type_is_aliased_as_brand
+ assert_equal @visa.type, @visa.brand
+ assert_equal @solo.type, @solo.brand
+ end
end
View
7 test/unit/gateways/netaxept_test.rb
@@ -152,6 +152,13 @@ def test_handles_transaction_error
assert_nil response.error_detail
end
+ def test_uses_credit_card_brand_instead_of_credit_card_type
+ brand = @credit_card.type
+ @credit_card.expects(:type).never
+ @credit_card.expects(:brand).at_least_once.returns(brand)
+ @gateway.purchase(@amount, @credit_card, @options)
+ end
+
private
# Place raw successful response from gateway here

0 comments on commit 3a2a7a0

Please sign in to comment.