Sha256: 13f0517bfaf0a081c969d10174847002b48cf86f0a1ca58184e9318e97a107ae

Contents?: true

Size: 1.61 KB

Versions: 36

Compression:

Stored size: 1.61 KB

Contents

require 'test_helper'

class NetbillingTest < Test::Unit::TestCase
  def setup
    @gateway = NetbillingGateway.new(
                 :login => 'login',
                 :password => 'password'
               )

    @credit_card = credit_card('4242424242424242')
    @amount = 100
    @options = { :billing_address => address }
  end
  
  def test_successful_request
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_success response
    assert_equal '110270311543', response.authorization
    assert response.test?
  end

  def test_unsuccessful_request
    @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
    
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_failure response
    assert response.test?
  end
  
  def test_avs_result
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    response = @gateway.purchase(@amount, @credit_card, @options)
    assert_equal 'X', response.avs_result['code']
  end
  
  def test_cvv_result
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    response = @gateway.purchase(@amount, @credit_card, @options)
    assert_equal 'M', response.cvv_result['code']
  end
  
  private
  def successful_purchase_response
    "avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=110270311543&auth_msg=TEST+APPROVED&auth_date=2008-01-25+16:43:54"
  end
  
  def unsuccessful_purchase_response
    "status_code=0&auth_msg=CARD+EXPIRED&trans_id=110492608613&auth_date=2008-01-25+17:47:44"
  end
end

Version data entries

36 entries across 36 versions & 11 rubygems

Version Path
johnideal-activemerchant-1.4.10 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.11 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.4 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.5 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.6 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.7 test/unit/gateways/netbilling_test.rb
johnideal-activemerchant-1.4.8 test/unit/gateways/netbilling_test.rb
mattbauer-activemerchant-1.4.2 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.3 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.4 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.5 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.6 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.7 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.8 test/unit/gateways/netbilling_test.rb
tomriley-tomriley-active_merchant-1.4.2.4 test/unit/gateways/netbilling_test.rb
goldstar-activemerchant-1.4.2.7 test/unit/gateways/netbilling_test.rb
goldstar-activemerchant-1.4.2.6 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.11 test/unit/gateways/netbilling_test.rb
tomriley-active_merchant-1.4.2.10 test/unit/gateways/netbilling_test.rb
smulube-activemerchant-1.5.1.4 test/unit/gateways/netbilling_test.rb