test/unit/gateways/payment_express_test.rb in activemerchant-1.2.1 vs test/unit/gateways/payment_express_test.rb in activemerchant-1.3.0
- old
+ new
@@ -6,87 +6,53 @@
@gateway = PaymentExpressGateway.new(
:login => 'LOGIN',
:password => 'PASSWORD'
)
- @visa = CreditCard.new(
- :number => '4242424242424242',
- :month => 8,
- :year => 2008,
- :first_name => 'Longbob',
- :last_name => 'Longsen',
- :type => 'visa'
- )
+ @visa = credit_card
- @solo = CreditCard.new(
- :type => "solo",
- :number => "6334900000000005",
- :month => 11,
- :year => 2012,
- :first_name => "Test",
- :last_name => "Mensch",
- :issue_number => '01'
- )
+ @solo = credit_card("6334900000000005",
+ :type => "solo",
+ :issue_number => '01'
+ )
- @address = { :address1 => '1234 My Street',
- :address2 => 'Apt 1',
- :company => 'Widgets Inc',
- :city => 'Ottawa',
- :state => 'ON',
- :zip => 'K1C2N6',
- :country => 'Canada',
- :phone => '(555)555-5555'
- }
- end
-
- def test_successful_request
- @visa.number = 1
+ @options = {
+ :order_id => generate_unique_id,
+ :billing_address => address,
+ :email => 'cody@example.com',
+ :description => 'Store purchase'
+ }
- assert response = @gateway.purchase(100, @visa)
- assert_success response
- assert_equal '5555', response.authorization
- assert response.test?
+ @amount = 100
end
-
- def test_unsuccessful_request
- @visa.number = 2
- assert response = @gateway.purchase(100, @visa)
- assert_failure response
- assert response.test?
- end
-
- def test_request_error
- @visa.number = 3
- assert_raise(Error){ @gateway.purchase(100, @visa) }
- end
def test_default_currency
assert_equal 'NZD', PaymentExpressGateway.default_currency
end
def test_invalid_credentials
@gateway.expects(:ssl_post).returns(invalid_credentials_response)
- assert response = @gateway.purchase(100, @visa)
+ assert response = @gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid Credentials', response.message
assert_failure response
end
def test_successful_authorization
@gateway.expects(:ssl_post).returns(successful_authorization_response)
- assert response = @gateway.purchase(100, @visa)
+ assert response = @gateway.purchase(@amount, @visa, @options)
assert_success response
assert response.test?
assert_equal 'APPROVED', response.message
assert_equal '00000004011a2478', response.authorization
end
def test_successful_solo_authorization
@gateway.expects(:ssl_post).returns(successful_authorization_response)
- assert response = @gateway.purchase(100, @solo)
+ assert response = @gateway.purchase(@amount, @solo, @options)
assert_success response
assert response.test?
assert_equal 'APPROVED', response.message
assert_equal '00000004011a2478', response.authorization
end
@@ -124,11 +90,11 @@
assert response = @gateway.store(@visa)
token = response.token
@gateway.expects(:ssl_post).returns( successful_token_purchase_response )
- assert response = @gateway.purchase(100, token)
+ assert response = @gateway.purchase(@amount, token, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert_equal '0000000303ace8db', response.authorization
end
@@ -138,10 +104,24 @@
def test_supported_card_types
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb ], PaymentExpressGateway.supported_cardtypes
end
+ def test_avs_result_not_supported
+ @gateway.expects(:ssl_post).returns(successful_authorization_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_authorization_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_nil response.cvv_result['code']
+ end
+
private
def invalid_credentials_response
'<Txn><ReCo>0</ReCo><ResponseText>Invalid Credentials</ResponseText></Txn>'
end
@@ -149,10 +129,10 @@
<<-RESPONSE
<Txn>
<Transaction success="1" reco="00" responsetext="APPROVED">
<Authorized>1</Authorized>
<MerchantReference>Test Transaction</MerchantReference>
- <Cvc2></Cvc2>
+ <Cvc2>M</Cvc2>
<CardName>Visa</CardName>
<Retry>0</Retry>
<StatusRequired>0</StatusRequired>
<AuthCode>015921</AuthCode>
<Amount>1.23</Amount>