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
smulube-activemerchant-1.5.1.3 test/unit/gateways/pay_secure_test.rb
smulube-activemerchant-1.5.1.2 test/unit/gateways/pay_secure_test.rb
ghazel-activemerchant-1.4.2 test/unit/gateways/pay_secure_test.rb
activemerchant-est-1.4.2.6 test/unit/gateways/pay_secure_test.rb
activemerchant-1.5.0 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.6 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.5 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.4 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.3 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.2 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2.1 test/unit/gateways/pay_secure_test.rb
activemerchant-est-1.4.2.5 test/unit/gateways/pay_secure_test.rb
patmaddox-activemerchant-1.4.2 test/unit/gateways/pay_secure_test.rb
abtain_billing-1.03 test/unit/gateways/pay_secure_test.rb
abtain_billing-1.02 test/unit/gateways/pay_secure_test.rb
abtain_billing-1.0 test/unit/gateways/pay_secure_test.rb