Sha256: 2b61009275bf2f35399bc97a9a7c3ecc161155e7656390bc18e8efdc3da2349f

Contents?: true

Size: 1.9 KB

Versions: 36

Compression:

Stored size: 1.9 KB

Contents

require 'test_helper'

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

    @credit_card = credit_card
    @options = { 
      :order_id => '1000',
      :billing_address => address,
      :description => 'Test purchase'
    }
    @amount = 100
  end
  
  def test_successful_purchase
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_instance_of Response, response
    assert_success response
    assert_equal '2778;SimProxy 54041670', response.authorization
    assert response.test?
  end
  
  def test_failed_purchase
    @gateway.expects(:ssl_post).returns(failure_response)
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_instance_of Response, response
    assert_equal "Field value '8f796cb29a1be32af5ce12d4ca7425c2' does not match required format.", response.message
    assert_failure response
  end
  
  def test_avs_result_not_supported
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    response = @gateway.purchase(@amount, @credit_card, @options)    
    assert_nil response.avs_result['code']
  end
  
  def test_cvv_result_not_supported
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    response = @gateway.purchase(@amount, @credit_card, @options)
    assert_nil response.cvv_result['code']
  end
  
  private
  def successful_purchase_response
    <<-RESPONSE
Status: Accepted
SettlementDate: 2007-10-09
AUTHNUM: 2778
ErrorString: No Error
CardBin: 1
ERROR: 0
TransID: SimProxy 54041670
    RESPONSE
  end
  
  def failure_response
    <<-RESPONSE
Status: Declined
ErrorString: Field value '8f796cb29a1be32af5ce12d4ca7425c2' does not match required format.
ERROR: 1
    RESPONSE
  end
end

Version data entries

36 entries across 36 versions & 11 rubygems

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