Skip to content

Commit

Permalink
Revert "Merge pull request activemerchant#218 from odorcicd/moneris_f…
Browse files Browse the repository at this point in the history
…raud"

This reverts commit df93d86, reversing
changes made to 147648e.
  • Loading branch information
John Duff committed Mar 7, 2012
1 parent d42ca07 commit f509a42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 87 deletions.
34 changes: 4 additions & 30 deletions lib/active_merchant/billing/gateways/moneris.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def debit_params(money, creditcard, options = {})
:amount => amount(money), :amount => amount(money),
:pan => creditcard.number, :pan => creditcard.number,
:expdate => expdate(creditcard), :expdate => expdate(creditcard),
:crypt_type => options[:crypt_type] || @options[:crypt_type], :crypt_type => options[:crypt_type] || @options[:crypt_type]
:cvv => creditcard.verification_value,
:billing_address => options[:address] || options[:billing_address]
} }
end end


Expand Down Expand Up @@ -131,9 +129,7 @@ def commit(action, parameters = {})


Response.new(successful?(response), message_from(response[:message]), response, Response.new(successful?(response), message_from(response[:message]), response,
:test => test?, :test => test?,
:authorization => authorization_from(response), :authorization => authorization_from(response)
:avs_result => {:code => response[:avs_result_code]},
:cvv_result => response[:cvd_result_code] && response[:cvd_result_code].last
) )
end end


Expand Down Expand Up @@ -176,32 +172,10 @@ def post_data(action, parameters = {})
actions[action].each do |key| actions[action].each do |key|
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank? transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
end end


add_avs_info(transaction, parameters)
add_cvd_info(transaction, parameters)

xml.to_s xml.to_s
end end


def add_avs_info(transaction, parameters)
if address = parameters[:billing_address]
street_number, street_name = address[:address1].split(' ', 2)

avs_info = transaction.add_element('avs_info')
avs_info.add_element('avs_street_number').text = street_number
avs_info.add_element('avs_street_name').text = street_name
avs_info.add_element('avs_zipcode').text = address[:zip]
end
end

def add_cvd_info(transaction, parameters)
if cvd_value = parameters[:cvv]
cvd_info = transaction.add_element('cvd_info')
cvd_info.add_element('cvd_indicator').text = '1'
cvd_info.add_element('cvd_value').text = cvd_value
end
end

def message_from(message) def message_from(message)
return 'Unspecified error' if message.blank? return 'Unspecified error' if message.blank?
message.gsub(/[^\w]/, ' ').split.join(" ").capitalize message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
Expand Down
14 changes: 1 addition & 13 deletions test/remote/gateways/remote_moneris_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def setup
Base.mode = :test Base.mode = :test


@gateway = MonerisGateway.new(fixtures(:moneris)) @gateway = MonerisGateway.new(fixtures(:moneris))
@amount = 1010 @amount = 100
@credit_card = credit_card('4242424242424242') @credit_card = credit_card('4242424242424242')
@options = { @options = {
:order_id => generate_unique_id, :order_id => generate_unique_id,
Expand Down Expand Up @@ -79,16 +79,4 @@ def test_failed_purchase_from_error
assert_failure response assert_failure response
assert_equal 'Declined', response.message assert_equal 'Declined', response.message
end end

def test_avs_results
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_equal "A", response.avs_result["code"]
end

def test_cvd_results
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_equal "M", response.cvv_result["code"]
end
end end
46 changes: 2 additions & 44 deletions test/unit/gateways/moneris_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,23 +42,7 @@ def test_refund
@gateway.expects(:parse).returns({}) @gateway.expects(:parse).returns({})
@gateway.refund(@amount, "123;456", @options) @gateway.refund(@amount, "123;456", @options)
end end


def test_avs_result
@gateway.expects(:ssl_post).returns(successful_purchase_response_with_avs_and_cvd)

assert response = @gateway.authorize(100, @credit_card, @options)
assert_success response
assert_equal 'M', response.avs_result["code"]
end

def test_cvd_result
@gateway.expects(:ssl_post).returns(successful_purchase_response_with_avs_and_cvd)

assert response = @gateway.authorize(100, @credit_card, @options)
assert_success response
assert_equal 'M', response.cvv_result["code"]
end

def test_amount_style def test_amount_style
assert_equal '10.34', @gateway.send(:amount, 1034) assert_equal '10.34', @gateway.send(:amount, 1034)


Expand Down Expand Up @@ -151,33 +135,7 @@ def successful_purchase_response
RESPONSE RESPONSE
end end


def successful_purchase_response_with_avs_and_cvd
<<-RESPONSE
<?xml version="1.0"?>
<response>
<receipt>
<ReceiptId>1026.1</ReceiptId>
<ReferenceNum>661221050010170010</ReferenceNum>
<ResponseCode>027</ResponseCode>
<ISO>01</ISO>
<AuthCode>013511</AuthCode>
<TransTime>18:41:13</TransTime>
<TransDate>2008-01-05</TransDate>
<TransType>00</TransType>
<Complete>true</Complete>
<Message>APPROVED * =</Message>
<TransAmount>1.00</TransAmount>
<CardType>V</CardType>
<TransID>58-0_3</TransID>
<TimedOut>false</TimedOut>
<AvsResultCode>M</AvsResultCode>
<CvdResultCode>1M</CvdResultCode>
</receipt>
</response>
RESPONSE
end

def failed_purchase_response def failed_purchase_response
<<-RESPONSE <<-RESPONSE
<?xml version="1.0"?> <?xml version="1.0"?>
Expand Down

0 comments on commit f509a42

Please sign in to comment.