/
remote_itransact_test.rb
89 lines (75 loc) · 2.8 KB
/
remote_itransact_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require 'test_helper'
class RemoteItransactTest < Test::Unit::TestCase
def setup
@gateway = ItransactGateway.new(fixtures(:itransact))
@amount = 1065
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('4000300011112220')
@options = {
:order_id => '1',
:billing_address => address,
:description => 'Store Purchase'
}
end
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_nil response.message
end
# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
# production gateway account in test mode.
# def test_unsuccessful_purchase
# assert response = @gateway.purchase(@amount, @credit_card, @options)
# assert_failure response
# assert_equal 'DECLINE', response.params['error_category']
# assert_equal 'Code: NBE001 Your credit card was declined by the credit card processing network. Please use another card and resubmit your transaction.', response.message
# end
def test_authorize_and_capture
amount = @amount
assert response = @gateway.authorize(amount, @credit_card, @options)
assert_success response
assert_nil response.message
assert response.authorization
assert capture = @gateway.capture(amount, response.authorization)
assert_success capture
end
# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
# production gateway account in test mode.
# def test_failed_capture
# assert response = @gateway.capture(@amount, '9999999999')
# assert_failure response
# assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message
# end
def test_authorize_and_void
amount = @amount
assert response = @gateway.authorize(amount, @credit_card, @options)
assert_success response
assert_nil response.message
assert response.authorization
assert capture = @gateway.void(response.authorization)
assert_success capture
end
def test_void
assert void = @gateway.void('9999999999')
assert_success void
end
# As of Sep 19, 2012, iTransact REQUIRES the total amount for the refund.
# def test_refund
# assert refund = @gateway.refund(nil, '9999999999')
# assert_success refund
# end
def test_refund_partial
assert refund = @gateway.refund(555, '9999999999') # $5.55 in cents
assert_success refund
end
def test_invalid_login
gateway = ItransactGateway.new(
:login => 'x',
:password => 'x',
:gateway_id => 'x'
)
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_equal 'Invalid login credentials', response.message
end
end