Sha256: 256a637477366945089c5e0159b6a90d10e0c0e4a7296ac96c01e86477bfa1da

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 KB

Contents

require File.dirname(__FILE__) + '/../../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

11 entries across 11 versions & 5 rubygems

Version Path
martinstannard-activemerchant-0.1.0 test/unit/gateways/pay_secure_test.rb
seamusabshere-active_merchant-1.4.2.1 test/unit/gateways/pay_secure_test.rb
seamusabshere-active_merchant-1.4.2.3 test/unit/gateways/pay_secure_test.rb
activemerchant-1.4.1 test/unit/gateways/pay_secure_test.rb
activemerchant-1.3.1 test/unit/gateways/pay_secure_test.rb
activemerchant-1.4.0 test/unit/gateways/pay_secure_test.rb
activemerchant-1.3.2 test/unit/gateways/pay_secure_test.rb
activemerchant-1.3.0 test/unit/gateways/pay_secure_test.rb
activemerchant-1.4.2 test/unit/gateways/pay_secure_test.rb
merb_merchant-1.4.1 test/unit/gateways/pay_secure_test.rb
spree-0.2.0 vendor/plugins/active_merchant/test/unit/gateways/pay_secure_test.rb