Skip to content

Commit

Permalink
Remove Response#card_data
Browse files Browse the repository at this point in the history
git-svn-id: https://activemerchant.googlecode.com/svn/trunk/active_merchant@553 6513ea26-6c20-0410-8a68-89cd7235086d
  • Loading branch information
codyfauser committed Jan 12, 2008
1 parent 92c2981 commit d2da5d4
Show file tree
Hide file tree
Showing 25 changed files with 15 additions and 143 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Remove Response#card_data. The application has access to the information anyway [cody]
* Return the last 4 digits of the card number from the Response instead of the masked number [cody]
* Actually use the shipping address in TrustCommerce [cody]
* Update TrustCommerceGateway to support avs and cvv results. Remove test_result_from_cc_number. Automatically fallback to SSL POST if the TCLink library is not available. Add additional customer information to the requests. [cody]
Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/authorize_net.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def commit(action, money, parameters)
:authorization => @response[:transaction_id],
:fraud_review => fraud_review?(@response),
:avs_result => { :code => @response[:avs_result_code] },
:cvv_result => @response[:card_code],
:card_number => parameters[:card_num]
:cvv_result => @response[:card_code]
)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/brain_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ def commit(action, money, parameters)
:authorization => @response["transactionid"],
:test => test?,
:cvv_result => @response["cvvresponse"],
:avs_result => { :code => @response["avsresponse"] },
:card_number => parameters[:ccnumber]
:avs_result => { :code => @response["avsresponse"] }
)

end
Expand Down
1 change: 0 additions & 1 deletion lib/active_merchant/billing/gateways/card_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def commit(action, parameters)
Response.new(success, message, @response,
:test => test?,
:authorization => @response[:cross_reference],
:card_number => parameters[:CardNumber],
:cvv_result => CVV_CODE[ @response[:avscv2_response_code].to_s[0, 1] ],
:avs_result => {
:street_match => AVS_STREET_MATCH[ @response[:avscv2_response_code].to_s[2, 1] ],
Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/linkpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ def commit(money, creditcard, options = {})
:test => test?,
:authorization => @response[:ordernum],
:avs_result => { :code => @response[:avs].to_s[2,1] },
:cvv_result => @response[:avs].to_s[3,1],
:card_number => creditcard && parameters[:creditcard][:cardnumber]
:cvv_result => @response[:avs].to_s[3,1]
)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/moneris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def commit(action, parameters = {})

Response.new(successful_response?(response), message_from(response[:message]), @response,
:test => test?,
:authorization => authorization_string(response),
:card_number => parameters[:pan]
:authorization => authorization_string(response)
)
end

Expand Down
5 changes: 2 additions & 3 deletions lib/active_merchant/billing/gateways/pay_junction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ def commit(action, parameters)
@response = parse(data)

Response.new(successful?(@response), message_from(@response), @response,
:test => test?,
:authorization => @response[:transaction_id] || parameters[:transaction_id],
:card_number => parameters[:number]
:test => test?,
:authorization => @response[:transaction_id] || parameters[:transaction_id]
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,9 @@ def commit(request_body, request_type = nil)
:test => test?,
:authorization => @response[:pn_ref] || @response[:rp_ref],
:cvv_result => CVV_CODE[@response[:cv_result]],
:avs_result => { :code => @response[:avs_result] },
:card_number => parse_credit_card_number(request)
:avs_result => { :code => @response[:avs_result] }
)
end

def parse_credit_card_number(request)
xml = REXML::Document.new(request)
card_number = REXML::XPath.first(xml, '//Tender/Card/CardNum')
card_number && card_number.text
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,9 @@ def commit(action, request)
:test => test?,
:authorization => @response[:transaction_id] || @response[:authorization_id], # latter one is from reauthorization
:avs_result => { :code => @response[:avs_code] },
:cvv_result => @response[:cvv2_code],
:card_number => parse_credit_card_number(request)
:cvv_result => @response[:cvv2_code]
)
end

def parse_credit_card_number(request)
xml = REXML::Document.new(request)
card_number = REXML::XPath.first(xml, '//n2:CreditCard/n2:CreditCardNumber')
card_number && card_number.text
end
end
end
end
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/psigate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def commit(money, creditcard, options = {})
:test => test?,
:authorization => @response[:orderid],
:avs_result => { :code => @response[:avsresult] },
:cvv_result => @response[:cardidresult],
:card_number => parameters[:CardNumber]
:cvv_result => @response[:cardidresult]
)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/quickpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ def commit(action, params)

