Permalink
Browse files

Update Realex to add support for cvv data. remove test_result_from_cc…

…_number.

git-svn-id: https://activemerchant.googlecode.com/svn/trunk/active_merchant@605 6513ea26-6c20-0410-8a68-89cd7235086d
  • Loading branch information...
1 parent 840fb36 commit f19f05d96d09c7f2f5d9c8bd9330fcf411a8c04b codyfauser committed Jan 28, 2008
View
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG
+* Update Realex to add support for cvv data. remove test_result_from_cc_number. [cody]
* Update Protx to add support for avs and cvv data. remove test_result_from_cc_number. [cody]
* Include ActiveMerchant::Utils module in test_helper and use generate_unique_id from the module instead of generate_order_id. [cody]
* Update SecurePay tests to check for avs and cvv data. [cody]
@@ -56,21 +56,13 @@ def purchase(money, credit_card, options = {})
end
private
- def commit(request)
- if result = test_result_from_cc_number(parse_credit_card_number(request))
- return result
- end
-
- data = ssl_post(URL, request)
-
- @response = parse(data)
+ def commit(request)
+ response = parse(ssl_post(URL, request))
- success = @response[:result] == "00"
- test = response[:message] =~ /\[ test system \]/
-
- Response.new(success, message_from(@response), @response,
- :test => test,
- :authorization => @response[:authcode]
+ Response.new(response[:result] == "00", message_from(response), response,
+ :test => response[:message] =~ /\[ test system \]/,
+ :authorization => response[:authcode],
+ :cvv_result => response[:cvnresult]
)
end
@@ -1,8 +1,7 @@
require File.dirname(__FILE__) + '/../../test_helper'
class RemoteRealexTest < Test::Unit::TestCase
- AMOUNT = 10000
-
+
def setup
@gateway = RealexGateway.new(fixtures(:realex))
@@ -20,16 +19,14 @@ def setup
@mastercard_referral_b = fixtures(:realex_mastercard_referral_b)
@mastercard_referral_a = fixtures(:realex_mastercard_referral_a)
@mastercard_coms_error = fixtures(:realex_mastercard_coms_error)
- end
-
- def test_nothing
- assert true
+
+ @amount = 10000
end
def test_realex_purchase
[ @visa, @mastercard ].each do |card|
- response = @gateway.purchase(AMOUNT, card,
+ response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Purchase',
:billing_address => {
@@ -50,7 +47,7 @@ def test_realex_purchase_with_invalid_login
:login => 'invalid',
:password => 'invalid'
)
- response = gateway.purchase(AMOUNT, @visa,
+ response = gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'Invalid login test'
)
@@ -65,7 +62,7 @@ def test_realex_purchase_with_invalid_login
def test_realex_purchase_with_invalid_account
- response = @gateway_with_account.purchase(AMOUNT, @visa,
+ response = @gateway_with_account.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'Test Realex purchase with invalid acocunt'
)
@@ -82,7 +79,7 @@ def test_realex_purchase_declined
[ @visa_declined, @mastercard_declined ].each do |card|
- response = @gateway.purchase(AMOUNT, card,
+ response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex purchase declined'
)
@@ -98,7 +95,7 @@ def test_realex_purchase_declined
def test_realex_purchase_referral_b
[ @visa_referral_b, @mastercard_referral_b ].each do |card|
- response = @gateway.purchase(AMOUNT, card,
+ response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Referral B'
)
@@ -113,7 +110,7 @@ def test_realex_purchase_referral_b
def test_realex_purchase_referral_a
[ @visa_referral_a, @mastercard_referral_a ].each do |card|
- response = @gateway.purchase(AMOUNT, card,
+ response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Rqeferral A'
)
@@ -129,7 +126,7 @@ def test_realex_purchase_coms_error
[ @visa_coms_error, @mastercard_coms_error ].each do |card|
- response = @gateway.purchase(AMOUNT, card,
+ response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex coms error'
)
@@ -146,7 +143,7 @@ def test_realex_purchase_coms_error
def test_realex_ccn_error
@visa.number = 5
- response = @gateway.purchase(AMOUNT, @visa,
+ response = @gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'Test Realex ccn error'
)
@@ -161,7 +158,7 @@ def test_realex_ccn_error
def test_realex_expiry_month_error
@visa.month = 13
- response = @gateway.purchase(AMOUNT, @visa,
+ response = @gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'Test Realex expiry month error'
)
@@ -176,7 +173,7 @@ def test_realex_expiry_month_error
def test_realex_expiry_year_error
@visa.year = 2005
- response = @gateway.purchase(AMOUNT, @visa,
+ response = @gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'Test Realex expiry year error'
)
@@ -191,7 +188,7 @@ def test_invalid_credit_card_name
@visa.first_name = ""
@visa.last_name = ""
- response = @gateway.purchase(AMOUNT, @visa,
+ response = @gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'test_chname_error'
)
@@ -205,7 +202,7 @@ def test_invalid_credit_card_name
def test_cvn
@visa_cvn = @visa.clone
@visa_cvn.verification_value = "111"
- response = @gateway.purchase(AMOUNT, @visa_cvn,
+ response = @gateway.purchase(@amount, @visa_cvn,
:order_id => generate_unique_id,
:description => 'test_cvn'
)
@@ -215,7 +212,7 @@ def test_cvn
end
def test_customer_number
- response = @gateway.purchase(AMOUNT, @visa,
+ response = @gateway.purchase(@amount, @visa,
:order_id => generate_unique_id,
:description => 'test_cust_num',
:customer => 'my customer id'
@@ -2,8 +2,7 @@
require 'digest/sha1'
class RealexTest < Test::Unit::TestCase
- AMOUNT = 100
-
+
def setup
@login = 'your_merchant_id'
@password = 'your_secret'
@@ -20,14 +19,20 @@ def setup
:account => 'bill_web_cengal'
)
- @creditcard = CreditCard.new(
+ @credit_card = CreditCard.new(
:number => '4263971921001307',
:month => 8,
:year => 2008,
:first_name => 'Longbob',
:last_name => 'Longsen',
:type => 'visa'
)
+
+ @options = {
+ :order_id => '1'
+ }
+
+ @amount = 100
end
@@ -43,35 +48,23 @@ def test_hash
result = Digest::SHA1.hexdigest(result + "." + @password)
assert_equal "06a8b619cbd76024676401e5a83e7e5453521af3", result
end
-
-
- def test_successful_request
- @creditcard.number = 1
- assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
- assert_success response
- assert_equal '5555', response.authorization
- assert response.test?
- end
-
- def test_unsuccessful_request
- @creditcard.number = 2
- assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
- assert_failure response
- assert response.test?
- end
def test_successful_purchase
- @gateway.expects(:ssl_post).returns(successful_response)
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_instance_of Response, response
assert_success response
+ assert response.test?
end
def test_unsuccessful_purchase
- @gateway.expects(:ssl_post).returns(unsuccessful_response)
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_instance_of Response, response
assert_failure response
+ assert response.test?
end
def test_supported_countries
@@ -82,10 +75,23 @@ def test_supported_card_types
assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
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
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_equal 'M', response.cvv_result['code']
+ end
private
- def successful_response
+ def successful_purchase_response
<<-RESPONSE
<response timestamp='20010427043422'>
<merchantid>your merchant id</merchantid>
@@ -114,15 +120,15 @@ def successful_response
RESPONSE
end
- def unsuccessful_response
+ def unsuccessful_purchase_response
<<-RESPONSE
<response timestamp='20010427043422'>
<merchantid>your merchant id</merchantid>
<account>account to use</account>
<orderid>order id from request</orderid>
<authcode>authcode received</authcode>
<result>01</result>
- <message>message returned from system</message>
+ <message>[ test system ] message returned from system</message>
<pasref> realex payments reference</pasref>
<cvnresult>M</cvnresult>
<batchid>batch id for this transaction (if any)</batchid>

0 comments on commit f19f05d

Please sign in to comment.