Sha256: 6ea83498339002b8a26bf40a7bb4a0b14844c3eef3ade250597957a9303dd202

Contents?: true

Size: 1.64 KB

Versions: 15

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

class RemoteModernPaymentTest < Test::Unit::TestCase

  def setup
    @gateway = ModernPaymentsGateway.new(fixtures(:modern_payments))
    
    @amount = 100
    @credit_card = credit_card('4111111111111111')
    @declined_card = credit_card('4000000000000000')
    
    @options = { 
      :order_id => '1',
      :billing_address => address,
      :description => 'Store Purchase'
    }
    
  end
  
  def test_successful_purchase
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    
    # Test mode seems to not return "approved = true"
    assert_failure response
    assert_match /RESPONSECODE=A/, response.params["auth_string"]
    assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message
  end

  def test_unsuccessful_purchase
    assert response = @gateway.purchase(@amount, @declined_card, @options)
    assert_failure response
    assert_match /RESPONSECODE=D/, response.params["auth_string"]
    assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message
  end

  def test_invalid_login
    gateway = ModernPaymentsGateway.new(
                :login => '5000',
                :password => 'password'
              )
    assert response = gateway.purchase(@amount, @credit_card, @options)
    assert_failure response
    assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message
  end
  
  def test_invalid_login
    gateway = ModernPaymentsGateway.new(
                :login => '',
                :password => ''
              )
              
    assert_raises(ActiveMerchant::ResponseError) do
      gateway.purchase(@amount, @credit_card, @options)
    end
  end
  
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
goldstar-activemerchant-1.4.2.7 test/remote/gateways/remote_modern_payments_test.rb
goldstar-activemerchant-1.4.2.6 test/remote/gateways/remote_modern_payments_test.rb
smulube-activemerchant-1.5.1.4 test/remote/gateways/remote_modern_payments_test.rb
smulube-activemerchant-1.5.1.3 test/remote/gateways/remote_modern_payments_test.rb
smulube-activemerchant-1.5.1.2 test/remote/gateways/remote_modern_payments_test.rb
activemerchant-est-1.4.2.6 test/remote/gateways/remote_modern_payments_test.rb
activemerchant-1.5.0 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.6 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.5 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.4 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.3 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.2 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2.1 test/remote/gateways/remote_modern_payments_test.rb
activemerchant-est-1.4.2.5 test/remote/gateways/remote_modern_payments_test.rb
patmaddox-activemerchant-1.4.2 test/remote/gateways/remote_modern_payments_test.rb