Response.new(success, message, @response,
:test => test?,
:authorization => @response[:transaction],
:card_number => params[:cardnumber]
:authorization => @response[:transaction]
)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/trust_commerce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ def commit(action, parameters)
:test => test?,
:authorization => data["transid"],
:cvv_result => data["cvv"],
:avs_result => { :code => data["avs"] },
:card_number => parameters['cc']
:avs_result => { :code => data["avs"] }
)
end

Expand Down
11 changes: 1 addition & 10 deletions lib/active_merchant/billing/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Error < ActiveMerchantError #:nodoc:
end

class Response
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result, :card_data
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result

def success?
@success
Expand All @@ -26,15 +26,6 @@ def initialize(success, message, params = {}, options = {})
@fraud_review = options[:fraud_review]
@avs_result = AVSResult.new(options[:avs_result]).to_hash
@cvv_result = CVVResult.new(options[:cvv_result]).to_hash
@card_data = format_card_data(options[:card_number])
end

private
def format_card_data(number)
{
'type' => CreditCard.type?(number),
'number' => CreditCard.last_digits(number)
}
end
end
end
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/authorize_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(fraud_review_response)

response = @gateway.purchase(100, @credit_card)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private

def post_data_fixture
Expand Down
9 changes: 1 addition & 8 deletions test/unit/gateways/brain_tree_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,7 @@ def test_cvv_result
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'N', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_purchase_response)

response = @gateway.purchase(@amount, @credit_card)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end


private
def successful_purchase_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=510695343&avsresponse=N&cvvresponse=N&orderid=ea1e0d50dcc8cfc6e4b55650c592097e&type=sale&response_code=100'
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/card_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_purchase_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

def test_supported_countries
assert_equal ['GB'], CardStreamGateway.supported_countries
end
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/linkpoint_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_authorization_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private
def successful_authorization_response
'<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:41:31 2008</r_time><r_ref>0004486182</r_ref><r_error/><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486182:NNNM:100018312899:</r_code><r_tdate>1199680890</r_tdate><r_score/><r_authresponse/><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>'
Expand Down
10 changes: 1 addition & 9 deletions test/unit/gateways/moneris_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,7 @@ def test_should_raise_error_if_transaction_param_empty_on_credit_request
end
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_purchase_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private

private
def successful_purchase_response
<<-RESPONSE
<?xml version="1.0"?>
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/pay_junction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ def test_purchase_exception
end
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_authorization_response)

response = @gateway.purchase(100, @credit_card)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private
def successful_authorization_response
<<-RESPONSE
Expand Down
8 changes: 0 additions & 8 deletions test/unit/gateways/payflow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end


def test_card_data
@gateway.expects(:ssl_post).returns(successful_authorization_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

def test_using_test_mode
assert @gateway.test?
end
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/paypal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,6 @@ def test_cvv_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'M', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_purchase_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private
def successful_purchase_response
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/psigate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_authorization_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private

def successful_authorization_response
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/quickpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ def test_supported_card_types
assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], QuickpayGateway.supported_cardtypes
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_authorization_response)

response = @gateway.authorize(@amount, @credit_card, @options)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

private

def error_response
Expand Down
7 changes: 0 additions & 7 deletions test/unit/gateways/trust_commerce_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ def test_cvv_result
assert_equal 'P', response.cvv_result['code']
end

def test_card_data
@gateway.expects(:ssl_post).returns(successful_purchase_response)

response = @gateway.purchase(@amount, @credit_card)
assert_equal CreditCard.last_digits(@credit_card.number), response.card_data['number']
end

def test_supported_countries
assert_equal ['US'], TrustCommerceGateway.supported_countries
end
Expand Down
18 changes: 0 additions & 18 deletions test/unit/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,4 @@ def test_cvv_result
assert_equal 'M', cvv_result['code']
assert_equal CVVResult.messages['M'], cvv_result['message']
end

def test_card_data
response = Response.new(true, 'message', {}, :card_number => '5105105105105100')
assert_equal 'master', response.card_data['type']
assert_equal CreditCard.last_digits('5105105105105100'), response.card_data['number']
end

def test_empty_card_data
response = Response.new(true, 'message', {}, :card_number => nil)
assert_nil response.card_data['type']
assert_nil response.card_data['number']
end

def test_blank_card_data
response = Response.new(true, 'message', {}, :card_number => '')
assert_nil response.card_data['type']
assert_nil response.card_data['number']
end
end

0 comments on commit d2da5d4

Please sign in to comment.