Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Add new alias credit_card.brand for credit_card.type and handle the b…
Browse files Browse the repository at this point in the history
…rand correctly in Netaxept
  • Loading branch information
Soleone committed Nov 22, 2010
1 parent 9b96bcc commit 3a2a7a0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/active_merchant/billing/gateways/netaxept.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/credit_card_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions test/unit/gateways/netaxept_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a2a7a0

Please sign in to comment.